|
|
|
|
|
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 * from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
$resultans = api_sql_query($queryans, __FILE__, __LINE__);
while ($row = mysql_fetch_array($resultans))
{
$ind = $row['answer'];
$choice[$ind] = 1;
}
$studentChoice=$choice[$answerId];
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);
$queryans = "select answer from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
$resultans = api_sql_query($queryans, __FILE__, __LINE__);
$choice = mysql_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);
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 `".$TABLETRACK_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;
for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
{
$answer=$objAnswerTmp->selectAnswer($answerId);
$answerComment=$objAnswerTmp->selectComment($answerId);
$answerCorrect=$objAnswerTmp->isCorrect($answerId);
$answerWeighting=$objAnswerTmp->selectWeighting($answerId);
$queryfree = "select marks from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
$resfree = api_sql_query($queryfree, __FILE__, __LINE__);
$questionScore= mysql_result($resfree,0,"marks");
//to assign marks to open question
$totalScore+=$questionScore;
$query = "select answer from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
$resq=api_sql_query($query);
$choice = mysql_result($resq,0,"answer");
?>
|
|
|
|
|
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);
$querymatch = "select * from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
$resmatch = api_sql_query($querymatch, __FILE__, __LINE__);
while ($row = mysql_fetch_array($resmatch))
{
$ind = $row['position'];
$answ = $row['answer'];
$choice[$ind] = $answ;
}
if($answerCorrect)
{
if($answerCorrect == $choice[$answerId])
{
$questionScore+=$answerWeighting;
$totalScore+=$answerWeighting;
$choice[$answerId]=$matching[$choice[$answerId]];
}
elseif(!$choice[$answerId])
{
$choice[$answerId]=' ';
}
else
{
$choice[$answerId]=''.$matching[$choice[$answerId]].'';
}
}
else
{
$matching[$answerId]=$answer;
}
?>
$v)
{
if($key==$answerId)
{
echo "".$answer." | ";
echo "";
echo $v.'/';
}
}
?>
|
|
".$comnt;
?>
defaultRenderer();
$renderer->setFormTemplate(
' ');
$renderer->setElementTemplate(
' {element} '
);
$comnt =get_comments($id,$questionId);
${user.$questionId}['comments_'.$questionId] = $comnt;
$$questionId->addElement('html_editor','comments_'.$questionId,false);
//$$questionId->addElement('submit','submitQuestion',get_lang('Ok'));
$$questionId->setDefaults(${user.$questionId});
$$questionId->display();
?>
".$comnt;
}
?>
|