0 && isset($id)) {
$test=Database::result($result,0,0);
$exerciseTitle=api_parse_tex($test);
$exerciseDescription=Database::result($result,0,1);
// if the results_disabled of the Quiz is 1 when block the script
$result_disabled=Database::result($result,0,2);
if (!(api_is_platform_admin() || api_is_course_admin()) ) {
if ($result_disabled==1) {
//api_not_allowed();
$show_results = false;
//Display::display_warning_message(get_lang('CantViewResults'));
if ($origin!='learnpath') {
Display::display_warning_message(get_lang('ThankYouForPassingTheTest').'
selectNbrAnswers();
$questionScore=0;
for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
$answerWeighting = $objAnswerTmp->selectWeighting($answerId);
// the question is encoded like this
// [A] B [C] D [E] F::10,10,10@1
// number 1 before the "@" means that is a switchable fill in blank question
// [A] B [C] D [E] F::10,10,10@ or [A] B [C] D [E] F::10,10,10
// means that is a normal fill blank question
$pre_array = explode('::', $answer);
// is switchable fill blank or not
$is_set_switchable = explode('@', $pre_array[1]);
$switchable_answer_set=false;
if ($is_set_switchable[1]==1) {
$switchable_answer_set=true;
}
$answer = $pre_array[0];
// splits weightings that are joined with a comma
$answerWeighting = explode(',',$is_set_switchable[0]);
//list($answer,$answerWeighting)=explode('::',$multiple[0]);
//$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=api_strpos($temp,'[tex]');
$endlocations=api_strpos($temp,'[/tex]');
if ($startlocations !== false && $endlocations !== false) {
$texstring=api_substr($temp,$startlocations,$endlocations-$startlocations+6);
// 2. replace this by {texcode}
$temp=str_replace($texstring,'{texcode}',$temp);
}
$j=0;
// the loop will stop at the end of the text
$i=0;
//normal fill in blank
if (!$switchable_answer_set) {
while (1) {
// quits the loop if there are no more blanks
if (($pos = api_strpos($temp,'[')) === false) {
// adds the end of the text
$answer.=$temp;
// TeX parsing
$texstring = api_parse_tex($texstring);
break;
}
$temp=api_substr($temp,$pos+1);
// quits the loop if there are no more blanks
if (($pos = api_strpos($temp,']')) === false) {
break;
}
$queryfill = "select answer from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$resfill = api_sql_query($queryfill, __FILE__, __LINE__);
$str = Database::result($resfill,0,"answer");
preg_match_all('#\[([^[]*)\]#', $str, $arr);
$choice = $arr[1];
$tmp=strrpos($choice[$j],' / ');
$choice[$j]=substr($choice[$j],0,$tmp);
$choice[$j]=trim($choice[$j]);
// if the word entered by the student IS the same as the one defined by the professor
if (api_strtolower(api_substr($temp,0,$pos)) == api_strtolower($choice[$j])) {
// gives the related weighting to the student
$questionScore+=$answerWeighting[$j];
// increments total score
$totalScore+=$answerWeighting[$j];
}
// else if the word entered by the student IS NOT the same as the one defined by the professor
$j++;
$temp=api_substr($temp,$pos+1);
$i=$i+1;
}
$answer = stripslashes($str);
$answer = str_replace('rn', '', $answer);
} else {
//multiple fill in blank
while (1) {
// quits the loop if there are no more blanks
if (($pos = api_strpos($temp,'[')) === false) {
// adds the end of the text
$answer.=$temp;
// TeX parsing
$texstring = api_parse_tex($texstring);
//$answer=str_replace("{texcode}",$texstring,$answer);
break;
}
// adds the piece of text that is before the blank and ended by [
$real_text[]=api_substr($temp,0,$pos+1);
$answer.=api_substr($temp,0,$pos+1);
$temp=api_substr($temp,$pos+1);
// quits the loop if there are no more blanks
if (($pos = api_strpos($temp,']')) === false) {
// adds the end of the text
//$answer.=$temp;
break;
}
$queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$resfill = api_sql_query($queryfill, __FILE__, __LINE__);
$str=Database::result($resfill,0,"answer");
preg_match_all ('#\[([^[/]*)/#', $str, $arr);
$choice = $arr[1];
$choice[$j]=trim($choice[$j]);
$user_tags[]=api_strtolower($choice[$j]);
$correct_tags[]=api_strtolower(api_substr($temp,0,$pos));
$j++;
$temp=api_substr($temp,$pos+1);
$i=$i+1;
}
$answer='';
for ($i=0;$i
';
unset($objAnswerTmp);
$i++;
$totalWeighting+=$questionWeighting;
} // end of large foreach on questions
} //end of condition if $show_results
if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
//$query = "update ".$TBL_TRACK_EXERCICES." set exe_result = $totalScore where exe_id = '$id'";
//api_sql_query($query,__FILE__,__LINE__);
if ($show_results) {
echo '