[svn r18522] Several bugs fixed see FS#3510 for more details

skala
Julio Montoya 16 years ago
parent 3aa2e830b6
commit af7fa4f150
  1. 112
      main/auth/my_progress.php
  2. 353
      main/exercice/exercice.php
  3. 188
      main/exercice/exercice_submit.php
  4. 19
      main/exercice/exercise.class.php
  5. 22
      main/exercice/exercise.lib.php
  6. 36
      main/exercice/exercise_result.php
  7. 216
      main/exercice/exercise_show.php
  8. 10
      main/exercice/question_list_admin.inc.php
  9. 11
      main/exercice/unique_answer.class.php

@ -1,6 +1,6 @@
<?php <?php
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file = array('registration','tracking','exercice'); $language_file = array('registration','tracking','exercice','admin');
$cidReset = true; $cidReset = true;
@ -67,7 +67,10 @@ $now=date('Y-m-d');
<th><?php echo get_lang('Course'); ?></th> <th><?php echo get_lang('Course'); ?></th>
<th><?php echo get_lang('Time'); ?></th> <th><?php echo get_lang('Time'); ?></th>
<th><?php echo get_lang('Progress'); ?></th> <th><?php echo get_lang('Progress'); ?></th>
<th><?php echo get_lang('Score'); ?></th> <th><?php
echo get_lang('Score');
Display :: display_icon('info3.gif',get_lang('ScormAndLPTestTotalAverage') , array ('style' => 'margin-bottom:-3px;'));
?></th>
<th><?php echo get_lang('LastConnexion'); ?></th> <th><?php echo get_lang('LastConnexion'); ?></th>
<th><?php echo get_lang('Details'); ?></th> <th><?php echo get_lang('Details'); ?></th>
</tr> </tr>
@ -106,8 +109,8 @@ foreach($Courses as $enreg)
<?php echo $pourcentageScore.'%'; ?> <?php echo $pourcentageScore.'%'; ?>
</td> </td>
<td align='center'> <td align='center' >
<?php echo $lastConnexion; ?> <?php echo $lastConnexion ?>
</td> </td>
<td align='center'> <td align='center'>
@ -213,15 +216,11 @@ foreach($Courses as $enreg)
$resultLearnpath = api_sql_query($sqlLearnpath); $resultLearnpath = api_sql_query($sqlLearnpath);
if(Database::num_rows($resultLearnpath)>0) if(Database::num_rows($resultLearnpath)>0) {
{ while($a_learnpath = Database::fetch_array($resultLearnpath)) {
while($a_learnpath = Database::fetch_array($resultLearnpath))
{
$progress = learnpath :: get_db_progress($a_learnpath['id'],$_user['user_id'], '%',$a_infosCours['db_name']); $progress = learnpath :: get_db_progress($a_learnpath['id'],$_user['user_id'], '%',$a_infosCours['db_name']);
// calculates last connection time // calculates last connection time
$sql = 'SELECT MAX(start_time) $sql = 'SELECT MAX(start_time)
FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' AS item_view FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' AS item_view
@ -248,7 +247,7 @@ foreach($Courses as $enreg)
"; ";
echo stripslashes($a_learnpath['name']); echo stripslashes($a_learnpath['name']);
echo " </td> echo " </td>
<td> <td align='center'>
"; ";
echo api_time_to_hms($total_time); echo api_time_to_hms($total_time);
echo " </td> echo " </td>
@ -256,7 +255,7 @@ foreach($Courses as $enreg)
"; ";
echo $progress; echo $progress;
echo " </td> echo " </td>
<td align='center'> <td align='center' width=180px >
"; ";
if($start_time!=''){ if($start_time!=''){
echo format_locale_date(get_lang('dateFormatLong'),$start_time); echo format_locale_date(get_lang('dateFormatLong'),$start_time);
@ -294,19 +293,15 @@ foreach($Courses as $enreg)
$sql='SELECT visibility FROM '.$a_infosCours['db_name'].'.'.TABLE_TOOL_LIST.' WHERE name="quiz"'; $sql='SELECT visibility FROM '.$a_infosCours['db_name'].'.'.TABLE_TOOL_LIST.' WHERE name="quiz"';
$resultVisibilityTests = api_sql_query($sql); $resultVisibilityTests = api_sql_query($sql);
if(Database::result($resultVisibilityTests,0,'visibility')==1){ if (Database::result($resultVisibilityTests,0,'visibility')==1) {
$sqlExercices = " SELECT quiz.title,id, results_disabled
$sqlExercices = " SELECT quiz.title,id
FROM ".$a_infosCours['db_name'].".".$tbl_course_quiz." AS quiz FROM ".$a_infosCours['db_name'].".".$tbl_course_quiz." AS quiz
WHERE active='1' WHERE active='1'";
";
$resuktExercices = api_sql_query($sqlExercices); $resuktExercices = api_sql_query($sqlExercices);
if(Database::num_rows($resuktExercices)>0){ if (Database::num_rows($resuktExercices)>0) {
while($a_exercices = Database::fetch_array($resuktExercices)) while ($a_exercices = Database::fetch_array($resuktExercices)) {
{
$sqlEssais = " SELECT COUNT(ex.exe_id) as essais $sqlEssais = " SELECT COUNT(ex.exe_id) as essais
FROM $tbl_stats_exercices AS ex FROM $tbl_stats_exercices AS ex
WHERE ex.exe_user_id='".$_user['user_id']."' AND ex.exe_cours_id = '".$a_infosCours['code']."' WHERE ex.exe_user_id='".$_user['user_id']."' AND ex.exe_cours_id = '".$a_infosCours['code']."'
@ -320,17 +315,15 @@ foreach($Courses as $enreg)
$sqlScore = "SELECT exe_id , exe_result,exe_weighting $sqlScore = "SELECT exe_id , exe_result,exe_weighting
FROM $tbl_stats_exercices FROM $tbl_stats_exercices
WHERE exe_user_id = ".$_user['user_id']." WHERE exe_user_id = ".$_user['user_id']."
AND exe_cours_id = '".$a_infosCours['code']."' AND exe_cours_id = '".$a_infosCours['code']."'
AND exe_exo_id = ".$a_exercices['id']." AND exe_exo_id = ".$a_exercices['id']."
AND orig_lp_id = 0 AND orig_lp_id = 0
AND orig_lp_item_id = 0 AND orig_lp_item_id = 0
ORDER BY exe_date DESC LIMIT 1" ORDER BY exe_date DESC LIMIT 1";
;
$resultScore = api_sql_query($sqlScore); $resultScore = api_sql_query($sqlScore);
$score = 0; $score = 0;
while($a_score = Database::fetch_array($resultScore)) while($a_score = Database::fetch_array($resultScore)) {
{
$score = $score + $a_score['exe_result']; $score = $score + $a_score['exe_result'];
$weighting = $weighting + $a_score['exe_weighting']; $weighting = $weighting + $a_score['exe_weighting'];
$exe_id = $a_score['exe_id']; $exe_id = $a_score['exe_id'];
@ -339,39 +332,44 @@ foreach($Courses as $enreg)
if ($weighting>0) { if ($weighting>0) {
// i.e 10.50% // i.e 10.50%
$pourcentageScore = round(($score*100)/$weighting,2); $pourcentageScore = round(($score*100)/$weighting,2);
} } else {
else
{
$pourcentageScore=0; $pourcentageScore=0;
} }
$weighting = 0; $weighting = 0;
echo "<tr> echo '<tr>
<td> <td>';
"; echo $a_exercices['title'];
echo $a_exercices['title']; echo '</td>';
echo " </td>
"; if ($a_exercices['results_disabled']==0) {
echo " <td align='center'> echo '<td align="center">';
"; echo $pourcentageScore.'%';
echo $pourcentageScore.'%'; echo '</td>';
echo " </td> echo '<td align="center">';
echo $a_essais['essais'];
<td align='center'> echo '</td>
"; <td align="center" width="25">';
echo $a_essais['essais']; if($a_essais['essais']>0)
echo ' </td> echo '<a href="../exercice/exercise_show.php?origin=myprogress&id='.$exe_id.'&cidReq='.$a_infosCours['code'].'&id_session='.$_GET['id_session'].'"> '.Display::return_icon('quiz.gif', get_lang('Quiz')).' </a>';
<td align="center" width="25"> echo '</td>';
'; } else {
if($a_essais['essais']>0) // we show or not the results if the teacher wants to
echo '<a href="../exercice/exercise_show.php?origin=myprogress&id='.$exe_id.'&cidReq='.$a_infosCours['code'].'&id_session='.$_GET['id_session'].'"> '.Display::return_icon('quiz.gif', get_lang('Quiz')).' </a>'; echo '<td align="center">';
echo " </td> echo get_lang('CantShowResults');
</tr> echo '</td>';
"; echo '<td align="center">';
echo ' -- ';
echo '</td>
<td align="center" width="25">';
echo ' -- ';
echo '</td>';
}
echo '</tr>';
} }
} } else {
else{
echo '<tr><td colspan="4">'.get_lang('NoEx').'</td></tr>'; echo '<tr><td colspan="4">'.get_lang('NoEx').'</td></tr>';
} }
} }

@ -1,4 +1,4 @@
<?php // $Id: exercice.php 18366 2009-02-09 16:43:18Z iflorespaz $ <?php // $Id: exercice.php 18522 2009-02-16 20:20:29Z juliomontoya $
/* /*
============================================================================== ==============================================================================
@ -586,21 +586,16 @@ echo '<div class="actions">';
{ {
echo '<a href="exercise_admin.php?'.api_get_cidreq().'">'.Display::return_icon('new_test.gif',get_lang('NewEx')).get_lang('NewEx').'</a>'; echo '<a href="exercise_admin.php?'.api_get_cidreq().'">'.Display::return_icon('new_test.gif',get_lang('NewEx')).get_lang('NewEx').'</a>';
echo '<a href="hotpotatoes.php">'.Display::return_icon('jqz.gif',get_lang('ImportHotPotatoesQuiz')).get_lang('ImportHotPotatoesQuiz').'</a>'; echo '<a href="hotpotatoes.php">'.Display::return_icon('jqz.gif',get_lang('ImportHotPotatoesQuiz')).get_lang('ImportHotPotatoesQuiz').'</a>';
echo '<a href="'.api_add_url_param($_SERVER['REQUEST_URI'],'show=result').'">'.Display::return_icon('show_test_results.gif',get_lang('Results')).get_lang("Results").'</a>'; echo '<a href="'.api_add_url_param($_SERVER['REQUEST_URI'],'show=result').'">'.Display::return_icon('show_test_results.gif',get_lang('Results')).get_lang('Results').'</a>';
// the actions for the statistics // the actions for the statistics
if($show == 'result') if($show == 'result') {
{
// the form // the form
if(api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) if(api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
{ if($_SESSION['export_user_fields']==false) {
if($_SESSION['export_user_fields']==false)
{
$alt = get_lang('ExportWithUserFields'); $alt = get_lang('ExportWithUserFields');
$extra_user_fields = '<input type="hidden" name="export_user_fields" value="export_user_fields">'; $extra_user_fields = '<input type="hidden" name="export_user_fields" value="export_user_fields">';
} } else {
else
{
$alt = get_lang('ExportWithoutUserFields'); $alt = get_lang('ExportWithoutUserFields');
$extra_user_fields = '<input type="hidden" name="export_user_fields" value="do_not_export_user_fields">'; $extra_user_fields = '<input type="hidden" name="export_user_fields" value="do_not_export_user_fields">';
} }
@ -619,8 +614,13 @@ echo '<div class="actions">';
echo '<form id="form1c" name="form1c" method="post" action="'.api_get_self().'?show='.Security::remove_XSS($_GET['show']).'">'; echo '<form id="form1c" name="form1c" method="post" action="'.api_get_self().'?show='.Security::remove_XSS($_GET['show']).'">';
echo $extra_user_fields; echo $extra_user_fields;
echo '</form>'; echo '</form>';
}
} }
} else {
//the student view
echo '<a href="'.api_add_url_param($_SERVER['REQUEST_URI'],'show=result').'">'.Display::return_icon('show_test_results.gif',get_lang('Results')).get_lang('Results').'</a>';
if($show == 'result') {
echo '<a href="'.api_add_url_param($_SERVER['REQUEST_URI'],'show=test').'">'.Display::return_icon('quiz.gif',get_lang('BackToExercisesList')).get_lang('BackToExercisesList').'</a>';
} }
} }
@ -711,94 +711,95 @@ if ($show == 'test') {
<table class="data_table"> <table class="data_table">
<?php <?php
if (($is_allowedToEdit) and ($origin != 'learnpath')) { if (($is_allowedToEdit) and ($origin != 'learnpath')) {
?> ?>
<tr class="row_odd"> <tr class="row_odd">
<th colspan="3"><?php echo get_lang('ExerciseName');?></th> <th colspan="3"><?php echo get_lang('ExerciseName');?></th>
<th><?php echo get_lang('QuantityQuestions');?></th> <th><?php echo get_lang('QuantityQuestions');?></th>
<th><?php echo get_lang('Export');?></th> <th><?php echo get_lang('Export');?></th>
<th><?php echo get_lang('Modify');?></th> <th><?php echo get_lang('Modify');?></th>
</tr> </tr>
<?php <?php
} else { } else {
?> <tr> ?> <tr>
<th colspan="3"><?php echo get_lang('ExerciseName');?></th> <th colspan="3"><?php echo get_lang('ExerciseName');?></th>
<th><?php echo get_lang('QuantityQuestions');?></th> <th><?php echo get_lang('QuantityQuestions');?></th>
<th><?php echo get_lang('State');?></th> <th><?php echo get_lang('State');?></th>
</tr> </tr>
<?php <?php
} }
// show message if no HP test to show // show message if no HP test to show
if (!($nbrExercises+$nbrHpTests) ) { if (!($nbrExercises+$nbrHpTests) ) {
?> ?>
<tr> <tr>
<td <?php echo ($is_allowedToEdit?'colspan="6"':'colspan="5"'); ?>><?php echo get_lang("NoEx"); ?></td> <td <?php echo ($is_allowedToEdit?'colspan="6"':'colspan="5"'); ?>><?php echo get_lang("NoEx"); ?></td>
</tr> </tr>
<?php <?php
} }
$i=1; $i=1;
// while list exercises // while list exercises
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
//avoid sending empty parameters //avoid sending empty parameters
$myorigin = (empty($origin)?'':'&origin='.$origin); $myorigin = (empty($origin)?'':'&origin='.$origin);
$mylpid = (empty($learnpath_id)?'':'&learnpath_id='.$learnpath_id); $mylpid = (empty($learnpath_id)?'':'&learnpath_id='.$learnpath_id);
$mylpitemid = (empty($learnpath_item_id)?'':'&learnpath_item_id='.$learnpath_item_id); $mylpitemid = (empty($learnpath_item_id)?'':'&learnpath_item_id='.$learnpath_item_id);
while($row=Database::fetch_array($result)) { while($row=Database::fetch_array($result)) {
if($i%2==0) if($i%2==0)
$s_class="row_odd"; $s_class="row_odd";
else else
$s_class="row_even"; $s_class="row_even";
// prof only // prof only
if ($is_allowedToEdit) { if ($is_allowedToEdit) {
echo '<tr class="'.$s_class.'">'."\n"; echo '<tr class="'.$s_class.'">'."\n";
?>
<td width="30" align="left"><?php Display::display_icon('quiz.gif', get_lang('Exercice'))?></td>
<td width="15" valign="left"><?php echo ($i+($page*$limitExPage)).'.'; ?></td>
<?php $row['title']=api_parse_tex($row['title']); ?>
<td><a href="exercice_submit.php?<?php echo api_get_cidreq().$myorigin.$mylpid.$mylpitemid; ?>&amp;exerciseId=<?php echo $row['id']; ?>" <?php if(!$row['active']) echo 'class="invisible"'; ?>><?php echo $row['title']; ?></a></td>
<td> <?php
$exid = $row['id'];
$sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '".Database::escape_string($exid)."'";
$sqlresult =api_sql_query($sqlquery);
$rowi = Database::result($sqlresult,0);
echo $rowi.' '.strtolower(get_lang(($rowi>1?'Questions':'Question'))).'</td>';
echo '<td><a href="exercice.php?choice=exportqti2&exerciseId='.$row['id'].'"><img src="../img/export.png" border="0" title="IMS/QTI" /></a></td>';
?>
<td>
<a href="admin.php?exerciseId=<?php echo $row['id']; ?>"><img src="../img/wizard_small.gif" border="0" title="<?php echo htmlentities(get_lang('Build'),ENT_QUOTES,$charset); ?>" alt="<?php echo htmlentities(get_lang('Build'),ENT_QUOTES,$charset); ?>" /></a>
<?php
if($row['results_disabled']) {
echo '<a href="exercice.php?choice=enable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('EnableResults').'" alt="'.get_lang('EnableResults').'"><img src="../img/lp_quiz_na.gif" border="0" alt="'.htmlentities(get_lang('EnableResults'),ENT_QUOTES,$charset).'" /></a>';
} else {
echo '<a href="exercice.php?choice=disable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('DisableResults').'" alt="'.get_lang('DisableResults').'"><img src="../img/lp_quiz.gif" border="0" alt="'.htmlentities(get_lang('DisableResults'),ENT_QUOTES,$charset).'" /></a>';
}
?>
<a href="exercise_admin.php?modifyExercise=yes&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/edit.gif" border="0" title="<?php echo htmlentities(get_lang('Modify'),ENT_QUOTES,$charset); ?>" alt="<?php echo htmlentities(get_lang('Modify'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?choice=delete&exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('AreYouSureToDelete'),ENT_QUOTES,$charset)); echo " ".$row['title']; echo "?"; ?>')) return false;"> <img src="../img/delete.gif" border="0" alt="<?php echo htmlentities(get_lang('Delete'),ENT_QUOTES,$charset); ?>" /></a>
<?php
//if active
if ($row['active']) {
?> ?>
<a href="exercice.php?choice=disable&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/visible.gif" border="0" alt="<?php echo htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset); ?>" /></a> <td width="30" align="left"><?php Display::display_icon('quiz.gif', get_lang('Exercice'))?></td>
<?php <td width="15" valign="left"><?php echo ($i+($page*$limitExPage)).'.'; ?></td>
} else { <?php $row['title']=api_parse_tex($row['title']); ?>
// else if not active <td><a href="exercice_submit.php?<?php echo api_get_cidreq().$myorigin.$mylpid.$mylpitemid; ?>&amp;exerciseId=<?php echo $row['id']; ?>" <?php if(!$row['active']) echo 'class="invisible"'; ?>><?php echo $row['title']; ?></a></td>
<td> <?php
$exid = $row['id'];
$sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '".Database::escape_string($exid)."'";
$sqlresult =api_sql_query($sqlquery);
$rowi = Database::result($sqlresult,0);
echo $rowi.' '.strtolower(get_lang(($rowi>1?'Questions':'Question'))).'</td>';
echo '<td><a href="exercice.php?choice=exportqti2&exerciseId='.$row['id'].'"><img src="../img/export.png" border="0" title="IMS/QTI" /></a></td>';
?>
<td>
<a href="admin.php?exerciseId=<?php echo $row['id']; ?>"><img src="../img/wizard_small.gif" border="0" title="<?php echo htmlentities(get_lang('Build'),ENT_QUOTES,$charset); ?>" alt="<?php echo htmlentities(get_lang('Build'),ENT_QUOTES,$charset); ?>" /></a>
<?php
if($row['results_disabled']) {
echo '<a href="exercice.php?choice=enable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('EnableResults').'" alt="'.get_lang('EnableResults').'"><img src="../img/lp_quiz_na.gif" border="0" alt="'.htmlentities(get_lang('EnableResults'),ENT_QUOTES,$charset).'" /></a>';
} else {
echo '<a href="exercice.php?choice=disable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('DisableResults').'" alt="'.get_lang('DisableResults').'"><img src="../img/lp_quiz.gif" border="0" alt="'.htmlentities(get_lang('DisableResults'),ENT_QUOTES,$charset).'" /></a>';
}
?> ?>
<a href="exercice.php?choice=enable&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/invisible.gif" border="0" alt="<?php echo htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a> <a href="exercise_admin.php?modifyExercise=yes&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/edit.gif" border="0" title="<?php echo htmlentities(get_lang('Modify'),ENT_QUOTES,$charset); ?>" alt="<?php echo htmlentities(get_lang('Modify'),ENT_QUOTES,$charset); ?>" /></a>
<?php <a href="exercice.php?choice=delete&exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('AreYouSureToDelete'),ENT_QUOTES,$charset)); echo " ".$row['title']; echo "?"; ?>')) return false;"> <img src="../img/delete.gif" border="0" alt="<?php echo htmlentities(get_lang('Delete'),ENT_QUOTES,$charset); ?>" /></a>
} <?php
echo "</td>"; //if active
echo "</tr>\n"; if ($row['active']) {
} else {// student only
?> ?>
<tr> <a href="exercice.php?choice=disable&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/visible.gif" border="0" alt="<?php echo htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset); ?>" /></a>
<td><?php echo ($i+($page*$limitExPage)).'.'; ?></td> <?php
<td>&nbsp;</td> } else {
<?php $row['title']=api_parse_tex($row['title']);?> // else if not active
<td><a href="exercice_submit.php?<?php echo api_get_cidreq().$myorigin.$mylpid.$myllpitemid; ?>&exerciseId=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a></td> ?>
<td align="center"> <?php <a href="exercice.php?choice=enable&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/invisible.gif" border="0" alt="<?php echo htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a>
<?php
}
echo "</td>";
echo "</tr>\n";
} else {// student only
?>
<tr>
<td><?php echo ($i+($page*$limitExPage)).'.'; ?></td>
<td>&nbsp;</td>
<?php $row['title']=api_parse_tex($row['title']);?>
<td><a href="exercice_submit.php?<?php echo api_get_cidreq().$myorigin.$mylpid.$myllpitemid; ?>&exerciseId=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a></td>
<td align="center"> <?php
$exid = $row['id']; $exid = $row['id'];
$sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '".Database::escape_string($exid)."'"; $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '".Database::escape_string($exid)."'";
$sqlresult =api_sql_query($sqlquery); $sqlresult =api_sql_query($sqlquery);
@ -808,21 +809,30 @@ echo $rowi.' '.strtolower(get_lang(($rowi>1?'Questions':'Question'))); ?> </td>
$eid = $row['id']; $eid = $row['id'];
$uid= api_get_user_id(); $uid= api_get_user_id();
//this query might be improved later on by ordering by the new "tms" field rather than by exe_id //this query might be improved later on by ordering by the new "tms" field rather than by exe_id
$qry = "SELECT * FROM $TBL_TRACK_EXERCICES " . $qry = "SELECT * FROM $TBL_TRACK_EXERCICES
"WHERE exe_exo_id = '".Database::escape_string($eid)."' and exe_user_id = '".Database::escape_string($uid)."' AND exe_cours_id = '".api_get_course_id()."' AND status <>'incomplete' AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND session_id = '".api_get_session_id()."' ORDER BY exe_id DESC"; WHERE exe_exo_id = '".Database::escape_string($eid)."' and exe_user_id = '".Database::escape_string($uid)."' AND exe_cours_id = '".api_get_course_id()."' AND status <>'incomplete' AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND session_id = '".api_get_session_id()."'
ORDER BY exe_id DESC";
$qryres = api_sql_query($qry); $qryres = api_sql_query($qry);
$num = Database::num_rows($qryres); $num = Database::num_rows($qryres);
if ($num>0) {
$row = Database::fetch_array($qryres); //hide the results
$percentage = 0; $my_result_disabled = $row['results_disabled'];
if($row['exe_weighting'] != 0) { if ($my_result_disabled==0) {
$percentage = ($row['exe_result']/$row['exe_weighting'])*100; if ($num>0) {
} $row = Database::fetch_array($qryres);
echo get_lang('Attempted').' ('.get_lang('Score').':'; $percentage = 0;
printf("%1.2f\n",$percentage); if($row['exe_weighting'] != 0) {
echo " %)"; $percentage = ($row['exe_result']/$row['exe_weighting'])*100;
} else { }
echo get_lang('NotAttempted'); echo get_lang('Attempted').' ('.get_lang('Score').': ';
printf("%1.2f\n",$percentage);
echo " %)";
} else {
echo get_lang('NotAttempted');
}
}
else {
echo get_lang('CantShowResults');
} }
?></td> ?></td>
</tr> </tr>
@ -951,7 +961,7 @@ $i++;
/*****************************************/ /*****************************************/
// if tracking is enabled // if tracking is enabled
if ($_configuration['tracking_enabled'] AND ($show == 'result') ) if ($_configuration['tracking_enabled'] && ($show == 'result') )
{ {
?> ?>
<table class="data_table"> <table class="data_table">
@ -972,7 +982,6 @@ if ($_configuration['tracking_enabled'] AND ($show == 'result') )
if($is_allowedToEdit || $is_tutor) { if($is_allowedToEdit || $is_tutor) {
$user_id_and=''; $user_id_and='';
if (!empty($_POST['filter_by_user'])) { if (!empty($_POST['filter_by_user'])) {
if ($_POST['filter_by_user'] =='all') { if ($_POST['filter_by_user'] =='all') {
$user_id_and = " AND user_id like '%'"; $user_id_and = " AND user_id like '%'";
@ -997,29 +1006,30 @@ if ($_configuration['tracking_enabled'] AND ($show == 'result') )
WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '".Database::escape_string($_cid)." $user_id_and ' WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '".Database::escape_string($_cid)." $user_id_and '
ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC"; ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC";
} else { } else {
// get only this user's results // get only this user's results
$user_id_and = ' AND te.exe_user_id = ' . Database::escape_string ( api_get_user_id() ).' '; $user_id_and = ' AND te.exe_user_id = ' . Database::escape_string ( api_get_user_id() ).' ';
$sql="SELECT CONCAT(lastname,' ',firstname) as users, ce.title, te.exe_result , $sql="SELECT CONCAT(lastname,' ',firstname) as users, ce.title, te.exe_result ,
te.exe_weighting, UNIX_TIMESTAMP(te.exe_date), te.exe_id, email, UNIX_TIMESTAMP(te.start_date), steps_counter,cuser.user_id,te.exe_duration te.exe_weighting, UNIX_TIMESTAMP(te.exe_date), te.exe_id, email, UNIX_TIMESTAMP(te.start_date), steps_counter,cuser.user_id,te.exe_duration, ce.results_disabled
FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te, $TBL_USER AS user,$tbl_course_rel_user AS cuser FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te, $TBL_USER AS user,$tbl_course_rel_user AS cuser
WHERE user.user_id=cuser.user_id AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id AND te.exe_cours_id='".Database::escape_string($_cid)."' WHERE user.user_id=cuser.user_id AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id AND te.exe_cours_id='".Database::escape_string($_cid)."'
AND cuser.status<>1 $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND cuser.status<>1 $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0
AND cuser.course_code=te.exe_cours_id ORDER BY users, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC"; AND cuser.course_code=te.exe_cours_id ORDER BY users, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";
$hpsql="SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date) $hpsql="SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date)
FROM $TBL_TRACK_HOTPOTATOES FROM $TBL_TRACK_HOTPOTATOES
WHERE exe_user_id = '".$_user['user_id']."' AND exe_cours_id = '".Database::escape_string($_cid)."' WHERE exe_user_id = '".$_user['user_id']."' AND exe_cours_id = '".Database::escape_string($_cid)."'
ORDER BY exe_cours_id ASC, exe_date DESC"; ORDER BY exe_cours_id ASC, exe_date DESC";
} }
$results=getManyResultsXCol($sql,11); $results=getManyResultsXCol($sql,12);
$hpresults=getManyResultsXCol($hpsql,5); $hpresults=getManyResultsXCol($hpsql,5);
$NoTestRes = 0; $NoTestRes = 0;
$NoHPTestRes = 0; $NoHPTestRes = 0;
//Print the results of tests //Print the results of tests
$lang_nostartdate = get_lang('NoStartDate').' / '; $lang_nostartdate = get_lang('NoStartDate').' / ';
if (is_array($results)) { if (is_array($results)) {
$users_array_id = array(); $users_array_id = array();
if ($_GET['gradebook']=='view') { if ($_GET['gradebook']=='view') {
@ -1060,46 +1070,81 @@ if ($_configuration['tracking_enabled'] AND ($show == 'result') )
$res = $results[$i][2]; $res = $results[$i][2];
$duration = intval($results[$i][10]); $duration = intval($results[$i][10]);
echo '<tr'; // we filter the results if we have the permission to
if ($i%2==0) { if (isset($results[$i][11]))
echo 'class="row_odd"'; $result_disabled = intval($results[$i][11]);
} else { else
echo 'class="row_even"'; $result_disabled = 0;
}
echo '>'; if ($result_disabled==0) {
$add_start_date = $lang_nostartdate; echo '<tr';
if ($i%2==0) {
if ($is_allowedToEdit || $is_tutor) { echo 'class="row_odd"';
$user = $results[$i][0]; } else {
echo '<td>'.$user.' </td>'; echo 'class="row_even"';
}
echo '<td>'.$test.'</td>';
echo '<td>';
if ($results[$i][7] > 1) {
echo ceil((($results[$i][4] - $results[$i][7])/60)).' '.get_lang('MinMinutes');
if($results[$i][8] > 1) {
echo ' ( '.$results[$i][8].' '.get_lang('Steps').' )';
} }
$add_start_date = format_locale_date('%b %d, %Y %H:%M',$results[$i][7]).' / '; echo '>';
} else { $add_start_date = $lang_nostartdate;
echo get_lang('NoLogOfDuration');
if ($is_allowedToEdit || $is_tutor) {
$user = $results[$i][0];
echo '<td>'.$user.' </td>';
}
echo '<td>'.$test.'</td>';
echo '<td>';
if ($results[$i][7] > 1) {
echo ceil((($results[$i][4] - $results[$i][7])/60)).' '.get_lang('MinMinutes');
if($results[$i][8] > 1) {
echo ' ( '.$results[$i][8].' '.get_lang('Steps').' )';
}
$add_start_date = format_locale_date('%b %d, %Y %H:%M',$results[$i][7]).' / ';
} else {
echo get_lang('NoLogOfDuration');
}
echo '</td>';
echo '<td>'.$add_start_date.format_locale_date('%b %d, %Y %H:%M',$results[$i][4]).'</td>';//get_lang('dateTimeFormatLong')
// there are already a duration test period calculated??
//echo '<td>'.sprintf(get_lang('DurationFormat'), $duration).'</td>';
echo '<td>'.round(($res/($results[$i][3]!=0?$results[$i][3]:1))*100,2).'% ('.$res.' / '.$results[$i][3].')</td>';
// Is hard to read this!!
echo '<td>'.(($is_allowedToEdit||$is_tutor)?
"<a href='exercise_show.php?user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>".
(($revised)?get_lang('Edit'):get_lang('Qualify'))."</a>".
((api_is_platform_admin() || $is_tutor)?' - <a href="exercice.php?cidReq='.htmlentities($_GET['cidReq']).'&show=result&filter='.$filter.'&delete=delete&did='.$id.'" onclick="javascript:if(!confirm(\''.sprintf(get_lang('DeleteAttempt'),$user,$dt).'\')) return false;">'.get_lang('Delete').'</a>':'')
.(($is_allowedToEdit)?' - <a href="exercice_history.php?cidReq='.htmlentities($_GET['cidReq']).'&exe_id='.$id.'">'.get_lang('ViewHistoryChange').'</a>':'')
:(($revised)?"<a href='exercise_show.php?dt=$dt&res=$res&id=$id'>".get_lang('Show')."</a>":'')).'</td>';
/*
echo '<td>';
if ($is_allowedToEdit||$is_tutor) {
echo "<a href='exercise_show.php?user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>";
if ($revised)
echo get_lang('Edit');
else
echo get_lang('Qualify');
echo "</a>";
if (api_is_platform_admin() || $is_tutor)
echo ' - <a href="exercice.php?cidReq='.htmlentities($_GET['cidReq']).'&show=result&filter='.$filter.'&delete=delete&did='.$id.'" onclick="javascript:if(!confirm(\''.sprintf(get_lang('DeleteAttempt'),$user,$dt).'\')) return false;">'.get_lang('Delete').'</a>';
if ($is_allowedToEdit)
echo ' - <a href="exercice_history.php?cidReq='.htmlentities($_GET['cidReq']).'&exe_id='.$id.'">'.get_lang('ViewHistoryChange').'</a>';
} else {
if ($revised)
echo "<a href='exercise_show.php?dt=$dt&res=$res&id=$id'>".get_lang('Show')."</a> ";
else
echo '&nbsp;'.get_lang('NoResultsYet');
}
echo '</td>';
*/
echo '</tr>';
} }
echo '</td>';
echo '<td>'.$add_start_date.format_locale_date('%b %d, %Y %H:%M',$results[$i][4]).'</td>';//get_lang('dateTimeFormatLong')
// there are already a duration test period calculated??
//echo '<td>'.sprintf(get_lang('DurationFormat'), $duration).'</td>';
echo '<td>'.round(($res/($results[$i][3]!=0?$results[$i][3]:1))*100,2).'% ('.$res.' / '.$results[$i][3].')</td>';
echo '<td>'.(($is_allowedToEdit||$is_tutor)?
"<a href='exercise_show.php?user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>".
(($revised)?get_lang('Edit'):get_lang('Qualify'))."</a>".
((api_is_platform_admin() || $is_tutor)?' - <a href="exercice.php?cidReq='.htmlentities($_GET['cidReq']).'&show=result&filter='.$filter.'&delete=delete&did='.$id.'" onclick="javascript:if(!confirm(\''.sprintf(get_lang('DeleteAttempt'),$user,$dt).'\')) return false;">'.get_lang('Delete').'</a>':'')
.(($is_allowedToEdit)?' - <a href="exercice_history.php?cidReq='.htmlentities($_GET['cidReq']).'&exe_id='.$id.'">'.get_lang('ViewHistoryChange').'</a>':'')
:(($revised)?"<a href='exercise_show.php?dt=$dt&res=$res&id=$id'>".get_lang('Show')."</a>":'')).'</td>';
echo '</tr>';
} }
} else { } else {
$NoTestRes = 1; $NoTestRes = 1;

@ -1,4 +1,4 @@
<?php // $Id: exercice_submit.php 18387 2009-02-09 22:05:17Z juliomontoya $ <?php // $Id: exercice_submit.php 18522 2009-02-16 20:20:29Z juliomontoya $
/* /*
============================================================================== ==============================================================================
@ -42,7 +42,7 @@
* @package dokeos.exercise * @package dokeos.exercise
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @author Julio Montoya multiple fill in blank option added * @author Julio Montoya multiple fill in blank option added
* @version $Id: exercice_submit.php 18387 2009-02-09 22:05:17Z juliomontoya $ * @version $Id: exercice_submit.php 18522 2009-02-16 20:20:29Z juliomontoya $
*/ */
@ -254,11 +254,8 @@ if ($formSent) {
$counter++; $counter++;
// gets the student choice for this question // gets the student choice for this question
$choice=$exerciseResult[$questionId]; $choice=$exerciseResult[$questionId];
//print_r($choice); echo "<br>"; // creates a temporary Question object
// creates a temporary Question object
$objQuestionTmp = Question :: read($questionId); $objQuestionTmp = Question :: read($questionId);
$questionName=$objQuestionTmp->selectTitle(); $questionName=$objQuestionTmp->selectTitle();
@ -525,10 +522,13 @@ if ($formSent) {
} }
$val=addslashes($val); $val=addslashes($val);
$val=strip_tags($val); $val=strip_tags($val);
$sql = "select position from $table_ans where question_id='".Database::escape_string($questionId)."' and answer='".Database::escape_string($val)."' AND correct=0"; $sql = "SELECT position from $table_ans where question_id='".Database::escape_string($questionId)."' and answer='".Database::escape_string($val)."' AND correct=0";
$res = api_sql_query($sql, __FILE__, __LINE__); $res = api_sql_query($sql, __FILE__, __LINE__);
$answer = mysql_result($res,0,"position"); if (Database::num_rows($res)>0) {
$answer = Database::result($res,0,"position");
} else {
$answer = '';
}
exercise_attempt($questionScore,$answer,$quesId,$exeId,$j); exercise_attempt($questionScore,$answer,$quesId,$exeId,$j);
} }
@ -561,11 +561,8 @@ if ($formSent) {
$counter++; $counter++;
// gets the student choice for this question // gets the student choice for this question
$choice=$exerciseResult[$questionId]; $choice=$exerciseResult[$questionId];
//print_r($choice); echo "<br>"; // creates a temporary Question object
// creates a temporary Question object
$objQuestionTmp = Question :: read($questionId); $objQuestionTmp = Question :: read($questionId);
$questionName=$objQuestionTmp->selectTitle(); $questionName=$objQuestionTmp->selectTitle();
@ -835,8 +832,11 @@ if ($formSent) {
$val=strip_tags($val); $val=strip_tags($val);
$sql = "select position from $table_ans where question_id='".Database::escape_string($questionId)."' and answer='".Database::escape_string($val)."' AND correct=0"; $sql = "select position from $table_ans where question_id='".Database::escape_string($questionId)."' and answer='".Database::escape_string($val)."' AND correct=0";
$res = api_sql_query($sql, __FILE__, __LINE__); $res = api_sql_query($sql, __FILE__, __LINE__);
$answer = mysql_result($res,0,"position"); if (Database::num_rows($res)>0) {
$answer = Database::result($res,0,"position");
} else {
$answer = '';
}
exercise_attempt($questionScore,$answer,$quesId,$exeId,$j); exercise_attempt($questionScore,$answer,$quesId,$exeId,$j);
} }
@ -901,11 +901,13 @@ if ($formSent) {
} }
// if the object is not in the session // if the object is not in the session
if (!isset($_SESSION['objExercise']) || $origin == 'learnpath' || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
//why destroying the exercise when a LP is loaded ?
//if (!isset($_SESSION['objExercise']) || $origin == 'learnpath' || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
if (!isset($_SESSION['objExercise']) || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
if ($debug>0) { if ($debug>0) {
echo str_repeat('&nbsp;',0).'$_SESSION[objExercise] was unset'."<br />\n"; echo str_repeat('&nbsp;',0).'$_SESSION[objExercise] was unset'."<br />\n";
} }
// construction of Exercise // construction of Exercise
$objExercise=new Exercise(); $objExercise=new Exercise();
unset($_SESSION['questionList']); unset($_SESSION['questionList']);
@ -942,34 +944,29 @@ $exerciseSound=$objExercise->selectSound();
$randomQuestions=$objExercise->isRandom(); $randomQuestions=$objExercise->isRandom();
$exerciseType=$objExercise->selectType(); $exerciseType=$objExercise->selectType();
if(!isset($_SESSION['questionList']) || $origin == 'learnpath') //if (!isset($_SESSION['questionList']) || $origin == 'learnpath') {
{ //in LP's is enabled the "remember question" feature?
if($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset'."<br />\n";} if (!isset($_SESSION['questionList'])) {
if ($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset'."<br />\n";}
// selects the list of question ID // selects the list of question ID
$questionList = ($randomQuestions?$objExercise->selectRandomList():$objExercise->selectQuestionList()); $questionList = ($randomQuestions?$objExercise->selectRandomList():$objExercise->selectQuestionList());
// saves the question list into the session // saves the question list into the session
api_session_register('questionList'); api_session_register('questionList');
if($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset - set now - end'."<br />\n";} if ($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset - set now - end'."<br />\n";}
} }
if(!isset($objExcercise) && isset($_SESSION['objExercise'])){ if(!isset($objExcercise) && isset($_SESSION['objExercise'])) {
$questionList = $_SESSION['questionList']; $questionList = $_SESSION['questionList'];
} }
$quizStartTime = time(); $quizStartTime = time();
api_session_register('quizStartTime'); api_session_register('quizStartTime');
$nbrQuestions=sizeof($questionList); $nbrQuestions=sizeof($questionList);
// if questionNum comes from POST and not from GET // if questionNum comes from POST and not from GET
if(!$questionNum || $_POST['questionNum']) if(!$questionNum || $_POST['questionNum']) {
{
// only used for sequential exercises (see $exerciseType) // only used for sequential exercises (see $exerciseType)
if(!$questionNum) if(!$questionNum) {
{
$questionNum=1; $questionNum=1;
} } else {
else
{
$questionNum++; $questionNum++;
} }
} }
@ -1132,7 +1129,7 @@ else
<?php <?php
} }
$exerciseTitle=api_parse_tex($exerciseTitle); $exerciseTitle=api_parse_tex($exerciseTitle);
echo "<h3>".$exerciseTitle."</h3>"; echo "<h3>".$exerciseTitle."</h3>";
@ -1151,23 +1148,24 @@ if( $exerciseAttempts > 0){
if ( $attempt[0] >= $exerciseAttempts ) { if ( $attempt[0] >= $exerciseAttempts ) {
if (!api_is_allowed_to_edit()) { if (!api_is_allowed_to_edit()) {
Display::display_warning_message(sprintf(get_lang('ReachedMaxAttempts'),$exerciseTitle,$exerciseAttempts)); Display::display_warning_message(sprintf(get_lang('ReachedMaxAttempts'),$exerciseTitle,$exerciseAttempts),false);
if ($origin != 'learnpath')
Display::display_footer(); Display::display_footer();
exit; exit;
} else { } else {
Display::display_warning_message(sprintf(get_lang('ReachedMaxAttemptsAdmin'),$exerciseTitle,$exerciseAttempts)); Display::display_warning_message(sprintf(get_lang('ReachedMaxAttemptsAdmin'),$exerciseTitle,$exerciseAttempts),false);
} }
} }
} }
if (!function_exists('convert_date_to_number')) { if (!function_exists('convert_date_to_number')) {
function convert_date_to_number($default){ function convert_date_to_number($default){
// 2008-10-12 00:00:00 ---to--> 12345672218 (timestamp) // 2008-10-12 00:00:00 ---to--> 12345672218 (timestamp)
$parts = split(' ',$default); $parts = split(' ',$default);
list($d_year,$d_month,$d_day) = split('-',$parts[0]); list($d_year,$d_month,$d_day) = split('-',$parts[0]);
list($d_hour,$d_minute,$d_second) = split(':',$parts[1]); list($d_hour,$d_minute,$d_second) = split(':',$parts[1]);
return mktime($d_hour, $d_minute, $d_second, $d_month, $d_day, $d_year); return mktime($d_hour, $d_minute, $d_second, $d_month, $d_day, $d_year);
} }
} }
$limit_time_exists = (($Exe_starttime!='0000-00-00 00:00:00')||($Exe_endtime!='0000-00-00 00:00:00'))? true : false; $limit_time_exists = (($Exe_starttime!='0000-00-00 00:00:00')||($Exe_endtime!='0000-00-00 00:00:00'))? true : false;
@ -1245,6 +1243,7 @@ else
if($exerciseType==2){ if($exerciseType==2){
$s2 = "&exerciseId=".$exerciseId; $s2 = "&exerciseId=".$exerciseId;
} }
$s.=" <form method='post' action='".api_get_self()."?autocomplete=off".$s2."' name='frm_exercise' $onsubmit> $s.=" <form method='post' action='".api_get_self()."?autocomplete=off".$s2."' name='frm_exercise' $onsubmit>
<input type='hidden' name='formSent' value='1' /> <input type='hidden' name='formSent' value='1' />
<input type='hidden' name='exerciseType' value='".$exerciseType."' /> <input type='hidden' name='exerciseType' value='".$exerciseType."' />
@ -1254,57 +1253,52 @@ else
<input type='hidden' name='origin' value='".$origin."' /> <input type='hidden' name='origin' value='".$origin."' />
<input type='hidden' name='learnpath_id' value='".$learnpath_id."' /> <input type='hidden' name='learnpath_id' value='".$learnpath_id."' />
<input type='hidden' name='learnpath_item_id' value='".$learnpath_item_id."' /> <input type='hidden' name='learnpath_item_id' value='".$learnpath_item_id."' />
<table width='100%' border='0' cellpadding='1' cellspacing='0'> <table width='100%' border='0' cellpadding='1' cellspacing='0'>
<tr> <tr>
<td> <td>
<table width='100%' cellpadding='3' cellspacing='0' border='0'>"; <table width='100%' cellpadding='3' cellspacing='0' border='0'>";
echo $s; echo $s;
$i=0; $i=1;
foreach($questionList as $questionId) { foreach($questionList as $questionId) {
$i++; // for sequential exercises
// for sequential exercises if($exerciseType == 2) {
if($exerciseType == 2) { // if it is not the right question, goes to the next loop iteration
// if it is not the right question, goes to the next loop iteration if ($questionNum != $i ) {
if($questionNum != $i){ $i++;
continue; continue;
} else { } else {
if ($exerciseFeedbackType!=1) { if ($exerciseFeedbackType != 1) {
// if the user has already answered this question // if the user has already answered this question
if(isset($exerciseResult[$questionId])) { if (isset($exerciseResult[$questionId])) {
// construction of the Question object // construction of the Question object
$objQuestionTmp = Question::read($questionId); $objQuestionTmp = Question::read($questionId);
$questionName=$objQuestionTmp->selectTitle(); $questionName=$objQuestionTmp->selectTitle();
// destruction of the Question object // destruction of the Question object
unset($objQuestionTmp); unset($objQuestionTmp);
echo '<tr><td>'.get_lang('AlreadyAnswered').' &quot;'.$questionName.'&quot;</td></tr>'; Display::display_normal_message(get_lang('AlreadyAnswered'));
break; $i++;
//echo '<tr><td>'.get_lang('AlreadyAnswered').' &quot;'.$questionName.'&quot;</td></tr>';
break;
}
}
}
} }
// shows the question and its answers
showQuestion($questionId, false, $origin,$i,$nbrQuestions);
$i++;
// for sequential exercises
if($exerciseType == 2) {
// quits the loop
break;
}
} }
} // end foreach()
}
/*
$s="<tr>
<td width='3%' bgcolor='#e6e6e6'><img src=\"".api_get_path(WEB_IMG_PATH)."test.gif\" align=\"absmiddle\"></td>
<td valign='middle' bgcolor='#e6e6e6'>
".get_lang('Question')." ";
*/
// shows the question and its answers
showQuestion($questionId, false, $origin,$i,$nbrQuestions);
// for sequential exercises
if($exerciseType == 2) {
// quits the loop
break;
}
}
// end foreach()
echo " echo "
<!-- <button type='submit' name='buttonCancel' class='cancel'>".get_lang('Cancel')."</button> <!-- <button type='submit' name='buttonCancel' class='cancel'>".get_lang('Cancel')."</button>
&nbsp;&nbsp; //--><br />"; &nbsp;&nbsp; //--><br />";
$submit_btn="<button class=\"save\" type='submit' name='submit'>"; $submit_btn="<button class=\"save\" type='submit' name='submit'>";
// $submit_btn.=get_lang('ValidateAnswer'); // $submit_btn.=get_lang('ValidateAnswer');
if ($objExercise->selectFeedbackType()==1 && $_SESSION['objExercise']->selectType()==2) { if ($objExercise->selectFeedbackType()==1 && $_SESSION['objExercise']->selectType()==2) {
$submit_btn=''; $submit_btn='';
echo '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript"></script>'; echo '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript"></script>';
echo '<style type="text/css" media="all">@import "'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css";</style>'; echo '<style type="text/css" media="all">@import "'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css";</style>';
@ -1315,7 +1309,12 @@ else
$('.rounded_inner').corners(); $('.rounded_inner').corners();
});</script>"; });</script>";
//echo '<br /><span class="rounded" style="width: 300px; margin-top: 10px; padding: 3px; background-color:#ccc;"><span style="width: 300px" class="rounded_inner" ><a href="exercise_submit_modal.php?hotspot='.$hotspot_get.'&nbrQuestions='.$nbrQuestions.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&exerciseId='.$exerciseId.'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=480&width=640&modal=true" title="" class="thickbox" id="validationButton">'.get_lang('ValidateAnswer').'</a></span></span><br /><br /><br />'; //echo '<br /><span class="rounded" style="width: 300px; margin-top: 10px; padding: 3px; background-color:#ccc;"><span style="width: 300px" class="rounded_inner" ><a href="exercise_submit_modal.php?hotspot='.$hotspot_get.'&nbrQuestions='.$nbrQuestions.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&exerciseId='.$exerciseId.'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=480&width=640&modal=true" title="" class="thickbox" id="validationButton">'.get_lang('ValidateAnswer').'</a></span></span><br /><br /><br />';
echo '<br /><div class="rounded" style="text-align: center;"><div class="rounded_inner"><a href="exercise_submit_modal.php?hotspot='.$hotspot_get.'&nbrQuestions='.$nbrQuestions.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&exerciseId='.$exerciseId.'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=480&width=640&modal=true" title="" class="thickbox" id="validationButton">'.get_lang('ValidateAnswer').'</a></div></div><br /><br /><br />'; echo '<br />
<div class="rounded" style="text-align: center;">
<div class="rounded_inner">
<a href="exercise_submit_modal.php?hotspot='.$hotspot_get.'&nbrQuestions='.$nbrQuestions.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&exerciseId='.$exerciseId.'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=480&width=640&modal=true" title="" class="thickbox" id="validationButton">'.get_lang('ValidateAnswer').'</a>
</div>
</div><br /><br /><br />';
} else { } else {
if ($exerciseType == 1 || $nbrQuestions == $questionNum) if ($exerciseType == 1 || $nbrQuestions == $questionNum)
{ {
@ -1326,9 +1325,13 @@ else
$submit_btn.=get_lang('Next').' &gt;'; $submit_btn.=get_lang('Next').' &gt;';
} }
$submit_btn.= "</button>"; $submit_btn.= "</button>";
} }
echo $submit_btn; echo $submit_btn;
echo "</form>"; echo "</table>
</td>
</tr>
</table></form>";
$b=2; $b=2;
} }
@ -1345,6 +1348,7 @@ else
} }
} }
if ($origin != 'learnpath') { //so we are not in learnpath tool if ($origin != 'learnpath') {
//so we are not in learnpath tool
Display::display_footer(); Display::display_footer();
} }

@ -25,7 +25,7 @@
* Exercise class: This class allows to instantiate an object of type Exercise * Exercise class: This class allows to instantiate an object of type Exercise
* @package dokeos.exercise * @package dokeos.exercise
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @version $Id: exercise.class.php 18487 2009-02-13 04:02:46Z ivantcholakov $ * @version $Id: exercise.class.php 18522 2009-02-16 20:20:29Z juliomontoya $
*/ */
@ -287,11 +287,10 @@ class Exercise
*/ */
function selectRandomList() function selectRandomList()
{ {
$nbQuestions = $this->selectNbrQuestions(); $nbQuestions = $this->selectNbrQuestions();
$temp_list = $this->questionList; $temp_list = $this->questionList;
shuffle($temp_list); shuffle($temp_list);
return array_combine(range(1,$nbQuestions),$temp_list); return array_combine(range(1,$nbQuestions),$temp_list);
$nbQuestions = $this->selectNbrQuestions(); $nbQuestions = $this->selectNbrQuestions();
//Not a random exercise, or if there are not at least 2 questions //Not a random exercise, or if there are not at least 2 questions
@ -329,7 +328,10 @@ class Exercise
*/ */
function isInList($questionId) function isInList($questionId)
{ {
return in_array($questionId,$this->questionList); if (is_array($this->questionList))
return in_array($questionId,$this->questionList);
else
return false;
} }
/** /**
@ -747,7 +749,8 @@ class Exercise
} }
else else
{ {
$pos=max(array_keys($this->questionList))+1; if (is_array($this->questionList))
$pos=max(array_keys($this->questionList))+1;
} }
$this->questionList[$pos]=$questionId; $this->questionList[$pos]=$questionId;

@ -1,4 +1,4 @@
<?php // $Id: exercise.lib.php 18478 2009-02-12 21:27:18Z herodoto $ <?php // $Id: exercise.lib.php 18522 2009-02-16 20:20:29Z juliomontoya $
/* /*
============================================================================== ==============================================================================
@ -29,7 +29,7 @@
* shows a question and its answers * shows a question and its answers
* @package dokeos.exercise * @package dokeos.exercise
* @author Olivier Brouckaert <oli.brouckaert@skynet.be> * @author Olivier Brouckaert <oli.brouckaert@skynet.be>
* @version $Id: exercise.lib.php 18478 2009-02-12 21:27:18Z herodoto $ * @version $Id: exercise.lib.php 18522 2009-02-16 20:20:29Z juliomontoya $
*/ */
/** /**
@ -66,12 +66,12 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
$s="<div id=\"question_title\" class=\"sectiontitle\"> $s="<div id=\"question_title\" class=\"sectiontitle\">
".get_lang('Question').' '; ".get_lang('Question').' ';
$s.=$current_item; $s.=$current_item;
//@todo I need the get the feedback type
if($answerType == 2) //if($answerType != 1)
$s.=' / '.$total_item; //$s.=' / '.$total_item;
echo $s; echo $s;
echo ': '; echo ' : ';
$s =$questionName.'</div>'; $s =$questionName.'</div>';
$s.="<table class='exercise_questions'> $s.="<table class='exercise_questions'>
@ -92,7 +92,7 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
</tr>"; </tr>";
} }
} // end if(!$onlyAnswers) }
$s.= '</table>'; $s.= '</table>';
$s.="<script>$(document).ready( function(){ $s.="<script>$(document).ready( function(){
$('.rounded').corners(); $('.rounded').corners();
@ -296,9 +296,9 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
".get_lang('Question').' '; ".get_lang('Question').' ';
$s.=$current_item; $s.=$current_item;
//@todo I need to the get the feedback type
if($answerType == 2) //if($answerType == 2)
$s.=' / '.$total_item; // $s.=' / '.$total_item;
echo $s; echo $s;
echo ': '; echo ': ';

@ -29,7 +29,7 @@
* @author Olivier Brouckaert, main author * @author Olivier Brouckaert, main author
* @author Roan Embrechts, some refactoring * @author Roan Embrechts, some refactoring
* @author Julio Montoya Armas switchable fill in blank option added * @author Julio Montoya Armas switchable fill in blank option added
* @version $Id: exercise_result.php 18203 2009-02-03 18:02:16Z ndieschburg $ * @version $Id: exercise_result.php 18522 2009-02-16 20:20:29Z juliomontoya $
* *
* @todo split more code up in functions, move functions to library? * @todo split more code up in functions, move functions to library?
*/ */
@ -472,11 +472,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
$counter++; $counter++;
// gets the student choice for this question // gets the student choice for this question
$choice=$exerciseResult[$questionId]; $choice=$exerciseResult[$questionId];
//print_r($choice); echo "<br>";
// creates a temporary Question object // creates a temporary Question object
$objQuestionTmp = Question :: read($questionId); $objQuestionTmp = Question :: read($questionId);
$questionName=$objQuestionTmp->selectTitle(); $questionName=$objQuestionTmp->selectTitle();
@ -997,29 +993,25 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
$ans = $reply[$i]; $ans = $reply[$i];
exercise_attempt($questionScore,$ans,$quesId,$exeId,$i); exercise_attempt($questionScore,$ans,$quesId,$exeId,$i);
} }
} } else {
else
{
exercise_attempt($questionScore, 0 ,$quesId,$exeId,0); exercise_attempt($questionScore, 0 ,$quesId,$exeId,0);
} }
} } elseif ($answerType==MATCHING) {
elseif ($answerType==MATCHING)
{
$j=sizeof($matching)+1; $j=sizeof($matching)+1;
for ($i=0;$i<sizeof($choice);$i++,$j++) {
for ($i=0;$i<sizeof($choice);$i++,$j++)
{
$val = $choice[$j]; $val = $choice[$j];
if (preg_match_all ('#<font color="red"><s>([0-9a-z ]*)</s></font>#', $val, $arr1)) if (preg_match_all ('#<font color="red"><s>([0-9a-z ]*)</s></font>#', $val, $arr1))
$val = $arr1[1][0]; $val = $arr1[1][0];
$val=addslashes($val); $val=addslashes($val);
$val=strip_tags($val); $val=strip_tags($val);
$sql = "select position from $table_ans where question_id='".Database::escape_string($questionId)."' and answer='".Database::escape_string($val)."' AND correct=0"; $sql = "SELECT position from $table_ans where question_id='".Database::escape_string($questionId)."' and answer='".Database::escape_string($val)."' AND correct=0";
$res = api_sql_query($sql, __FILE__, __LINE__); $res = api_sql_query($sql, __FILE__, __LINE__);
$answer = Database::result($res,0,"position"); if (Database::num_rows($res)>0) {
$answer = Database::result($res,0,"position");
} else {
$answer = '';
}
exercise_attempt($questionScore,$answer,$quesId,$exeId,$j); exercise_attempt($questionScore,$answer,$quesId,$exeId,$j);
} }
} }
elseif ($answerType==FREE_ANSWER) { elseif ($answerType==FREE_ANSWER) {
@ -1087,7 +1079,11 @@ if($_configuration['tracking_enabled']) {
if($objExercise->results_disabled) { if($objExercise->results_disabled) {
ob_end_clean(); ob_end_clean();
Display :: display_normal_message(get_lang('ExerciseFinished').'<br /><a href="exercice.php" />'.get_lang('Back').'</a>',false); if ($origin != 'learnpath') {
Display :: display_normal_message(get_lang('ExerciseFinished').'<br /><a href="exercice.php" />'.get_lang('Back').'</a>',false);
} else {
Display :: display_normal_message(get_lang('ExerciseFinished').'<br /><br />',false);
}
} }
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
@ -1183,4 +1179,4 @@ if(count($arrques)>0) {
} }
api_mail_html($student_name, $to, $subject, $mail_content, $from_name, $from, array('encoding'=>$mycharset,'charset'=>$mycharset)); api_mail_html($student_name, $to, $subject, $mail_content, $from_name, $from, array('encoding'=>$mycharset,'charset'=>$mycharset));
} }
?> ?>

