[svn r16000] MULTIPLE question bug fixed - (see FS#2795)

skala
Julio Montoya 18 years ago
parent 9d478c671a
commit d1a817fe3c
  1. 21
      main/exercice/exercise_result.php
  2. 4
      main/exercice/exercise_show.php

@ -29,7 +29,7 @@
* @author Olivier Brouckaert, main author * @author Olivier Brouckaert, main author
* @author Roan Embrechts, some refactoring * @author Roan Embrechts, some refactoring
* @author Julio Montoya Armas switchable fill in blank option added * @author Julio Montoya Armas switchable fill in blank option added
* @version $Id: exercise_result.php 15967 2008-08-10 06:40:40Z yannoo $ * @version $Id: exercise_result.php 16000 2008-08-15 04:26:07Z juliomontoya $
* *
* @todo split more code up in functions, move functions to library? * @todo split more code up in functions, move functions to library?
*/ */
@ -438,6 +438,9 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
$counter++; $counter++;
// gets the student choice for this question // gets the student choice for this question
$choice=$exerciseResult[$questionId]; $choice=$exerciseResult[$questionId];
//print_r($choice); echo "<br>";
// creates a temporary Question object // creates a temporary Question object
$objQuestionTmp = Question :: read($questionId); $objQuestionTmp = Question :: read($questionId);
@ -951,11 +954,19 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
} }
if ($answerType==MULTIPLE_ANSWER ) if ($answerType==MULTIPLE_ANSWER )
{ {
$reply = array_keys($choice); if ($choice != 0)
for ($i=0;$i<sizeof($reply);$i++) {
$reply = array_keys($choice);
for ($i=0;$i<sizeof($reply);$i++)
{
$ans = $reply[$i];
exercise_attempt($questionScore,$ans,$quesId,$exeId,$i);
}
}
else
{ {
$ans = $reply[$i]; exercise_attempt($questionScore, 0 ,$quesId,$exeId,0);
exercise_attempt($questionScore,$ans,$quesId,$exeId,$i);
} }
} }
elseif ($answerType==MATCHING) elseif ($answerType==MATCHING)

@ -348,7 +348,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
$exerciseDexcription=mysql_result($result,0,1); $exerciseDexcription=mysql_result($result,0,1);
$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($_user['user_id'])." "; $user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($_user['user_id'])." ";
$query = "select * from ".$TBL_TRACK_ATTEMPT." as attempts $query = "select attempts.question_id, answer from ".$TBL_TRACK_ATTEMPT." as attempts
INNER JOIN ".$TBL_TRACK_EXERCICES." as stats_exercices ON stats_exercices.exe_id=attempts.exe_id INNER JOIN ".$TBL_TRACK_EXERCICES." as stats_exercices ON stats_exercices.exe_id=attempts.exe_id
INNER JOIN ".$TBL_EXERCICE_QUESTION." as quizz_rel_questions ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id AND quizz_rel_questions.question_id = attempts.question_id INNER JOIN ".$TBL_EXERCICE_QUESTION." as quizz_rel_questions ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id AND quizz_rel_questions.question_id = attempts.question_id
INNER JOIN ".$TBL_QUESTIONS." as questions ON questions.id=quizz_rel_questions.question_id INNER JOIN ".$TBL_QUESTIONS." as questions ON questions.id=quizz_rel_questions.question_id
@ -356,7 +356,6 @@ $query = "select * from ".$TBL_TRACK_ATTEMPT." as attempts
GROUP BY quizz_rel_questions.question_order, attempts.question_id"; GROUP BY quizz_rel_questions.question_order, attempts.question_id";
//GROUP BY questions.position, attempts.question_id"; //GROUP BY questions.position, attempts.question_id";
$result =api_sql_query($query, __FILE__, __LINE__); $result =api_sql_query($query, __FILE__, __LINE__);
?> ?>
@ -397,6 +396,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$questionList[] = $row['question_id']; $questionList[] = $row['question_id'];
$exerciseResult[] = $row['answer']; $exerciseResult[] = $row['answer'];
} }
//echo '<pre>';print_R($questionList);
foreach($questionList as $questionId) foreach($questionList as $questionId)
{ {
$counter++; $counter++;

Loading…
Cancel
Save