Skip to content
Snippets Groups Projects
Commit f5017cb0 authored by bewe's avatar bewe
Browse files

fix: submit

parent f734812e
No related merge requests found
...@@ -22,7 +22,16 @@ function submitQuiz($exerciseId, $exerciseName, $selectedOptions, $userId, $isDo ...@@ -22,7 +22,16 @@ function submitQuiz($exerciseId, $exerciseName, $selectedOptions, $userId, $isDo
curl_setopt($ch, CURLOPT_URL, "http://192.168.0.11:5000/exercise/result/" . $exerciseId); curl_setopt($ch, CURLOPT_URL, "http://192.168.0.11:5000/exercise/result/" . $exerciseId);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($submitData)); curl_setopt(
$ch,
CURLOPT_POSTFIELDS,
json_encode(
array(
"selectedOptions" => $submitData,
"userId" => (int)$userId,
)
)
);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$response = curl_exec($ch); $response = curl_exec($ch);
...@@ -75,45 +84,6 @@ function submitQuiz($exerciseId, $exerciseName, $selectedOptions, $userId, $isDo ...@@ -75,45 +84,6 @@ function submitQuiz($exerciseId, $exerciseName, $selectedOptions, $userId, $isDo
// echo 'Progress added successfully. Progress id: ' . $data['result']['progress_id']; // echo 'Progress added successfully. Progress id: ' . $data['result']['progress_id'];
} }
// soap add gems
$baseUrl = 'http://soap:8080/service/gems';
$soapRequest = '<x:Envelope
xmlns:x="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="http://service.toco.org/">
<x:Header/>
<x:Body>
<ser:addGems>
<user_id>' . $userId . '</user_id>
<gem>' . $score . '</gem>
<type> Gems Recieved from ' . $exerciseName . ' Exercise</type>
</ser:addGems>
</x:Body>
</x:Envelope>';
$ch = curl_init($baseUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $soapRequest);
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
array(
'Content-Type: text/xml',
'SOAPAction: addGems',
'X-api-key: toco_php'
)
);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
return $score; return $score;
} }
......
...@@ -29,6 +29,16 @@ $selectedLanguageId = isset($_GET['language']) ? (int) $_GET['language'] : -1; ...@@ -29,6 +29,16 @@ $selectedLanguageId = isset($_GET['language']) ? (int) $_GET['language'] : -1;
<div class="exercise-head"> <div class="exercise-head">
<div class="content"> <div class="content">
<h2 class="font-bold text-md"> <h2 class="font-bold text-md">
<?php
$imageUrl = null;
foreach ($data["languages"] as $language) {
if ($language["language_id"] == $exercise["language_id"]) {
$imageUrl = $language["language_flag"];
break;
}
}
?>
<img src="<?= $imageUrl ?>" alt="language" width="20px" height="20px" class="language-icon">
<?= $exercise['exe_name'] ?> <?= $exercise['exe_name'] ?>
</h2> </h2>
<?php <?php
......
...@@ -3,12 +3,21 @@ ...@@ -3,12 +3,21 @@
<h1 class="font-bold text-xl text-blue-purple-gradient"> <h1 class="font-bold text-xl text-blue-purple-gradient">
Merchandise Merchandise
</h1> </h1>
<h2 class="gems font-bold"> <h2 class="gems">
Your Balance: <?= $data['gems'] ?> gems <img src="/public/icons/gems.svg" alt="gem" width="50px" class="gem-icon">
<div>
<div class="font-reg">
Your Balance:
</div>
<div class="font-bold">
<?= $data['gems'] ?> gems
</div>
</div>
</h2> </h2>
<div class="merchandise-items"> <div class="merchandise-items">
<? foreach ($data['merch'] as $merch): ?> <? foreach ($data['merch'] as $merch): ?>
<div class="merch-item" style="background-image: url('http://192.168.0.11:5000/image/?filename=<?= $merch['image'] ?>');"> <div class="merch-item"
style="background-image: url('http://192.168.0.11:5000/image/?filename=<?= $merch['image'] ?>');">
<div class="merch-image"></div> <div class="merch-image"></div>
<div class="merch-details"> <div class="merch-details">
<div class="merch-name"> <div class="merch-name">
...@@ -33,4 +42,4 @@ ...@@ -33,4 +42,4 @@
<? endforeach; ?> <? endforeach; ?>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -21,6 +21,15 @@ ...@@ -21,6 +21,15 @@
.gems { .gems {
color: var(--orange); color: var(--orange);
font-size: 28px; font-size: 28px;
min-width: 300px;
border-radius: 20px;
background: #FFFF9E;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
justify-content: center;
cursor: pointer;
transition: all 0.3s ease 0s;
padding: 20px 0;
text-align: center;
} }
.merchandise-items { .merchandise-items {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment