0 && isset($id)) {
$test=Database::result($result,0,0);
$exerciseTitle=api_parse_tex($test);
$exerciseDexcription=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);
$queryans = "select answer from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$resultans = api_sql_query($queryans, __FILE__, __LINE__);
$choice = Database::result($resultans,0,"answer");
$studentChoice=($choice == $answerId)?1:0;
if ($studentChoice) {
$questionScore+=$answerWeighting;
$totalScore+=$answerWeighting;
}
?>
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=strpos($temp,'[tex]');
$endlocations=strpos($temp,'[/tex]');
if($startlocations !== false && $endlocations !== false) {
$texstring=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 = strpos($temp,'[')) === false) {
// adds the end of the text
$answer.=$temp;
// TeX parsing
$texstring = api_parse_tex($texstring);
break;
}
$temp=substr($temp,$pos+1);
// quits the loop if there are no more blanks
if(($pos = 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];
$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]))) {
// 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=substr($temp,$pos+1);
$i=$i+1;
}
$answer = $str;
} else {
//multiple fill in blank
while(1) {
// quits the loop if there are no more blanks
if(($pos = 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[]=substr($temp,0,$pos+1);
$answer.=substr($temp,0,$pos+1);
$temp=substr($temp,$pos+1);
// quits the loop if there are no more blanks
if(($pos = 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[]=stripslashes(strtolower($choice[$j]));
$correct_tags[]=strtolower(substr($temp,0,$pos));
$j++;
$temp=substr($temp,$pos+1);
$i=$i+1;
}
$answer='';
for($i=0;$i
selectNbrAnswers();
$questionScore=0;
$query = "select answer, marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$resq=api_sql_query($query);
$choice = Database::result($resq,0,"answer");
$questionScore = Database::result($resq,0,"marks");
if($questionScore==-1){
$totalScore+=0;
}
else{
$totalScore+=$questionScore;
}
?>
0';
$sql_answer = 'SELECT position, answer FROM '.$table_ans.' WHERE question_id="'.Database::escape_string($questionId).'" AND correct=0';
$res_answer = api_sql_query($sql_answer, __FILE__, __LINE__);
// getting the real answer
$real_list =array();
while($real_answer = Database::fetch_array($res_answer)) {
$real_list[$real_answer['position']]= $real_answer['answer'];
}
$res_answers = api_sql_query($sql_select_answer, __FILE__, __LINE__);
echo '
';
echo '
';
echo '
'.get_lang("ElementList").'
'.get_lang("CorrespondsTo").'
';
echo '
';
$questionScore=0;
while($a_answers = Database::fetch_array($res_answers)) {
$i_answer_id = $a_answers['id']; //3
$s_answer_label = $a_answers['answer']; // your dady - you mother
$i_answer_correct_answer = $a_answers['correct']; //1 - 2
$i_answer_position = $a_answers['position']; // 3 - 4
$sql_user_answer =
'SELECT answers.answer
FROM '.$TBL_TRACK_ATTEMPT.' as track_e_attempt
INNER JOIN '.$table_ans.' as answers
ON answers.position = track_e_attempt.answer
AND track_e_attempt.question_id=answers.question_id
WHERE answers.correct = 0
AND track_e_attempt.exe_id = "'.Database::escape_string($id).'"
AND track_e_attempt.question_id = "'.Database::escape_string($questionId).'"
AND track_e_attempt.position="'.Database::escape_string($i_answer_position).'"';
$res_user_answer = api_sql_query($sql_user_answer, __FILE__, __LINE__);
if (Database::num_rows($res_user_answer)>0 )
$s_user_answer = Database::result($res_user_answer,0,0); // rich - good looking
else
$s_user_answer = '';
//$s_correct_answer = $s_answer_label; // your ddady - your mother
$s_correct_answer = $real_list[$i_answer_correct_answer];
$i_answerWeighting=$objAnswerTmp->selectWeighting($i_answer_id);
//if($s_user_answer == $s_correct_answer) // rich == your ddady?? wrong
//echo $s_user_answer.' - '.$real_list[$i_answer_correct_answer];
if($s_user_answer == $real_list[$i_answer_correct_answer]) // rich == your ddady?? wrong
{
$questionScore+=$i_answerWeighting;
$totalScore+=$i_answerWeighting;
}
else
{
$s_user_answer = ''.$s_user_answer.'';
}
echo '
';
echo '
'.$s_answer_label.'
'.$s_user_answer.' / '.$s_correct_answer.'
';
echo '
';
}
echo '
';
} else if($answerType == HOTSPOT) {
?>
selectNbrAnswers();
$questionScore=0;
?>
selectAnswer($answerId);
$answerComment=$objAnswerTmp->selectComment($answerId);
$answerCorrect=$objAnswerTmp->isCorrect($answerId);
$answerWeighting=$objAnswerTmp->selectWeighting($answerId);
$TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$query = "select hotspot_correct from ".$TBL_TRACK_HOTSPOT." where hotspot_exe_id = '".Database::escape_string($id)."' and hotspot_question_id= '".Database::escape_string($questionId)."' AND hotspot_answer_id='".Database::escape_string($answerId)."'";
$resq=api_sql_query($query);
$choice = Database::result($resq,0,"hotspot_correct");
display_hotspot_answer($answerId,$answer,$choice,$answerComment);
$i++;
}
$queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$resfree = api_sql_query($queryfree, __FILE__, __LINE__);
$questionScore= Database::result($resfree,0,"marks");
$totalScore+=$questionScore;
?>