-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvalidation.php
39 lines (29 loc) · 1009 Bytes
/
validation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require_once("include/initialize.php");
$studentid = $_SESSION['StudentID'];
$exersiceid = $_POST['ExerciseID'];
$value = $_POST['Value'];
$sql = "SELECT * FROM `tblexercise` WHERE `ExerciseID`='{$exersiceid}'";
$mydb->setQuery($sql);
$quiz = $mydb->loadSingleResult();
$answer = $quiz->Answer;
$lessonid = $quiz->LessonID;
if ($answer == $value) {
$score= 1;
}else{
$score = 0;
}
$sql = "SELECT * From tblscore WHERE ExerciseID = '{$exersiceid}' AND StudentID='{$studentid}'";
$mydb->setQuery($sql);
$row = $mydb->executeQuery();
$maxrow = $mydb->num_rows($row);
if ($maxrow>0) {
$sql = "UPDATE tblscore SET Score='{$score}' WHERE ExerciseID = '{$exersiceid}' AND StudentID='{$studentid}'";
$mydb->setQuery($sql);
$mydb->executeQuery();
}else{
$sql = "INSERT INTO tblscore (`LessonID`,`ExerciseID`, `StudentID`, `Score`) VALUES ('{$lessonid}','{$exersiceid}','{$studentid}','{$score}')";
$mydb->setQuery($sql);
$mydb->executeQuery();
}
?>