/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1

« back to all changes in this revision

Viewing changes to trunk/DuggaSys/quizSystem/answerQuiz.php

  • Committer: Daniel Johansson
  • Date: 2013-03-28 14:01:33 UTC
  • mto: (4.7.5 GammaBear)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: maila@danieljohansson.nu-20130328140133-j2mugl3t6x25bxjc
Uppdaterat DuggaSys till att följa kodstandard utseendemässigt. Namnkonventioner kvar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
////    if incorrect the answer is not stored, else stored 
7
7
 
8
8
//Store answer and loginName+answer hash
9
 
function storeAnswer($loginName,$password,$courseName,$courseOccasion,$quizNr,$qVarNr,$quizAnswer,$grade,$gradeComment,$ip,$userAgent,$pdo){
 
9
function storeAnswer($loginName,$password,$courseName,$courseOccasion,$quizNr,$qVarNr,$quizAnswer,$grade,$gradeComment,$ip,$userAgent,$pdo) {
10
10
        $updateQuery="UPDATE AssignedQuizzes 
11
11
                                  SET AssignedQuizzes.answer=:ANSWER, 
12
12
                                          AssignedQuizzes.answerHash=:ANSWERHASH, 
64
64
$stmt->bindParam(':COCCASION', $_POST['courseOccasion']);
65
65
$stmt->execute();
66
66
 
67
 
if($stmt->fetchColumn()==1){ //Student is registered for the course - COUNT result read from the first column of the next unread row (i.e. the first row) 
 
67
if($stmt->fetchColumn()==1) { //Student is registered for the course - COUNT result read from the first column of the next unread row (i.e. the first row) 
68
68
        //Check if quiz is open (and fetch auto correction setting)
69
69
        $queryString="SELECT Quiz.opening, Quiz.closing, Quiz.autoCorrected
70
70
                                   FROM Quiz
75
75
        $stmt->bindParam(':CNAME', $_POST['courseName']);
76
76
        $stmt->execute();
77
77
        $quizData=$stmt->fetch(PDO::FETCH_ASSOC);
78
 
        if($quizData){
 
78
        if($quizData) {
79
79
                
80
80
                $now = new DateTime();
81
81
                $opening = new DateTime($quizData['opening']);
127
127
        $stmt->bindParam(':COCCASION', $_POST['courseOccasion']);
128
128
        $stmt->execute();
129
129
        $result=$stmt->fetch(PDO::FETCH_ASSOC);
130
 
        if($result){ //If there is a quiz variant assigned to the student
 
130
        if($result) { //If there is a quiz variant assigned to the student
131
131
                        if($result['answerHash']!=NULL){ //Student has already answered the quiz
132
132
                                echo json_encode(array('Error' => 'This quiz has already been answered', 'answerHash'=>$result['answerHash']));
133
133
                                exit();
134
134
                        } else { //check if autoCorrection
135
135
                        
136
 
                                if($quizData['autoCorrected']=='0'){ //Not auto corrected
 
136
                                if($quizData['autoCorrected']=='0') { //Not auto corrected
137
137
                                        if(storeAnswer($_POST['loginName'],
138
138
                                                                   $_POST['password'],
139
139
                                                                   $_POST['courseName'],