diff --git a/main/exercice/addlimits.php b/main/exercice/addlimits.php index 436b7d639b..5e21e6f909 100644 --- a/main/exercice/addlimits.php +++ b/main/exercice/addlimits.php @@ -1,6 +1,6 @@ 0){echo str_repeat(' ',0).'Entered exercise_result.php'."
\n";var_dump($_POST);} +if($debug>0) +{ + echo str_repeat(' ',0).'Entered exercise_result.php'."
\n";var_dump($_POST); +} // general parameters passed via POST/GET -if ( empty ( $origin ) ) { +if ( empty ( $origin ) ) +{ $origin = $_REQUEST['origin']; } -if ( empty ( $learnpath_id ) ) { +if ( empty ( $learnpath_id ) ) +{ $learnpath_id = mysql_real_escape_string($_REQUEST['learnpath_id']); } -if ( empty ( $learnpath_item_id ) ) { +if ( empty ( $learnpath_item_id ) ) +{ $learnpath_item_id = mysql_real_escape_string($_REQUEST['learnpath_item_id']); } -if ( empty ( $formSent ) ) { +if ( empty ( $formSent ) ) +{ $formSent= $_REQUEST['formSent']; } -if ( empty ( $exerciseResult ) ) { +if ( empty ( $exerciseResult ) ) +{ $exerciseResult = $_SESSION['exerciseResult']; } -if ( empty ( $questionId ) ) { +if ( empty ( $questionId ) ) +{ $questionId = $_REQUEST['questionId']; } if ( empty ( $choice ) ) { $choice = $_REQUEST['choice']; } -if ( empty ( $questionNum ) ) { +if ( empty ( $questionNum ) ) +{ $questionNum = mysql_real_escape_string($_REQUEST['questionNum']); -} -if ( empty ( $nbrQuestions ) ) { +} +if ( empty ( $nbrQuestions ) ) +{ $nbrQuestions = mysql_real_escape_string($_REQUEST['nbrQuestions']); } -if ( empty ( $questionList ) ) { +if ( empty ( $questionList ) ) +{ $questionList = $_SESSION['questionList']; } -if ( empty ( $objExercise ) ) { +if ( empty ( $objExercise ) ) +{ $objExercise = $_SESSION['objExercise']; } $exercise_id = $_GET['exercise_id']; -$is_allowedToEdit=$is_courseAdmin; +$is_allowedToEdit=$is_courseAdmin; $nameTools=get_lang('Exercice'); @@ -117,7 +130,7 @@ Display::display_header($nameTools,"Exercise"); include('../inc/global.inc.php'); if (isset($_POST['ok'])) { - $message = "Test limits added"; + $message = get_lang('TestLimitsAdded'); Display::display_normal_message($message); } ?> @@ -127,26 +140,23 @@ if (isset($_POST['ok'])) -

- -

+


Time :

- Unlimited +
- Limited: Each question of the test should be answered in + minute(s). +.

-Attempts : +:

- Unlimited +
- Limited: The test can be taken only + time(s). + .

- +
read($exerciseId); + $objExercise->read($exerciseId); } // saves the object into the session @@ -282,12 +289,12 @@ else $nameTools=get_lang('ExerciseManagement'); } -$interbreadcrump[]=array("url" => "exercice.php","name" => get_lang('Exercices')); +$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')); // shows a link to go back to the question pool if(!$exerciseId && $nameTools != get_lang('ExerciseManagement')) { - $interbreadcrump[]=array("url" => "question_pool.php?fromExercise=$fromExercise","name" => get_lang('QuestionPool')); + $interbreadcrumb[]=array("url" => "question_pool.php?fromExercise=$fromExercise","name" => get_lang('QuestionPool')); } // if the question is duplicated, disable the link of tool name @@ -326,7 +333,7 @@ Function VBGetSwfVer(i) on error resume next Dim swControl, swVersion swVersion = 0 - + set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i)) if (IsObject(swControl)) then swVersion = swControl.GetVariable(\"\$version\") @@ -372,46 +379,46 @@ function JSGetSwfVer(i){ else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2; // Can't detect in all other cases else { - + flashVer = -1; } return flashVer; -} +} // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available -function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) +function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { reqVer = parseFloat(reqMajorVer + \".\" + reqRevision); - // loop backwards through the versions until we find the newest version - for (i=25;i>0;i--) { + // loop backwards through the versions until we find the newest version + for (i=25;i>0;i--) { if (isIE && isWin && !isOpera) { versionStr = VBGetSwfVer(i); } else { versionStr = JSGetSwfVer(i); } - if (versionStr == -1 ) { + if (versionStr == -1 ) { return false; } else if (versionStr != 0) { if(isIE && isWin && !isOpera) { tempArray = versionStr.split(\" \"); tempString = tempArray[1]; - versionArray = tempString .split(\",\"); + versionArray = tempString .split(\",\"); } else { versionArray = versionStr.split(\".\"); } versionMajor = versionArray[0]; versionMinor = versionArray[1]; versionRevision = versionArray[2]; - + versionString = versionMajor + \".\" + versionRevision; // 7.0r24 == 7.24 versionNum = parseFloat(versionString); // is the major.revision >= requested major.revision AND the minor version >= requested minor if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) { return true; } else { - return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false ); + return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false ); } } - } + } } // --> "; @@ -428,7 +435,7 @@ if($newQuestion || $editQuestion) { // statement management $type = $_REQUEST['answerType']; - ?> + ?> @@ -105,12 +106,12 @@ require_once(api_get_path(SYS_PATH).'claroline/exercice/hotpotatoes.lib.php'); window.location='exercice.php'; "; - } + } } echo "
"; @@ -125,7 +126,7 @@ if($lstrComment=="") if($lstrComment=="") $lstrComment = GetFileName($hotpotatoesName,$documentPath); -echo $lstrComment; +echo $lstrComment; echo "\" size=40> "; echo " "; echo ""; diff --git a/main/exercice/answer.class.php b/main/exercice/answer.class.php index 342ea56c55..ce9c95a711 100644 --- a/main/exercice/answer.class.php +++ b/main/exercice/answer.class.php @@ -1,25 +1,25 @@ -questionId; //$answerType=$this->selectType(); - - $sql="SELECT answer,correct,comment,ponderation,position, hotspot_coordinates, hotspot_type FROM $TBL_ANSWER WHERE question_id='$questionId' ORDER BY position"; - + + $sql="SELECT answer,correct,comment,ponderation,position, hotspot_coordinates, hotspot_type FROM $TBL_ANSWER WHERE question_id='$questionId' ORDER BY position"; + $result=api_sql_query($sql,__FILE__,__LINE__); $i=1; @@ -147,24 +147,24 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates; */ function readOrderedBy($field,$order=ASC) { - global $_course; + global $_course; $field = mysql_real_escape_string($field); if(empty($field)){ $field = 'position'; } if($order != 'ASC' and $order!='DESC'){ $order = 'ASC'; - } + } $TBL_ANSWER = Database::get_course_table('quiz_answer'); $questionId=$this->questionId; //$answerType=$this->selectType(); - + $sql="SELECT answer,correct,comment,ponderation,position, hotspot_coordinates, hotspot_type " . "FROM $TBL_ANSWER " . "WHERE question_id='$questionId' " . "ORDER BY $field $order"; - + $result=api_sql_query($sql,__FILE__,__LINE__); $i=1; @@ -217,7 +217,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates; { return $this->answer[$id]; } - + /** * Returns a list of answers * @author Yannick Warnier @@ -256,7 +256,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates; } return $list; } - + /** * Returns the question type * @author Yannick Warnier @@ -273,7 +273,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates; $row = Database::fetch_array($res); return $row['type']; } - + /** * tells if answer is correct or not @@ -364,7 +364,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates; $this->new_nbrAnswers++; $id=$this->new_nbrAnswers; - + $this->new_answer[$id]=$answer; $this->new_correct[$id]=$correct; $this->new_comment[$id]=$comment; @@ -373,7 +373,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates; $this->new_hotspot_coordinates[$id]=$new_hotspot_coordinates; $this->new_hotspot_type[$id]=$new_hotspot_type; } - + /** * updates an answer * @@ -386,9 +386,9 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates; function updateAnswers($answer,$comment,$weighting,$position) { global $TBL_REPONSES; - + $questionId=$this->questionId; - + $sql = "UPDATE `$TBL_REPONSES` SET " . "`answer` = '$answer', " . "`comment` = '$comment', " . @@ -396,7 +396,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates; "`position` = '$position' " . "WHERE `id` =$position " . "AND `question_id` =$questionId"; - + api_sql_query($sql,__FILE__,__LINE__); } @@ -419,7 +419,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates; $sql="INSERT INTO `$TBL_REPONSES`" . "(id,question_id,answer,correct,comment," . "ponderation,position,hotspot_coordinates,hotspot_type) VALUES"; - + for($i=1;$i <= $this->new_nbrAnswers;$i++) { $answer=addslashes($this->new_answer[$i]); @@ -433,9 +433,9 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates; $sql.="('$i','$questionId','$answer','$correct','$comment', '$weighting','$position','$hotspot_coordinates','$hotspot_type'),"; } - + $sql = substr($sql,0,-1); - + api_sql_query($sql,__FILE__,__LINE__); // moves $new_* arrays diff --git a/main/exercice/answer_admin.inc.php b/main/exercice/answer_admin.inc.php index 136220662a..e60aeb0777 100644 --- a/main/exercice/answer_admin.inc.php +++ b/main/exercice/answer_admin.inc.php @@ -1,4 +1,4 @@ -duplicate($questionId); // construction of the duplicated Answers - + $objAnswer=new Answer($questionId); } @@ -99,13 +99,13 @@ if($modifyIn) $weighting=unserialize($weighting); } //free answer - elseif($answerType == FREE_ANSWER ) + elseif($answerType == FREE_ANSWER ) { $reponse=unserialize($reponse); $comment=unserialize($comment); $free_comment=$comment; $weighting=unserialize($weighting); - + } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) { @@ -115,8 +115,8 @@ if($modifyIn) $weighting=unserialize($weighting); $hotspot_coordinates=unserialize($hotspot_coordinates); $hotspot_type=unserialize($hotspot_type); - - + + } //fill in blanks else @@ -196,7 +196,7 @@ if($submitAnswers || $buttonBack) // $mainurl="question_pool.php"; ?> createAnswer('',0,$free_comment,$weighting,''); $objAnswer->save(); // sets the total weighting of the question @@ -402,7 +402,7 @@ if($submitAnswers || $buttonBack) // $mainurl="question_pool.php"; ?> cancel(); - break; + break; } if($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i])) { $msgErr=get_lang('HotspotNotDrawn'); - + // clears answers already recorded into the Answer object $objAnswer->cancel(); - break; + break; } - + } // end for() - + if(empty($msgErr)) { @@ -574,7 +574,7 @@ if($submitAnswers || $buttonBack) for($i=1;$i <= $nbrAnswers;$i++) { if($debug>0){echo str_repeat(' ',4).'$answerType is HOT_SPOT'."
\n";} - + $reponse[$i]=trim($reponse[$i]); $comment[$i]=addslashes(trim($comment[$i])); $weighting[$i]=intval($weighting[$i]); @@ -582,13 +582,13 @@ if($submitAnswers || $buttonBack) { $questionWeighting+=$weighting[$i]; } - + // creates answer $objAnswer->createAnswer($reponse[$i], '',$comment[$i],$weighting[$i],$i,$hotspot_coordinates[$i],$hotspot_type[$i]); } // end for() // saves the answers into the data base $objAnswer->save(); - + // sets the total weighting of the question $objQuestion->updateWeighting($questionWeighting); $objQuestion->save($exerciseId); @@ -606,13 +606,13 @@ if($submitAnswers || $buttonBack) if($modifyAnswers) { - + if($debug>0){echo str_repeat(' ',0).'$modifyAnswers is set'."
\n";} - + // construction of the Answer object $objAnswer=new Answer($questionId); - - + + api_session_register('objAnswer'); if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) @@ -712,7 +712,7 @@ if($modifyAnswers) // but as we have passed into the submitAnswers loop, this should be in the // objAnswer object. $free_comment = $objAnswer->selectComment(1); - $weighting=$objAnswer->selectWeighting(1); //added + $weighting=$objAnswer->selectWeighting(1); //added } elseif(!$modifyIn) { @@ -810,12 +810,12 @@ if($modifyAnswers) elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) { if($debug>0){echo str_repeat(' ',2).'$answerType is HOT_SPOT'."
\n";} - - $TBL_ANSWERS = $_course['dbNameGlu'].'quiz_answer'; - + + $TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER); + if(!$nbrAnswers) { - + $nbrAnswers=$objAnswer->selectNbrAnswers(); $reponse=Array(); @@ -833,10 +833,10 @@ if($modifyAnswers) $hotspot_coordinates[$i]=$objAnswer->selectHotspotCoordinates($i); $hotspot_type[$i]=$objAnswer->selectHotspotType($i); } - - + + } - + $_SESSION['tmp_answers'] = array(); $_SESSION['tmp_answers']['answer'] = $reponse; $_SESSION['tmp_answers']['comment'] = $comment; @@ -848,9 +848,9 @@ if($modifyAnswers) { // At least 1 answer if ($nbrAnswers > 1) { - + $nbrAnswers--; - + // Remove the last answer $tmp = array_pop($_SESSION['tmp_answers']['answer']); $tmp = array_pop($_SESSION['tmp_answers']['comment']); @@ -869,7 +869,7 @@ if($modifyAnswers) if ($nbrAnswers < 12) { $nbrAnswers++; - + // Add a new answer $_SESSION['tmp_answers']['answer'][]=''; $_SESSION['tmp_answers']['comment'][]=''; @@ -888,7 +888,7 @@ if($modifyAnswers) if(!$usedInSeveralExercises) { if($debug>0){echo str_repeat(' ',2).'$usedInSeveralExercises is untrue'."
\n";} - + if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) { if($debug>0){echo str_repeat(' ',4).'$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."
\n";} @@ -905,7 +905,7 @@ if($modifyAnswers)

