diff --git a/api/exercise/submit.php b/api/exercise/submit.php index 12955ba72df71d091931d24abdd820aefec13288..a4f34b95ec5214ed69d27d5551bf6d5d9300c7d8 100644 --- a/api/exercise/submit.php +++ b/api/exercise/submit.php @@ -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_RETURNTRANSFER, 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')); $response = curl_exec($ch); @@ -75,45 +84,6 @@ function submitQuiz($exerciseId, $exerciseName, $selectedOptions, $userId, $isDo // 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; } diff --git a/app/views/exercise/index.php b/app/views/exercise/index.php index 6210daf16eb10187efab577f3b6bbabead711deb..55a3a7a0246dfa710bfade0da76504def1409d52 100644 --- a/app/views/exercise/index.php +++ b/app/views/exercise/index.php @@ -29,6 +29,16 @@ $selectedLanguageId = isset($_GET['language']) ? (int) $_GET['language'] : -1; <div class="exercise-head"> <div class="content"> <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'] ?> </h2> <?php diff --git a/app/views/merchandise/index.php b/app/views/merchandise/index.php index bd47b5ab8d961014a1e2809a8c0f076248fb7201..63c6338cb32e51bfad05a3e388411e7e2e3dd4ef 100644 --- a/app/views/merchandise/index.php +++ b/app/views/merchandise/index.php @@ -3,12 +3,21 @@ <h1 class="font-bold text-xl text-blue-purple-gradient"> Merchandise </h1> - <h2 class="gems font-bold"> - Your Balance: <?= $data['gems'] ?> gems + <h2 class="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> <div class="merchandise-items"> <? 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-details"> <div class="merch-name"> @@ -33,4 +42,4 @@ <? endforeach; ?> </div> </div> -</div> +</div> \ No newline at end of file diff --git a/public/css/merchandise.css b/public/css/merchandise.css index 3e560331a7632615adb757012809e715c12d60be..d1ce283b459fad584cc50bba8e439f55748414c4 100644 --- a/public/css/merchandise.css +++ b/public/css/merchandise.css @@ -21,6 +21,15 @@ .gems { color: var(--orange); 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 {