@ -198,7 +198,7 @@ function get_comments($id,$question_id)
//$sql = "select teacher_comment from ".$TBL_TRACK_ATTEMPT." where exe_id='".Database::escape_string($id and question_id)."' = '".Database::escape_string($question_id)."' order by question_id"; //$sql = "select teacher_comment from ".$TBL_TRACK_ATTEMPT." where exe_id='".Database::escape_string($id and question_id)."' = '".Database::escape_string($question_id)."' order by question_id";
$sql = "select teacher_comment from ".$TBL_TRACK_ATTEMPT." where exe_id='".Database::escape_string($id)."' and question_id = '".Database::escape_string($question_id)."' order by question_id"; $sql = "select teacher_comment from ".$TBL_TRACK_ATTEMPT." where exe_id='".Database::escape_string($id)."' and question_id = '".Database::escape_string($question_id)."' order by question_id";
$sqlres = api_sql_query($sql, __FILE__, __LINE__); $sqlres = api_sql_query($sql, __FILE__, __LINE__);
$comm = mysql_result($sqlres,0,"teacher_comment"); $comm = Database::result($sqlres,0,"teacher_comment");
return $comm; return $comm;
} }
/** /**
@ -343,25 +343,41 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
<tr> <tr>
<td colspan="2"> <td colspan="2">
<?php <?php
$sql_test_name='SELECT title, description FROM '.$TBL_EXERCICES.' as exercises, '.$TBL_TRACK_EXERCICES.' as track_exercises WHERE exercises.id=track_exercises.exe_exo_id AND track_exercises.exe_id="'.Database::escape_string($id).'"'; $sql_test_name='SELECT title, description, results_disabled FROM '.$TBL_EXERCICES.' as exercises, '.$TBL_TRACK_EXERCICES.' as track_exercises WHERE exercises.id=track_exercises.exe_exo_id AND track_exercises.exe_id="'.Database::escape_string($id).'"';
$result=api_sql_query($sql_test_name); $result=api_sql_query($sql_test_name);
$test=Database::result($result,0,0); $show_results = true;
$exerciseTitle=api_parse_tex($test); // Avoiding the "Score 0/0" message when the exe_id is not set
$exerciseDexcription=Database::result($result,0,1); if (Database::num_rows($result)>0 && isset($id)) {
$test=Database::result($result,0,0);
$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($_user['user_id'])." "; $exerciseTitle=api_parse_tex($test);
$query = "select attempts.question_id, answer from ".$TBL_TRACK_ATTEMPT." as attempts $exerciseDexcription=Database::result($result,0,1);
INNER JOIN ".$TBL_TRACK_EXERCICES." as stats_exercices ON stats_exercices.exe_id=attempts.exe_id
INNER JOIN ".$TBL_EXERCICE_QUESTION." as quizz_rel_questions ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id AND quizz_rel_questions.question_id = attempts.question_id
INNER JOIN ".$TBL_QUESTIONS." as questions ON questions.id=quizz_rel_questions.question_id
WHERE attempts.exe_id='".Database::escape_string($id)."' $user_restriction
GROUP BY quizz_rel_questions.question_order, attempts.question_id";
//GROUP BY questions.position, attempts.question_id";
$result =api_sql_query($query, __FILE__, __LINE__); // 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();
}
}
$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($_user['user_id'])." ";
$query = "SELECT attempts.question_id, answer from ".$TBL_TRACK_ATTEMPT." as attempts
INNER JOIN ".$TBL_TRACK_EXERCICES." as stats_exercices ON stats_exercices.exe_id=attempts.exe_id
INNER JOIN ".$TBL_EXERCICE_QUESTION." as quizz_rel_questions ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id AND quizz_rel_questions.question_id = attempts.question_id
INNER JOIN ".$TBL_QUESTIONS." as questions ON questions.id=quizz_rel_questions.question_id
WHERE attempts.exe_id='".Database::escape_string($id)."' $user_restriction
GROUP BY quizz_rel_questions.question_order, attempts.question_id";
//GROUP BY questions.position, attempts.question_id";
$result =api_sql_query($query, __FILE__, __LINE__);
} else {
Display::display_warning_message(get_lang('CantViewResults'));
$show_results = false;
echo '</td>
</tr>
</table>';
}
$show_results = true;
?>
<table> <table>
<tr> <tr>
<td style="font-weight:bold"><?php echo get_lang('CourseTitle')?> : </td> <td style="font-weight:bold"><?php echo get_lang('CourseTitle')?> : </td>
@ -384,54 +400,51 @@ $result =api_sql_query($query, __FILE__, __LINE__);
<br /> <br />
<?php <?php
$i=$totalScore=$totalWeighting=0; $i=$totalScore=$totalWeighting=0;
if($debug>0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);} if($debug>0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);}
// for each question // for each question
$questionList = array(); $questionList = array();
$exerciseResult = array(); $exerciseResult = array();
$k=0; $k=0;
$counter=0; $counter=0;
while ($row = mysql_fetch_array($result)) while ($row = Database::fetch_array($result)) {
{
$questionList[] = $row['question_id']; $questionList[] = $row['question_id'];
$exerciseResult[] = $row['answer']; $exerciseResult[] = $row['answer'];
} }
//echo '<pre>';print_R($questionList); //echo '<pre>';print_R($questionList);
foreach($questionList as $questionId) if ($show_results)
foreach($questionList as $questionId) {
$counter++;
$k++;
$choice=$exerciseResult[$questionId];
// creates a temporary Question object
$objQuestionTmp = Question::read($questionId);
$questionName=$objQuestionTmp->selectTitle();
$questionDescription=$objQuestionTmp->selectDescription();
$questionWeighting=$objQuestionTmp->selectWeighting();
$answerType=$objQuestionTmp->selectType();
$quesId =$objQuestionTmp->selectId(); //added by priya saini
// destruction of the Question object
unset($objQuestionTmp);
if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
{ {
$counter++; $colspan=2;
$k++; }
$choice=$exerciseResult[$questionId]; if($answerType == MATCHING || $answerType == FREE_ANSWER)
// creates a temporary Question object {
$objQuestionTmp = Question::read($questionId); $colspan=2;
$questionName=$objQuestionTmp->selectTitle(); }
$questionDescription=$objQuestionTmp->selectDescription(); else
$questionWeighting=$objQuestionTmp->selectWeighting(); {
$answerType=$objQuestionTmp->selectType(); $colspan=2;
$quesId =$objQuestionTmp->selectId(); //added by priya saini }?>
// destruction of the Question object
unset($objQuestionTmp);
if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
{
$colspan=2;
}
if($answerType == MATCHING || $answerType == FREE_ANSWER)
{
$colspan=2;
}
else
{
$colspan=2;
}?>
<tr bgcolor="#E6E6E6"> <tr>
<td colspan="2" > <?php echo get_lang("Question").' '.($counter).' : '.$questionName; ?> </td> <td colspan="2" height="24px"><div id="question_title" class="sectiontitle"><?php echo get_lang("Question").' '.($counter).' : '.$questionName; ?> </div></td>
</tr> </tr>
<tr> <tr>
<td colspan="2"><?php echo $questionDescription; ?> </td> <td colspan="2"><?php echo $questionDescription; ?> </td>
@ -460,25 +473,22 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$objAnswerTmp=new Answer($questionId); $objAnswerTmp=new Answer($questionId);
$nbrAnswers=$objAnswerTmp->selectNbrAnswers(); $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
$questionScore=0; $questionScore=0;
for($answerId=1;$answerId <= $nbrAnswers;$answerId++) for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
{ $answer=$objAnswerTmp->selectAnswer($answerId);
$answer=$objAnswerTmp->selectAnswer($answerId); $answerComment=$objAnswerTmp->selectComment($answerId);
$answerComment=$objAnswerTmp->selectComment($answerId); $answerCorrect=$objAnswerTmp->isCorrect($answerId);
$answerCorrect=$objAnswerTmp->isCorrect($answerId); $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
$answerWeighting=$objAnswerTmp->selectWeighting($answerId); $queryans = "select * from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$queryans = "select * 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__);
$resultans = api_sql_query($queryans, __FILE__, __LINE__); while ($row = Database::fetch_array($resultans)) {
while ($row = mysql_fetch_array($resultans)) $ind = $row['answer'];
{ $choice[$ind] = 1;
$ind = $row['answer']; }
$choice[$ind] = 1; $studentChoice=$choice[$answerId];
} if($studentChoice) {
$studentChoice=$choice[$answerId]; $questionScore+=$answerWeighting;
if($studentChoice) $totalScore+=$answerWeighting;
{ }
$questionScore+=$answerWeighting;
$totalScore+=$answerWeighting;
}
?> ?>
<tr> <tr>
@ -495,7 +505,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
}?> }?>
</table> </table>
<?php } <?php }
else if ($answerType == UNIQUE_ANSWER) elseif ($answerType == UNIQUE_ANSWER)
{?> {?>
<table width="355" border="0"> <table width="355" border="0">
<tr> <tr>
@ -521,7 +531,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$answerWeighting=$objAnswerTmp->selectWeighting($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)."'"; $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__); $resultans = api_sql_query($queryans, __FILE__, __LINE__);
$choice = mysql_result($resultans,0,"answer"); $choice = Database::result($resultans,0,"answer");
$studentChoice=($choice == $answerId)?1:0; $studentChoice=($choice == $answerId)?1:0;
if($studentChoice) if($studentChoice)
{ {
@ -629,7 +639,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$queryfill = "select answer from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'"; $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__); $resfill = api_sql_query($queryfill, __FILE__, __LINE__);
$str=mysql_result($resfill,0,"answer"); $str=Database::result($resfill,0,"answer");
preg_match_all ('#\[([^[/]*)/#', $str, $arr); preg_match_all ('#\[([^[/]*)/#', $str, $arr);
$choice = $arr[1]; $choice = $arr[1];
@ -678,7 +688,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'"; $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__); $resfill = api_sql_query($queryfill, __FILE__, __LINE__);
$str=mysql_result($resfill,0,"answer"); $str=Database::result($resfill,0,"answer");
preg_match_all ('#\[([^[/]*)/#', $str, $arr); preg_match_all ('#\[([^[/]*)/#', $str, $arr);
$choice = $arr[1]; $choice = $arr[1];
@ -733,8 +743,8 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$questionScore=0; $questionScore=0;
$query = "select answer, marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'"; $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); $resq=api_sql_query($query);
$choice = mysql_result($resq,0,"answer"); $choice = Database::result($resq,0,"answer");
$questionScore = mysql_result($resq,0,"marks"); $questionScore = Database::result($resq,0,"marks");
if($questionScore==-1){ if($questionScore==-1){
$totalScore+=0; $totalScore+=0;
} }
@ -759,7 +769,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$res_answer = api_sql_query($sql_answer, __FILE__, __LINE__); $res_answer = api_sql_query($sql_answer, __FILE__, __LINE__);
// getting the real answer // getting the real answer
$real_list =array(); $real_list =array();
while($real_answer = mysql_fetch_array($res_answer)) while($real_answer = Database::fetch_array($res_answer))
{ {
$real_list[$real_answer['position']]= $real_answer['answer']; $real_list[$real_answer['position']]= $real_answer['answer'];
} }
@ -776,7 +786,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$questionScore=0; $questionScore=0;
while($a_answers = mysql_fetch_array($res_answers)) while($a_answers = Database::fetch_array($res_answers))
{ {
$i_answer_id = $a_answers['id']; //3 $i_answer_id = $a_answers['id']; //3
$s_answer_label = $a_answers['answer']; // your dady - you mother $s_answer_label = $a_answers['answer']; // your dady - you mother
@ -798,7 +808,10 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$res_user_answer = api_sql_query($sql_user_answer, __FILE__, __LINE__); $res_user_answer = api_sql_query($sql_user_answer, __FILE__, __LINE__);
$s_user_answer = mysql_result($res_user_answer,0,0); // rich - good looking 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 = $s_answer_label; // your ddady - your mother
$s_correct_answer = $real_list[$i_answer_correct_answer]; $s_correct_answer = $real_list[$i_answer_correct_answer];
@ -856,14 +869,14 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); $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)."'"; $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); $resq=api_sql_query($query);
$choice = mysql_result($resq,0,"hotspot_correct"); $choice = Database::result($resq,0,"hotspot_correct");
display_hotspot_answer($answerId,$answer,$choice,$answerComment); display_hotspot_answer($answerId,$answer,$choice,$answerComment);
$i++; $i++;
} }
$queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'"; $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__); $resfree = api_sql_query($queryfree, __FILE__, __LINE__);
$questionScore= mysql_result($resfree,0,"marks"); $questionScore= Database::result($resfree,0,"marks");
$totalScore+=$questionScore; $totalScore+=$questionScore;
?> ?>
</table> </table>
@ -972,18 +985,17 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$arrmarks[] = $questionId; $arrmarks[] = $questionId;
echo '<div id="'.$marksname.'" style="visibility:hidden"><form name="marksform_'.$questionId.'" method="post" action=""><select name="marks" id="marks" style="display:none;"><option>'.$questionScore.'</option></select></form></div>'; echo '<div id="'.$marksname.'" style="visibility:hidden"><form name="marksform_'.$questionId.'" method="post" action=""><select name="marks" id="marks" style="display:none;"><option>'.$questionScore.'</option></select></form></div>';
} }
} } else {
else{ if($questionScore==-1) {
if($questionScore==-1){
$questionScore=0; $questionScore=0;
} }
}?> }?>
</td><tr><td align="left"><b><?php echo get_lang('Score')." : $questionScore/$questionWeighting"; ?></b><br /><br /></td> </td><tr><td align="left"><b><?php echo get_lang('Score')." : $questionScore/$questionWeighting"; ?></b><br /><br /></td>
</tr> </tr>
<?php unset($objAnswerTmp); <?php unset($objAnswerTmp);
$i++; $i++;
$totalWeighting+=$questionWeighting; $totalWeighting+=$questionWeighting;
} }
?> ?>
<tr><td align="left"><b><?php <tr><td align="left"><b><?php
@ -1042,13 +1054,19 @@ $totalWeighting+=$questionWeighting;
</tr> </tr>
</table> </table>
<?php <?php
if ($origin != 'learnpath') if ($origin != 'learnpath') {
{
//we are not in learnpath tool //we are not in learnpath tool
Display::display_footer(); Display::display_footer();
}else{ } else {
//record the results in the learning path, using the SCORM interface (API) //record the results in the learning path, using the SCORM interface (API)
echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n"; echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
echo '</body></html>'; echo '</body></html>';
} }
?> //destroying the session
api_session_unregister('questionList');
unset ($questionList);
api_session_unregister('exerciseResult');
unset ($exerciseResult);
?>

@ -1,4 +1,4 @@
<?php // $Id: question_list_admin.inc.php 18411 2009-02-10 17:59:08Z juliomontoya $ <?php // $Id: question_list_admin.inc.php 18522 2009-02-16 20:20:29Z juliomontoya $
/* /*
============================================================================== ==============================================================================
@ -28,7 +28,7 @@
* Code library for HotPotatoes integration. * Code library for HotPotatoes integration.
* @package dokeos.exercise * @package dokeos.exercise
* @author * @author
* @version $Id: question_list_admin.inc.php 18411 2009-02-10 17:59:08Z juliomontoya $ * @version $Id: question_list_admin.inc.php 18522 2009-02-16 20:20:29Z juliomontoya $
*/ */
@ -86,10 +86,9 @@ if($deleteQuestion)
echo '<div class="actionsbig">'; echo '<div class="actionsbig">';
//we filter the type of questions we can add //we filter the type of questions we can add
Question :: display_type_menu ($objExercise->feedbacktype); Question :: display_type_menu ($objExercise->feedbacktype);
echo '</div></div>'; echo '</div>';
?> ?>
<table class="data_table"> <table class="data_table">
<tr class="row_odd"> <tr class="row_odd">
<th><?php echo get_lang('Question'); ?></th> <th><?php echo get_lang('Question'); ?></th>
@ -155,4 +154,5 @@ if(!$i) {
<?php <?php
} }
?> ?>
</table> </table>
</div>

@ -141,11 +141,12 @@ class UniqueAnswer extends Question {
require_once('../newscorm/learnpathList.class.php'); require_once('../newscorm/learnpathList.class.php');
require_once(api_get_path(LIBRARY_PATH).'text.lib.php'); require_once(api_get_path(LIBRARY_PATH).'text.lib.php');
if (is_array($question_list)) {
foreach ($question_list as $key=>$questionid) { foreach ($question_list as $key=>$questionid) {
$question = Question::read($questionid); $question = Question::read($questionid);
$select_question[$questionid]='Q'.$key.' :'.cut($question->selectTitle(),20); $select_question[$questionid]='Q'.$key.' :'.cut($question->selectTitle(),20);
} }
}
$select_question[-1]=get_lang('ExitTest'); $select_question[-1]=get_lang('ExitTest');
//LP SELECT //LP SELECT

Loading…
Cancel
Save