- @@ -914,9 +914,9 @@ if($modifyAnswers) { ?> - @@ -1054,7 +1054,7 @@ if($modifyAnswers) @@ -1168,7 +1168,7 @@ if($modifyAnswers) - + @@ -1186,7 +1186,7 @@ if($modifyAnswers) } if(!empty($msgErr)) - { + { ?> @@ -1198,9 +1198,9 @@ if($modifyAnswers) @@ -1381,11 +1381,11 @@ if($modifyAnswers) - + "; @@ -392,15 +392,15 @@ else { $charset = 'ISO-8859-15'; } - header('Content-Type: text/html; charset='. $charset); - + header('Content-Type: text/html; charset='. $charset); + @$document_language = Database::get_language_isocode($language_interface); if(empty($document_language)) { //if there was no valid iso-code, use the english one $document_language = 'en'; } - + /* * HTML HEADER */ @@ -443,7 +443,7 @@ foreach($questionList as $questionId) { $i++; $objQuestionTmp = Question :: read($questionId); - + // for sequential exercises if($exerciseType == 2) { diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 0bb4d4cab7..0376cb1d67 100644 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -1,38 +1,38 @@ - addElement('text', 'exerciseTitle', get_lang('ExerciseName').' : '); - + // fck editor global $fck_attribute; $fck_attribute = array(); @@ -625,19 +622,19 @@ class Exercise $fck_attribute['Width'] = '100%'; $fck_attribute['ToolbarSet'] = 'NewTest'; $form -> addElement ('html_editor', 'exerciseDescription', get_lang('ExerciseDescription').' : '); - + // type $radios = array(); $radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SimpleExercise'),'1'); $radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2'); $form -> addGroup($radios, null, get_lang('ExerciseType').' : ', '
'); - + // submit $form -> addElement('submit', 'submitExercise', get_lang('Ok')); - + // rules $form -> addRule ('exerciseTitle', get_lang('GiveExerciseName'), 'required'); - + // defaults $defaults = array(); if($this -> id > 0) @@ -647,25 +644,25 @@ class Exercise $defaults['exerciseDescription'] = $this -> selectDescription(); } $defaults['exerciseType'] = '1'; - + $form -> setDefaults($defaults); - - + + } - - + + /** * function which process the creation of exercises * @param FormValidator $form the formvalidator instance */ - function processCreation($form) + function processCreation($form) { - + $this -> updateTitle($form -> getSubmitValue('exerciseTitle')); $this -> updateDescription($form -> getSubmitValue('exerciseDescription')); $this -> updateType($form -> getSubmitValue('exerciseType')); $this -> save(); - + } } diff --git a/main/exercice/exercise_result.php b/main/exercice/exercise_result.php index 9738ee6cb0..08bdb14053 100644 --- a/main/exercice/exercise_result.php +++ b/main/exercice/exercise_result.php @@ -1,29 +1,29 @@ - + ?> + ?> - + + ?> - + - + + ?>
@@ -278,15 +278,15 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme + +?>

:

@@ -296,20 +296,20 @@ $exerciseTitle=api_parse_tex($exerciseTitle); 0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);} - + // added by Priya Saini $sql = "select max(exe_Id) as id from `".$TABLETRACK_EXERCICES."`"; $res = api_sql_query($sql, __FILE__, __LINE__); $exeId =mysql_result($res,0,"id"); $exeId=$exeId+1; - + foreach($questionList as $questionId) { // gets the student choice for this question $choice=$exerciseResult[$questionId]; // creates a temporary Question object - + $objQuestionTmp = Question :: read($questionId); $questionName=$objQuestionTmp->selectTitle(); @@ -371,7 +371,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle); } elseif($answerType == FILL_IN_BLANKS) { - ?> + ?> @@ -381,7 +381,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle); } elseif($answerType == FREE_ANSWER) { - ?> + ?> @@ -394,7 +394,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle); } elseif($answerType == HOT_SPOT) { - ?> + ?>

