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);
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]');
$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;
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 = $id and question_id= $questionId";
$resfill = api_sql_query($queryfill, __FILE__, __LINE__);
$str=mysql_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;
?>
selectNbrAnswers();
$questionScore=0;
$query = "select answer, marks from ".$TBL_TRACK_ATTEMPT." where exe_id = $id and question_id= $questionId";
$resq=api_sql_query($query);
$choice = mysql_result($resq,0,"answer");
$questionScore = mysql_result($resq,0,"marks");
if($questionScore==-1){
$totalScore+=0;
}
else{
$totalScore+=$questionScore;
}
?>