skala
Laurent Opprecht 13 years ago
commit 231caa73ad
  1. 4
      main/exercice/answer.class.php
  2. 27
      main/exercice/exercise.class.php
  3. 9
      main/inc/lib/autoload.class.php
  4. 5
      main/inc/lib/events.lib.inc.php

@ -119,7 +119,7 @@ class Answer {
$this->answer[$i] = $object->answer;
$this->correct[$i] = $object->correct;
$this->comment[$i] = $object->comment;
$this->weighting[$i] = $object->ponderation;
$this->weighting[$i] = $object->ponderation;
$this->position[$i] = $object->position;
$this->hotspot_coordinates[$i] = $object->hotspot_coordinates;
$this->hotspot_type[$i] = $object->hotspot_type;
@ -178,7 +178,7 @@ class Answer {
}
if ($question_type['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
$this->answer[$i] = $doubt_data->answer;
$this->answer[$i] = $doubt_data->answer;
$this->correct[$i] = $doubt_data->correct;
$this->comment[$i] = $doubt_data->comment;
$this->weighting[$i] = $doubt_data->ponderation;

@ -1915,6 +1915,7 @@ class Exercise {
$organs_at_risk_hit = 0;
$questionScore = 0;
if ($debug) error_log('Start answer loop ');
$answer_correct_array = array();
@ -1923,7 +1924,8 @@ class Exercise {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
$answerWeighting = $objAnswerTmp->selectWeighting($answerId);
$answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId);
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
$answer_correct_array[$answerId] = (bool)$answerCorrect;
@ -2000,21 +2002,25 @@ class Exercise {
while ($row = Database::fetch_array($resultans)) {
$ind = $row['answer'];
$choice[$ind] = 1;
}
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
}
$studentChoice = $choice[$numAnswer];
$real_answers[$answerId] = (bool)$studentChoice;
if ($studentChoice == $answerCorrect) {
if ($studentChoice) {
$questionScore +=$answerWeighting;
}
} else {
//echo '+---';
//var_dump($numAnswer);
//var_dump($choice);
$studentChoice = $choice[$numAnswer];
if ($studentChoice == $answerCorrect) {
$questionScore +=$answerWeighting;
}
//var_dump($studentChoice .' - '.$answerCorrect);
if (isset($studentChoice)) {
$questionScore += $answerWeighting;
//var_dump($questionScore.' '.$answerWeighting);
}
$real_answers[$answerId] = (bool)$studentChoice;
}
$totalScore +=$answerWeighting;
$totalScore += $answerWeighting;
if ($debug) error_log("studentChoice: $studentChoice");
break;
@ -2864,7 +2870,9 @@ class Exercise {
//Fixes multiple answer question in order to be exact
if ($answerType == MULTIPLE_ANSWER) {
//var_dump($answer_correct_array, $real_answers);
$diff = @array_diff($answer_correct_array, $real_answers);
//var_dump($diff);
/*
* All good answers or nothing works like exact
$counter = 1;
@ -3077,9 +3085,10 @@ class Exercise {
} elseif ($answerType == MULTIPLE_ANSWER) {
if ($choice != 0) {
$reply = array_keys($choice);
if ($debug) error_log("reply ".print_r($reply, 1)."");
for ($i = 0; $i < sizeof($reply); $i++) {
$ans = $reply[$i];
$ans = $reply[$i];
exercise_attempt($questionScore, $ans, $quesId, $exeId, $i, $this->id);
}
} else {

@ -490,11 +490,12 @@ class Autoload
$map = &self::map();
if (isset($map[$class_name])) {
$path = $root . $map[$class_name];
require_once $path;
return true;
} else {
return false;
if (file_exists($path) && is_file($path)) {
require_once $path;
return true;
}
}
return false;
}
}

@ -453,7 +453,7 @@ function exercise_attempt($score, $answer, $question_id, $exe_id, $position, $ex
$score = Database::escape_string($score);
$answer = Database::escape_string($answer);
$question_id = Database::escape_string($question_id);
$exe_id = Database::escape_string($exe_id);
$exe_id = Database::escape_string($exe_id);
$position = Database::escape_string($position);
$now = api_get_utc_datetime();
$user_id = api_get_user_id();
@ -471,8 +471,7 @@ function exercise_attempt($score, $answer, $question_id, $exe_id, $position, $ex
if (!exercise_time_control_is_valid($exercise_id)) {
if ($debug) error_log("exercise_time_control_is_valid is false");
$score = 0;
$answer = 0;
$j = 0;
$answer = 0;
}

Loading…
Cancel
Save