@@ -449,7 +449,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle); switch($answerType) { // for unique answer - case UNIQUE_ANSWER : + case UNIQUE_ANSWER : $studentChoice=($choice == $answerId)?1:0; if($studentChoice) @@ -457,12 +457,12 @@ $exerciseTitle=api_parse_tex($exerciseTitle); $questionScore+=$answerWeighting; $totalScore+=$answerWeighting; } - + break; // for multiple answers - case MULTIPLE_ANSWER : - + case MULTIPLE_ANSWER : + $studentChoice=$choice[$answerId]; if($studentChoice) @@ -470,20 +470,20 @@ $exerciseTitle=api_parse_tex($exerciseTitle); $questionScore+=$answerWeighting; $totalScore+=$answerWeighting; } - + break; // for fill in the blanks - case FILL_IN_BLANKS : // splits text and weightings that are joined with the character '::' - + case FILL_IN_BLANKS : // splits text and weightings that are joined with the character '::' + list($answer,$answerWeighting)=explode('::',$answer); // splits weightings that are joined with a comma $answerWeighting=explode(',',$answerWeighting); // we save the answer because it will be modified - + $temp=$answer; - + // TeX parsing // 1. find everything between the [tex] and [/tex] tags $startlocations=strpos($temp,'[tex]'); @@ -491,7 +491,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle); if($startlocations !== false && $endlocations !== false) { - + $texstring=substr($temp,$startlocations,$endlocations-$startlocations+6); // 2. replace this by {texcode} $temp=str_replace($texstring,'{texcode}',$temp); @@ -499,13 +499,13 @@ $exerciseTitle=api_parse_tex($exerciseTitle); $answer=''; - + $j=0; // the loop will stop at the end of the text while(1) - { - + { + // quits the loop if there are no more blanks if(($pos = strpos($temp,'[')) === false) { @@ -524,14 +524,14 @@ $exerciseTitle=api_parse_tex($exerciseTitle); // quits the loop if there are no more blanks if(($pos = strpos($temp,']')) === false) { - + // adds the end of the text $answer.=$temp; break; } $choice[$j]=trim($choice[$j]); - + // if the word entered by the student IS the same as the one defined by the professor if(strtolower(substr($temp,0,$pos)) == stripslashes(strtolower($choice[$j]))) { @@ -566,7 +566,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle); break; // for free answer - case FREE_ANSWER : + case FREE_ANSWER : $studentChoice=$choice; if($studentChoice) @@ -574,11 +574,11 @@ $exerciseTitle=api_parse_tex($exerciseTitle); $questionScore=0; $totalScore+=0; } - + break; // for matching - case MATCHING : + case MATCHING : if($answerCorrect) { if($answerCorrect == $choice[$answerId]) @@ -641,7 +641,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle); elseif($answerType == FREE_ANSWER) { // to store the details of open questions in an array to be used in mail - + $arrques[] = $questionName; $arrans[] = $choice; $firstName = $_SESSION['_user']['firstName']; @@ -666,7 +666,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle); } else { - ?> + ?> - + "; } - ?> + ?> @@ -716,7 +716,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle); for ($i=0;$i([0-9a-z ]*)#', $val, $arr1)) $val = $arr1[1][0]; - $sql = "select position from $table_ans where question_id=$questionId and answer='$val'"; + $sql = "select position from $table_ans where question_id=$questionId and answer='$val'"; $res = api_sql_query($sql, __FILE__, __LINE__); $answer = mysql_result($res,0,"position"); - + exercise_attempt($questionScore,$answer,$quesId,$exeId,$j); - + } } elseif ($answerType==5) @@ -781,14 +781,14 @@ $exerciseTitle=api_parse_tex($exerciseTitle); - + - +
selectId(),$totalScore,$totalWeighting,$answer,$question_id); - + } if ($origin != 'learnpath') @@ -822,15 +822,15 @@ if (!empty($arrques)) $msg = " "; - + /*