|
5 | 5 | if (isset($_GET["questionKey"])) {
|
6 | 6 | $questionKey = $_GET["questionKey"];
|
7 | 7 | } else {
|
8 |
| - echo "no questionKey"; |
9 |
| - exit(); |
| 8 | + log_error("no questionKey",""); |
10 | 9 | }
|
11 | 10 | }
|
12 | 11 | if(!isset($assignmentKey)){
|
13 | 12 | if (isset($_GET["assignmentKey"])) {
|
14 | 13 | $assignmentKey = $_GET["assignmentKey"];
|
15 | 14 | } else {
|
16 |
| - echo "no assignmentKey"; |
17 |
| - exit(); |
| 15 | + log_error("no assignmentKey",""); |
18 | 16 | }
|
19 | 17 | }
|
20 | 18 | if(!isset($teacherKey)){
|
21 | 19 | if (isset($_GET["teacherKey"])) {
|
22 | 20 | $teacherKey = $_GET["teacherKey"];
|
23 | 21 | } else {
|
24 |
| - echo "no teacherKey"; |
25 |
| - exit(); |
| 22 | + log_error("no teacherKey",""); |
26 | 23 | }
|
27 | 24 | }
|
28 | 25 | if(!isset($hint_number)){
|
29 | 26 | if (isset($_GET["number"])) {
|
30 | 27 | $hint_number = $_GET["number"];
|
31 | 28 | } else {
|
32 |
| - echo "no hint number"; |
33 |
| - exit(); |
| 29 | + log_error("no hint number",""); |
34 | 30 | }
|
35 | 31 | }
|
36 | 32 | if(!$logged_in) {
|
37 |
| - echo "Login. I see you found this address and figured out how the hints were retrieved."; |
38 |
| - exit(); |
| 33 | + log_error("Login. I see you found this address and figured out how the hints were retrieved.",""); |
39 | 34 | }
|
40 | 35 | require_once "../../resources/authFunctions.php";
|
41 | 36 | require_once "../../resources/questionFormat.php";
|
42 | 37 | if(questionInAssignment($assignmentKey,$questionKey,$conn,$is_teacher)) {
|
43 | 38 | if(canViewAssignment($assignmentKey,$is_teacher,$conn,$user)) {
|
44 |
| - $results = $conn->query("SELECT `hints` FROM questions WHERE `key`=$questionKey LIMIT 1"); |
| 39 | + if(!$results = $conn->query("SELECT `hints` FROM questions WHERE `key`=$questionKey LIMIT 1")){ |
| 40 | + log_error("failed to get hints","",$conn->error); |
| 41 | + } |
45 | 42 | while ($row = $results->fetch_assoc()) {
|
46 | 43 | $hints = explode(";", $row["hints"]);
|
47 | 44 | foreach (array_keys($hints, "", true) as $key) {
|
48 | 45 | unset($hints[$key]);
|
49 | 46 | }
|
50 | 47 | if (sizeof($hints)+1 != $hint_number) {
|
51 |
| - $result=$conn->query("SELECT `variables` FROM `variables` WHERE `email`=\"".$user["email"]."\" AND `question`=$questionKey"); |
| 48 | + if(!$result=$conn->query("SELECT `variables` FROM `variables` WHERE `email`=\"".$user["email"]."\" AND `question`=$questionKey")){ |
| 49 | + log_error("failed to get variables","",$conn->error); |
| 50 | + } |
52 | 51 | $vars=array();
|
53 | 52 | while($row=$result->fetch_assoc()){
|
54 | 53 | foreach (explode("|",$row["variables"]) as $key => $value){
|
|
58 | 57 | }
|
59 | 58 | }
|
60 | 59 | echo format_text_tilde_codes($hints[$hint_number+1],$vars,$teacherKey);//STarts at 1
|
61 |
| - $result=$conn->query("SELECT `hint` FROM `hints` WHERE `email`=\"".$user["email"]."\" AND `assignmentKey`=$assignmentKey AND `question`=$questionKey AND `hint`=".($hint_number+1)); |
| 60 | + if(!$result=$conn->query("SELECT `hint` FROM `hints` WHERE `email`=\"".$user["email"]."\" AND `assignmentKey`=$assignmentKey AND `question`=$questionKey AND `hint`=".($hint_number+1))){ |
| 61 | + log_error("failed to get hints","",$conn->error); |
| 62 | + } |
62 | 63 | $found=false;
|
63 | 64 | while($result->fetch_assoc()){
|
64 | 65 | $found = true;
|
65 | 66 | }
|
66 | 67 | $result->close();
|
67 | 68 | if(!$found) {
|
68 |
| - $conn->query("INSERT INTO `hints`(`email`, `assignmentKey`, `question`, `hint`, `time`) VALUES (\"" . $user["email"] . "\",$assignmentKey,$questionKey," . ($hint_number + 1) . "," . time() . ")"); |
| 69 | + if(!$conn->query("INSERT INTO `hints`(`email`, `assignmentKey`, `question`, `hint`, `time`) VALUES (\"" . $user["email"] . "\",$assignmentKey,$questionKey," . ($hint_number + 1) . "," . time() . ")")){ |
| 70 | + log_error("failed to inser hints","",$conn->error); |
| 71 | + } |
69 | 72 | }
|
70 | 73 | } else {
|
71 | 74 | echo "No more hints";
|
72 | 75 | }
|
73 | 76 | }
|
74 | 77 | $results->close();
|
75 | 78 | } else {
|
76 |
| - echo "Question not in that assignment silly."; |
| 79 | + log_error("Question not in that assignment.",""); |
77 | 80 | }
|
78 | 81 | } else {
|
79 |
| - echo "Permission Denied"; |
| 82 | + log_error("Permission Denied",""); |
80 | 83 | }
|
0 commit comments