[svn r19574] logic changes - allow see random questions - (partial FS#3976)

skala
Isaac Flores 17 years ago
parent 61b298ae36
commit 239013288a
  1. 25
      main/exercice/exercice_submit.php
  2. 14
      main/exercice/exercise.class.php

@ -1,4 +1,4 @@
<?php // $Id: exercice_submit.php 19500 2009-04-02 15:15:56Z cvargas1 $
<?php // $Id: exercice_submit.php 19574 2009-04-06 20:56:01Z iflorespaz $
/*
==============================================================================
@ -42,7 +42,7 @@
* @package dokeos.exercise
* @author Olivier Brouckaert
* @author Julio Montoya multiple fill in blank option added
* @version $Id: exercice_submit.php 19500 2009-04-02 15:15:56Z cvargas1 $
* @version $Id: exercice_submit.php 19574 2009-04-06 20:56:01Z iflorespaz $
*/
@ -640,14 +640,33 @@ $exerciseDescription=stripslashes($exerciseDescription);
$exerciseSound=$objExercise->selectSound();
$randomQuestions=$objExercise->isRandom();
$exerciseType=$objExercise->selectType();
$table_quiz_test= Database :: get_course_table(TABLE_QUIZ_TEST);
//if (!isset($_SESSION['questionList']) || $origin == 'learnpath') {
//in LP's is enabled the "remember question" feature?
$my_exe_id=Security::remove_XSS($_GET['exerciseId']);
if (!isset($_SESSION['questionList'])) {
if ($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset'."<br />\n";}
// selects the list of question ID
$my_question_list=array();
$questionList = ($randomQuestions?$objExercise->selectRandomList():$objExercise->selectQuestionList());
// saves the question list into the session
$sql='SELECT random FROM '.$table_quiz_test.' WHERE id="'.Database::escape_string($my_exe_id).'";';
$rs=api_sql_query($sql,__FILE__,__LINE__);
$row_number=Database::fetch_array($rs);
$z=0;
if ($row_number['random']<>0) {
foreach ($questionList as $infoquestionList) {
if ($z<$row_number['random']) {
$my_question_list[$z]=$infoquestionList;
} else {
break;
}
$z++;
}
// $questionList=array();
$questionList=$my_question_list;
}
api_session_register('questionList');
if ($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset - set now - end'."<br />\n";}
}

@ -25,7 +25,7 @@
* Exercise class: This class allows to instantiate an object of type Exercise
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: exercise.class.php 19480 2009-04-01 15:51:23Z cvargas1 $
* @version $Id: exercise.class.php 19574 2009-04-06 20:56:01Z iflorespaz $
*/
@ -300,9 +300,15 @@ class Exercise
function selectRandomList()
{
$nbQuestions = $this->selectNbrQuestions();
$temp_list = $this->questionList;
shuffle($temp_list);
return array_combine(range(1,$nbQuestions),$temp_list);
$temp_list = $this->questionList;
//error_log(print_r($temp_list,true));
//error_log(count($temp_list));
if (count($temp_list)<>0) {
shuffle($temp_list);
return array_combine(range(1,$nbQuestions),$temp_list);
}
$nbQuestions = $this->selectNbrQuestions();
//Not a random exercise, or if there are not at least 2 questions

Loading…
Cancel
Save