|
@@ -333,10 +333,7 @@ if (!empty($_GET['gradebook']) && $_GET['gradebook']=='view' ) {
|
|
|
}
|
|
|
|
|
|
if (!empty($gradebook) && $gradebook=='view') {
|
|
|
- $interbreadcrumb[] = array (
|
|
|
- 'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
|
|
|
- 'name' => get_lang('ToolGradebook')
|
|
|
- );
|
|
|
+ $interbreadcrumb[] = array ('url' => '../gradebook/' . $_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook'));
|
|
|
}
|
|
|
|
|
|
if ($show != 'result') {
|
|
@@ -344,16 +341,10 @@ if ($show != 'result') {
|
|
|
} else {
|
|
|
if ($is_allowedToEdit || $is_tutor) {
|
|
|
$nameTools = get_lang('StudentScore');
|
|
|
- $interbreadcrumb[] = array (
|
|
|
- "url" => "exercice.php?gradebook=$gradebook",
|
|
|
- "name" => get_lang('Exercices')
|
|
|
- );
|
|
|
+ $interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
|
|
|
} else {
|
|
|
$nameTools = get_lang('YourScore');
|
|
|
- $interbreadcrumb[] = array (
|
|
|
- "url" => "exercice.php?gradebook=$gradebook",
|
|
|
- "name" => get_lang('Exercices')
|
|
|
- );
|
|
|
+ $interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -406,8 +397,7 @@ if (!empty ($_POST['export_report']) && $_POST['export_report'] == 'export_repor
|
|
|
require_once ('exercise_result.class.php');
|
|
|
switch ($_POST['export_format']) {
|
|
|
case 'xls' :
|
|
|
- $export = new ExerciseResult();
|
|
|
-
|
|
|
+ $export = new ExerciseResult();
|
|
|
$export->exportCompleteReportXLS($documentPath, $user_id, $_SESSION['export_user_fields'], $_POST['export_filter']);
|
|
|
exit;
|
|
|
break;
|
|
@@ -465,7 +455,6 @@ if ($is_allowedToEdit) {
|
|
|
switch ($choice) {
|
|
|
case 'delete' : // deletes an exercise
|
|
|
$objExerciseTmp->delete();
|
|
|
-
|
|
|
//delete link of exercise of gradebook tool
|
|
|
$sql = 'SELECT gl.id FROM ' . $tbl_grade_link . ' gl WHERE gl.type="1" AND gl.ref_id="' . $exerciseId . '";';
|
|
|
$result = Database::query($sql);
|
|
@@ -512,7 +501,6 @@ if ($is_allowedToEdit) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// destruction of Exercise
|
|
|
unset ($objExerciseTmp);
|
|
|
Security::clear_token();
|
|
@@ -555,13 +543,6 @@ if ($is_allowedToEdit) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if ($show == 'test') {
|
|
|
- $sql = "SELECT id,title,type,active,description, results_disabled FROM $TBL_EXERCICES WHERE active<>'-1' ORDER BY title LIMIT " . (int) $from . "," . (int) ($limitExPage +1);
|
|
|
- $result = Database::query($sql);
|
|
|
- }
|
|
|
-} elseif ($show == 'test') { // only for students
|
|
|
- $sql = "SELECT id,title,type,description, results_disabled FROM $TBL_EXERCICES WHERE active='1' ORDER BY title LIMIT " . (int) $from . "," . (int) ($limitExPage +1);
|
|
|
- $result = Database::query($sql);
|
|
|
}
|
|
|
|
|
|
// the actions
|
|
@@ -584,7 +565,8 @@ if ($is_allowedToEdit) {
|
|
|
$sql = "SELECT id, title, type, active, description, results_disabled, session_id, start_time, end_time, random,max_attempt FROM $TBL_EXERCICES WHERE active<>'-1' $condition_session ORDER BY title LIMIT " . (int) $from . "," . (int) ($limitExPage +1);
|
|
|
$result = Database::query($sql);
|
|
|
}
|
|
|
-} elseif ($show == 'test') { // only for students
|
|
|
+} elseif ($show == 'test') {
|
|
|
+ // only for students
|
|
|
$sql = "SELECT id, title, type, description, results_disabled, session_id, start_time, end_time FROM $TBL_EXERCICES WHERE active='1' $condition_session ORDER BY title LIMIT " . (int) $from . "," . (int) ($limitExPage +1);
|
|
|
$result = Database::query($sql);
|
|
|
}
|
|
@@ -627,14 +609,14 @@ if ($show == 'test') {
|
|
|
echo '</span>';
|
|
|
}
|
|
|
|
|
|
-if (($is_allowedToEdit) and ($origin != 'learnpath')) {
|
|
|
+if ($is_allowedToEdit && $origin != 'learnpath') {
|
|
|
if ($_GET['show'] != 'result') {
|
|
|
echo '<a href="exercise_admin.php?' . api_get_cidreq() . '">' . Display :: return_icon('more.png', get_lang('NewEx')) . get_lang('NewEx') . '</a>';
|
|
|
echo '<a href="question_create.php?' . api_get_cidreq() . '">' . Display :: return_icon('question_add.gif', get_lang('AddQuestionToExercise')) . get_lang('AddQuestionToExercise') . '</a>';
|
|
|
echo '<a href="hotpotatoes.php?' . api_get_cidreq() . '">' . Display :: return_icon('hotpotatoes_s.png', get_lang('ImportHotPotatoesQuiz')) . get_lang('ImportHotPotatoesQuiz') . '</a>';
|
|
|
// link to import qti2 ...
|
|
|
echo '<a href="qti2.php?' . api_get_cidreq() . '">' . Display :: return_icon('import_db.png', get_lang('ImportQtiQuiz')) . get_lang('ImportQtiQuiz') . '</a>';
|
|
|
- echo '<a href="exercice.php?' . api_get_cidreq() . '&show=result">' . Display :: return_icon('show_test_results.gif', get_lang('Results')) . get_lang('Results') . '</a>';
|
|
|
+ //echo '<a href="exercice.php?' . api_get_cidreq() . '&show=result">' . Display :: return_icon('show_test_results.gif', get_lang('Results')) . get_lang('Results') . '</a>';
|
|
|
}
|
|
|
|
|
|
// the actions for the statistics
|
|
@@ -678,37 +660,37 @@ if (($is_allowedToEdit) and ($origin != 'learnpath')) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-if ($_configuration['tracking_enabled']) {
|
|
|
- if ($show == 'result') {
|
|
|
- if (api_is_allowed_to_edit(null,true)) {
|
|
|
- if (!$_GET['filter']) {
|
|
|
- $filter_by_not_revised = true;
|
|
|
- $filter = 1;
|
|
|
- } else {
|
|
|
- $filter=Security::remove_XSS($_GET['filter']);
|
|
|
- }
|
|
|
- $filter = (int) $_GET['filter'];
|
|
|
|
|
|
- switch ($filter) {
|
|
|
- case 1 :
|
|
|
- $filter_by_not_revised = true;
|
|
|
- break;
|
|
|
- case 2 :
|
|
|
- $filter_by_revised = true;
|
|
|
- break;
|
|
|
- default :
|
|
|
- null;
|
|
|
- }
|
|
|
- if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) {
|
|
|
- $view_result = '<a href="' . api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=2&gradebook='.$gradebook.'" >'.Display :: return_icon('check.gif', get_lang('ShowCorrectedOnly')).get_lang('ShowCorrectedOnly').'</a>';
|
|
|
- } else {
|
|
|
- $view_result = '<a href="' .api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=1&gradebook='.$gradebook.'" >'.Display :: return_icon('un_check.gif', get_lang('ShowUnCorrectedOnly')).get_lang('ShowUnCorrectedOnly').'</a>';
|
|
|
- }
|
|
|
- echo $view_result;
|
|
|
+if ($show == 'result') {
|
|
|
+ if (api_is_allowed_to_edit(null,true)) {
|
|
|
+ if (!$_GET['filter']) {
|
|
|
+ $filter_by_not_revised = true;
|
|
|
+ $filter = 1;
|
|
|
+ } else {
|
|
|
+ $filter=Security::remove_XSS($_GET['filter']);
|
|
|
+ }
|
|
|
+ $filter = (int) $_GET['filter'];
|
|
|
+
|
|
|
+ switch ($filter) {
|
|
|
+ case 1 :
|
|
|
+ $filter_by_not_revised = true;
|
|
|
+ break;
|
|
|
+ case 2 :
|
|
|
+ $filter_by_revised = true;
|
|
|
+ break;
|
|
|
+ default :
|
|
|
+ null;
|
|
|
}
|
|
|
+ if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) {
|
|
|
+ $view_result = '<a href="' . api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=2&gradebook='.$gradebook.'" >'.Display :: return_icon('check.gif', get_lang('ShowCorrectedOnly')).get_lang('ShowCorrectedOnly').'</a>';
|
|
|
+ } else {
|
|
|
+ $view_result = '<a href="' .api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=1&gradebook='.$gradebook.'" >'.Display :: return_icon('un_check.gif', get_lang('ShowUnCorrectedOnly')).get_lang('ShowUnCorrectedOnly').'</a>';
|
|
|
+ }
|
|
|
+ echo $view_result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
echo '</div>'; // closing the actions div
|
|
|
|
|
|
if ($show == 'test') {
|
|
@@ -729,33 +711,13 @@ if ($show == 'test') {
|
|
|
.ui-tabs-vertical .ui-tabs-nav li.ui-tabs-selected { padding-bottom: 0; padding-right: .1em; border-right-width: 1px; border-right-width: 1px; }
|
|
|
.ui-tabs-vertical .ui-tabs-panel { padding: 1em; float: left; width: 40em;}
|
|
|
</style>
|
|
|
- <div id="exercise_tabs" class="tabs-left">
|
|
|
- <?php
|
|
|
- if (($is_allowedToEdit) and ($origin != 'learnpath')) {
|
|
|
- /*
|
|
|
-?>
|
|
|
- <tr class="row_odd">
|
|
|
- <th colspan="3"><?php echo get_lang('ExerciseName');?></th>
|
|
|
- <th><?php echo get_lang('QuantityQuestions');?></th>
|
|
|
- <th><?php echo get_lang('Modify');?></th>
|
|
|
- </tr>
|
|
|
- <?php*/
|
|
|
- } else {
|
|
|
- //student only
|
|
|
- /*
|
|
|
-?> <tr>
|
|
|
- <th colspan="2"><?php echo get_lang('ExerciseName');?></th>
|
|
|
- <th><?php echo get_lang('QuantityQuestions');?></th>
|
|
|
- <th><?php echo get_lang('State');?></th>
|
|
|
- </tr>
|
|
|
- <?php
|
|
|
- */
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ <?php
|
|
|
$i =1;
|
|
|
$lis = '';
|
|
|
$exercise_list = array();
|
|
|
- $online_icon = Display::return_icon('online.png', get_lang('Visible'),array('width'=>'12px'));
|
|
|
+ $online_icon = Display::return_icon('online.png', get_lang('Visible'),array('width'=>'12px'));
|
|
|
$offline_icon = Display::return_icon('offline.png',get_lang('Invisible'),array('width'=>'12px'));
|
|
|
|
|
|
while ($row = Database :: fetch_array($result,'ASSOC')) {
|
|
@@ -769,625 +731,194 @@ if ($show == 'test') {
|
|
|
$lis.= Display::tag('li','<a href="#tabs-'.$i.'">'.$status.' '.$row['title'].'</a>');
|
|
|
$i++;
|
|
|
$exercise_list[] = $row;
|
|
|
- }
|
|
|
- echo Display::tag('ul', $lis);
|
|
|
-
|
|
|
- /* Listing exercises */
|
|
|
+ }
|
|
|
|
|
|
- if ($origin != 'learnpath') {
|
|
|
- //avoid sending empty parameters
|
|
|
- $myorigin = (empty ($origin) ? '' : '&origin=' . $origin);
|
|
|
- $mylpid = (empty ($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id);
|
|
|
- $mylpitemid = (empty ($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id);
|
|
|
-
|
|
|
- $token = Security::get_token();
|
|
|
- $i=1;
|
|
|
- foreach ($exercise_list as $row) {
|
|
|
- echo '<div id="tabs-'.$i.'">';
|
|
|
- $i++;
|
|
|
- //validacion when belongs to a session
|
|
|
- $session_img = api_get_session_image($row['session_id'], $_user['status']);
|
|
|
-
|
|
|
- $time_limits = false;
|
|
|
- if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') {
|
|
|
- $time_limits = true;
|
|
|
- }
|
|
|
-
|
|
|
- if ($time_limits) {
|
|
|
- // check if start time
|
|
|
- $start_time = api_strtotime($row['start_time']);
|
|
|
- $end_time = api_strtotime($row['end_time']);
|
|
|
- $now = time();
|
|
|
- $is_actived_time = false;
|
|
|
- if ($now > $start_time && $end_time > $now ) {
|
|
|
- $is_actived_time = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // prof only
|
|
|
- if ($is_allowedToEdit) {
|
|
|
-
|
|
|
- //Showing exercise title
|
|
|
- $row['title']=text_filter($row['title']);
|
|
|
- echo Display::tag('h1',$row['title']);
|
|
|
-
|
|
|
- echo '<p>';
|
|
|
- echo $session_img;
|
|
|
- $exid = $row['id'];
|
|
|
-
|
|
|
- //count number exercice - teacher
|
|
|
- $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '" . Database :: escape_string($exid) . "'";
|
|
|
- $sqlresult = Database::query($sqlquery);
|
|
|
- $rowi = Database :: result($sqlresult, 0);
|
|
|
-
|
|
|
- $random_label = '';
|
|
|
- if ($row['random'] > 0) {
|
|
|
- $random_label = ' ('.get_lang('Random').') ';
|
|
|
- echo $row['random'] . ' ' . api_strtolower(get_lang(($row['random'] > 1 ? 'Questions' : 'Question'))) .$random_label. '</td>';
|
|
|
- } else {
|
|
|
- echo $rowi . ' ' . api_strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question'))) . '</td>';
|
|
|
- }
|
|
|
-
|
|
|
- if ($session_id == $row['session_id']) {
|
|
|
- ?>
|
|
|
- <a href="admin.php?<?php echo api_get_cidreq()?>&exerciseId=<?php echo $row['id']; ?>">
|
|
|
- <img src="../img/settings.png" border="0" title="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" /></a>
|
|
|
- <a href="exercice.php?<?php echo api_get_cidreq()?>&choice=copy_exercise&sec_token=<?php echo $token; ?>&exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;">
|
|
|
- <img width="22" src="../img/cd.gif" border="0" title="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" /></a>
|
|
|
- <a href="exercice.php?<?php echo api_get_cidreq()?>&choice=clean_results&sec_token=<?php echo $token; ?>&exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;" >
|
|
|
- <img width="22" src="../img/clean_group.png" border="0" title="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" /></a>
|
|
|
- <?php
|
|
|
- //if active
|
|
|
- if ($row['active']) {
|
|
|
- echo Display::tag('a', Display::return_icon('visible.gif', get_lang('Deactivate')) , array('href'=>'exercice.php?'.api_get_cidreq().'&choice=disable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']));
|
|
|
- } else { // else if not active
|
|
|
- echo Display::tag('a', Display::return_icon('invisible.gif', get_lang('Activate')) , array('href'=>'exercice.php?'.api_get_cidreq().'&choice=enable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']));
|
|
|
- }
|
|
|
- // Export qti ...
|
|
|
- echo '<a href="exercice.php?choice=exportqti2&exerciseId='.$row['id'].'"><img src="../img/export_db.png" border="0" title="IMS/QTI" /></a>';
|
|
|
- } else { // not session resource
|
|
|
- echo Display::return_icon('wizard_gray_small.gif', get_lang('ExerciseEditionNotAvailableInSession'));
|
|
|
- ?>
|
|
|
- <a href="exercice.php?<?php echo api_get_cidreq()?>&choice=copy_exercise&sec_token=<?php echo $token; ?>&exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;"><img width="16" src="../img/cd.gif" border="0" title="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" /></a>
|
|
|
- <?php
|
|
|
- }
|
|
|
-
|
|
|
- //last option is deleted
|
|
|
- if ($session_id == $row['session_id']) { ?>
|
|
|
- <a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=delete&sec_token=<?php echo$token; ?>&exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToDelete'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;">
|
|
|
- <?php
|
|
|
- echo Display::return_icon('delete.png', get_lang('Delete'));
|
|
|
- echo '</a>';
|
|
|
- }
|
|
|
-
|
|
|
- echo '<br />'.get_count_exam_results($row['id']).' '.get_lang('Attempts');
|
|
|
+ if (!empty($exercise_list)) {
|
|
|
+
|
|
|
+ echo '<div id="exercise_tabs" class="tabs-left">';
|
|
|
+ echo Display::tag('ul', $lis);
|
|
|
+
|
|
|
+ /* Listing exercises */
|
|
|
+
|
|
|
+ if ($origin != 'learnpath') {
|
|
|
+ //avoid sending empty parameters
|
|
|
+ $myorigin = (empty ($origin) ? '' : '&origin=' . $origin);
|
|
|
+ $mylpid = (empty ($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id);
|
|
|
+ $mylpitemid = (empty ($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id);
|
|
|
+
|
|
|
+ $token = Security::get_token();
|
|
|
+ $i=1;
|
|
|
+ foreach ($exercise_list as $row) {
|
|
|
+ echo '<div id="tabs-'.$i.'">';
|
|
|
+ $i++;
|
|
|
+ //validacion when belongs to a session
|
|
|
+ $session_img = api_get_session_image($row['session_id'], $_user['status']);
|
|
|
|
|
|
- echo '<div class="operations">';
|
|
|
- echo Display::tag('a', get_lang('Preview'), array('href'=>'exercice_submit.php?'.api_get_cidreq().$myorigin.$mylpid.$mylpitemid.'&exerciseId='.$row['id']));
|
|
|
- echo ' ';
|
|
|
- echo Display::tag('a', get_lang('Results'), array('href'=>'exercice.php?'.api_get_cidreq().'&show=result&exerciseId='.$row['id']));
|
|
|
- echo '</div>';
|
|
|
- } else {
|
|
|
- // student only
|
|
|
- $row['title']=text_filter($row['title']);
|
|
|
-
|
|
|
- // if time is actived show link to exercise
|
|
|
- if ($time_limits) {
|
|
|
- if ($is_actived_time) {
|
|
|
- echo '<a href="exercice_submit.php?'.api_get_cidreq().$myorigin.$mylpid.$myllpitemid.'&exerciseId='.$row['id'].'">'.$row['title'].'</a>';
|
|
|
- } else {
|
|
|
- echo $row['title'];
|
|
|
- }
|
|
|
- } else {
|
|
|
- echo '<a href="exercice_submit.php?'.api_get_cidreq().$myorigin.$mylpid.$myllpitemid.'&exerciseId='.$row['id'].'">'.$row['title'].'</a>';
|
|
|
+ $time_limits = false;
|
|
|
+ if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') {
|
|
|
+ $time_limits = true;
|
|
|
}
|
|
|
-
|
|
|
- $exid = $row['id'];
|
|
|
- //count number exercise questions
|
|
|
- $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '" . Database :: escape_string($exid) . "'";
|
|
|
- $sqlresult = Database::query($sqlquery);
|
|
|
- $rowi = Database :: result($sqlresult, 0);
|
|
|
- //count number random exercice
|
|
|
- $sql_random_query = 'SELECT type,random,active,results_disabled,max_attempt FROM ' . $TBL_EXERCICES . ' WHERE id="' . Database :: escape_string($exid) . '" ';
|
|
|
- $rs_random = Database::query($sql_random_query);
|
|
|
- $row_random = Database :: fetch_array($rs_random);
|
|
|
- if ($row_random['random'] > 0) {
|
|
|
- echo $row_random['random'] . ' ' . api_strtolower(get_lang(($row_random['random'] > 1 ? 'Questions' : 'Question')));
|
|
|
- } else {
|
|
|
- //show results student
|
|
|
- echo $rowi . ' ' . api_strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question')));
|
|
|
- }
|
|
|
- $eid = $row['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
|
|
|
- $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";
|
|
|
- $qryres = Database::query($qry);
|
|
|
- $num = Database :: num_rows($qryres);
|
|
|
-
|
|
|
- //hide the results
|
|
|
- $my_result_disabled = $row['results_disabled'];
|
|
|
|
|
|
if ($time_limits) {
|
|
|
- if ($my_result_disabled == 0) {
|
|
|
- if ($num > 0) {
|
|
|
- echo sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_get_local_time($row['start_time']), api_get_local_time($row['end_time']));
|
|
|
+ // check if start time
|
|
|
+ $start_time = api_strtotime($row['start_time']);
|
|
|
+ $end_time = api_strtotime($row['end_time']);
|
|
|
+ $now = time();
|
|
|
+ $is_actived_time = false;
|
|
|
+ if ($now > $start_time && $end_time > $now ) {
|
|
|
+ $is_actived_time = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // prof only
|
|
|
+ if ($is_allowedToEdit) {
|
|
|
+
|
|
|
+ //Showing exercise title
|
|
|
+ $row['title']=text_filter($row['title']);
|
|
|
+ echo Display::tag('h1',$row['title']);
|
|
|
+
|
|
|
+ echo '<p>';
|
|
|
+ echo $session_img;
|
|
|
+ $exid = $row['id'];
|
|
|
+
|
|
|
+ //count number exercice - teacher
|
|
|
+ $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '" . Database :: escape_string($exid) . "'";
|
|
|
+ $sqlresult = Database::query($sqlquery);
|
|
|
+ $rowi = Database :: result($sqlresult, 0);
|
|
|
+
|
|
|
+ $random_label = '';
|
|
|
+
|
|
|
+ if ($row['random'] > 0) {
|
|
|
+ $random_label = ' ('.get_lang('Random').') ';
|
|
|
+ echo $row['random'] . ' ' . api_strtolower(get_lang(($row['random'] > 1 ? 'Questions' : 'Question'))) .$random_label;
|
|
|
+ } else {
|
|
|
+ echo $rowi . ' ' . api_strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question')));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($session_id == $row['session_id']) {
|
|
|
+ //Settings
|
|
|
+ //echo Display::tag('a', Display::return_icon('settings.png', get_lang('Edit')), array('href'=>'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']));
|
|
|
+ //Export
|
|
|
+ echo Display::tag('a', Display::return_icon('cd.gif', get_lang('CopyExercise')), array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id']));
|
|
|
+ //Clean exercise
|
|
|
+ echo Display::tag('a', Display::return_icon('clean_group.png', get_lang('CleanStudentResults')),array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=clean_results&sec_token='.$token.'&exerciseId='.$row['id']));
|
|
|
+ //Visible / invisible
|
|
|
+ if ($row['active']) {
|
|
|
+ echo Display::tag('a', Display::return_icon('visible.gif', get_lang('Deactivate')) , array('href'=>'exercice.php?'.api_get_cidreq().'&choice=disable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']));
|
|
|
+ } else { // else if not active
|
|
|
+ echo Display::tag('a', Display::return_icon('invisible.gif', get_lang('Activate')) , array('href'=>'exercice.php?'.api_get_cidreq().'&choice=enable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']));
|
|
|
+ }
|
|
|
+ // Export qti ...
|
|
|
+ echo Display::tag('a', Display::return_icon('export_db.png', 'IMS/QTI'), array('href'=>'exercice.php?choice=exportqti2&exerciseId='.$row['id']));
|
|
|
+ } else { // not session resource
|
|
|
+ echo Display::return_icon('wizard_gray_small.gif', get_lang('ExerciseEditionNotAvailableInSession'));
|
|
|
+ echo Display::tag('a', Display::return_icon('cd.gif', get_lang('CopyExercise')), array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id']));
|
|
|
+ }
|
|
|
+
|
|
|
+ //Delete
|
|
|
+ if ($session_id == $row['session_id']) {
|
|
|
+ echo Display::tag('a', Display::return_icon('delete.png', get_lang('Delete')),array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDelete'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=delete&sec_token='.$token.'&exerciseId='.$row['id']));
|
|
|
+ }
|
|
|
+ //Attempts
|
|
|
+ echo '<br />'.get_count_exam_results($row['id']).' '.get_lang('Attempts');
|
|
|
+
|
|
|
+ //Special buttons
|
|
|
+ echo '<div class="operations">';
|
|
|
+ echo Display::tag('a', Display::return_icon('settings.png',get_lang('EditQuestions'), array('width'=>'22px'))." ".get_lang('Edit'), array('href'=>'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']));
|
|
|
+ echo ' ';
|
|
|
+ echo Display::tag('a', Display::return_icon('preview.gif',get_lang('Preview'), array('width'=>'22px'))." ".get_lang('Preview'), array('href'=>'exercice_submit.php?'.api_get_cidreq().$myorigin.$mylpid.$mylpitemid.'&exerciseId='.$row['id']));
|
|
|
+ echo ' ';
|
|
|
+ echo Display::tag('a', Display::return_icon('show_test_results.gif',get_lang('Results'), array('width'=>'22px'))." ".get_lang('Results'), array('href'=>'exercice.php?'.api_get_cidreq().'&show=result&exerciseId='.$row['id']));
|
|
|
+ echo '</div>';
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // Student only
|
|
|
+ $row['title']=text_filter($row['title']);
|
|
|
+
|
|
|
+ // if time is actived show link to exercise
|
|
|
+ if ($time_limits) {
|
|
|
+ if ($is_actived_time) {
|
|
|
+ echo '<a href="exercice_submit.php?'.api_get_cidreq().$myorigin.$mylpid.$myllpitemid.'&exerciseId='.$row['id'].'">'.$row['title'].'</a>';
|
|
|
} else {
|
|
|
- echo get_lang('NotAttempted');
|
|
|
- }
|
|
|
+ echo $row['title'];
|
|
|
+ }
|
|
|
} else {
|
|
|
- echo get_lang('CantShowResults');
|
|
|
+ echo '<a href="exercice_submit.php?'.api_get_cidreq().$myorigin.$mylpid.$myllpitemid.'&exerciseId='.$row['id'].'">'.$row['title'].'</a>';
|
|
|
}
|
|
|
- } else {
|
|
|
- if ($my_result_disabled == 0) {
|
|
|
- if ($num > 0) {
|
|
|
- $row = Database :: fetch_array($qryres);
|
|
|
- $percentage = 0;
|
|
|
- if ($row['exe_weighting'] != 0) {
|
|
|
- $percentage = ($row['exe_result'] / $row['exe_weighting']) * 100;
|
|
|
- }
|
|
|
- echo get_lang('Attempted') . ' (' . get_lang('Score') . ': ';
|
|
|
- printf("%1.2f\n", $percentage);
|
|
|
- echo " %)";
|
|
|
+
|
|
|
+ $exid = $row['id'];
|
|
|
+ //count number exercise questions
|
|
|
+ $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '" . Database :: escape_string($exid) . "'";
|
|
|
+ $sqlresult = Database::query($sqlquery);
|
|
|
+ $rowi = Database :: result($sqlresult, 0);
|
|
|
+ //count number random exercice
|
|
|
+ $sql_random_query = 'SELECT type,random,active,results_disabled,max_attempt FROM ' . $TBL_EXERCICES . ' WHERE id="' . Database :: escape_string($exid) . '" ';
|
|
|
+ $rs_random = Database::query($sql_random_query);
|
|
|
+ $row_random = Database :: fetch_array($rs_random);
|
|
|
+ if ($row_random['random'] > 0) {
|
|
|
+ echo $row_random['random'] . ' ' . api_strtolower(get_lang(($row_random['random'] > 1 ? 'Questions' : 'Question')));
|
|
|
+ } else {
|
|
|
+ //show results student
|
|
|
+ echo $rowi . ' ' . api_strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question')));
|
|
|
+ }
|
|
|
+ $eid = $row['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
|
|
|
+ $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";
|
|
|
+ $qryres = Database::query($qry);
|
|
|
+ $num = Database :: num_rows($qryres);
|
|
|
+
|
|
|
+ //hide the results
|
|
|
+ $my_result_disabled = $row['results_disabled'];
|
|
|
+
|
|
|
+ if ($time_limits) {
|
|
|
+ if ($my_result_disabled == 0) {
|
|
|
+ if ($num > 0) {
|
|
|
+ echo sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_get_local_time($row['start_time']), api_get_local_time($row['end_time']));
|
|
|
+ } else {
|
|
|
+ echo get_lang('NotAttempted');
|
|
|
+ }
|
|
|
} else {
|
|
|
- //echo get_lang('WillBeActivated' .' '. $row['start_time']);
|
|
|
- echo get_lang('NotAttempted');
|
|
|
+ echo get_lang('CantShowResults');
|
|
|
}
|
|
|
} else {
|
|
|
- echo get_lang('CantShowResults');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- echo '</p>';
|
|
|
+ if ($my_result_disabled == 0) {
|
|
|
+ if ($num > 0) {
|
|
|
+ $row = Database :: fetch_array($qryres);
|
|
|
+ $percentage = 0;
|
|
|
+ if ($row['exe_weighting'] != 0) {
|
|
|
+ $percentage = ($row['exe_result'] / $row['exe_weighting']) * 100;
|
|
|
+ }
|
|
|
+ echo get_lang('Attempted') . ' (' . get_lang('Score') . ': ';
|
|
|
+ printf("%1.2f\n", $percentage);
|
|
|
+ echo " %)";
|
|
|
+ } else {
|
|
|
+ //echo get_lang('WillBeActivated' .' '. $row['start_time']);
|
|
|
+ echo get_lang('NotAttempted');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ echo get_lang('CantShowResults');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ echo '</p>';
|
|
|
+ echo '</div>';
|
|
|
+
|
|
|
+ } // end foreach()
|
|
|
echo '</div>';
|
|
|
- } // end while()
|
|
|
- echo '</div>';
|
|
|
- Display :: display_footer();
|
|
|
- exit;
|
|
|
-
|
|
|
- $ind = $i;
|
|
|
- if (($from + $limitExPage -1) > $nbrexerc) {
|
|
|
- if ($from > $nbrexerc) {
|
|
|
- $from = $from - $nbrexerc;
|
|
|
- $to = $limitExPage;
|
|
|
- } else {
|
|
|
- $to = $limitExPage - ($nbrexerc - $from);
|
|
|
- $from = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- $to = $limitExPage;
|
|
|
- }
|
|
|
-
|
|
|
- if ($is_allowedToEdit) {
|
|
|
- $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
|
|
|
- FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
|
|
|
- WHERE d.id = ip.ref AND ip.tool = '" . TOOL_DOCUMENT . "' AND (d.path LIKE '%htm%')
|
|
|
- AND d.path LIKE '" . Database :: escape_string($uploadPath) . "/%/%' LIMIT " . (int) $from . "," . (int) $to; // only .htm or .html files listed
|
|
|
+ }
|
|
|
} else {
|
|
|
- $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
|
|
|
- FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
|
|
|
- WHERE d.id = ip.ref AND ip.tool = '" . TOOL_DOCUMENT . "' AND (d.path LIKE '%htm%')
|
|
|
- AND d.path LIKE '" . Database :: escape_string($uploadPath) . "/%/%' AND ip.visibility='1' LIMIT " . (int) $from . "," . (int) $to;
|
|
|
- }
|
|
|
-
|
|
|
- $result = Database::query($sql);
|
|
|
-
|
|
|
- while ($row = Database :: fetch_array($result, 'ASSOC')) {
|
|
|
- $attribute['path'][] = $row['path'];
|
|
|
- $attribute['visibility'][] = $row['visibility'];
|
|
|
- $attribute['comment'][] = $row['comment'];
|
|
|
+ //echo Display::display_warning_message(get_lang('NoExercises'));
|
|
|
}
|
|
|
- $nbrActiveTests = 0;
|
|
|
- if (is_array($attribute['path'])) {
|
|
|
- while (list ($key, $path) = each($attribute['path'])) {
|
|
|
- list ($a, $vis) = each($attribute['visibility']);
|
|
|
- if (strcmp($vis, "1") == 0) {
|
|
|
- $active = 1;
|
|
|
- } else {
|
|
|
- $active = 0;
|
|
|
- }
|
|
|
- echo "<tr>\n";
|
|
|
-
|
|
|
- $title = GetQuizName($path, $documentPath);
|
|
|
- if ($title == '') {
|
|
|
- $title = basename($path);
|
|
|
- }
|
|
|
- // prof only
|
|
|
- if ($is_allowedToEdit) {
|
|
|
- echo ' <tr>'.
|
|
|
- ' <td><img src="../img/hotpotatoes_s.png" alt="HotPotatoes" /></td>'.
|
|
|
- ' <td>'.($ind+($page*$limitExPage)).'.</td>'.
|
|
|
- ' <td><a href="showinframes.php?file='.$path.'&cid='.$_course['official_code'].'&uid='.$_user['user_id'].'"'.(!$active?'class="invisible"':'').'>'.$title.'</a></td>'.
|
|
|
- ' <td align="center">-</td>'.
|
|
|
- ' <td align="center">' .
|
|
|
- ' <a href="adminhp.php?'.api_get_cidreq().'&hotpotatoesName='.$path.'">'.
|
|
|
- ' <img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="'.api_htmlentities(get_lang('Modify'),ENT_QUOTES,$charset).'" />' .
|
|
|
- ' </a>'.
|
|
|
- ' <a href="'.$exercicePath.'?'.api_get_cidreq().'&hpchoice=delete&file='.$path.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('AreYouSure'),ENT_QUOTES,$charset).$title."?").'\')) return false;"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="'.api_htmlentities(get_lang('Delete'),ENT_QUOTES,$charset).'" /></a>';
|
|
|
- // if active
|
|
|
- if ($active) {
|
|
|
- $nbrActiveTests = $nbrActiveTests +1;
|
|
|
- echo ' <a href="'.$exercicePath.'?'.api_get_cidreq().'&hpchoice=disable&page='.$page.'&file='.$path.'"><img src="../img/visible.gif" border="0" title="'.get_lang('Deactivate').'" alt="'.api_htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset).'" /></a>';
|
|
|
- } else { // else if not active
|
|
|
- echo ' <a href="'.$exercicePath.'?'.api_get_cidreq().'&hpchoice=enable&page='.$page.'&file='.$path.'"><img src="../img/invisible.gif" border="0" title="'.get_lang('Activate').'" alt="'.api_htmlentities(get_lang('Activate'),ENT_QUOTES,$charset).'" /></a>';
|
|
|
- }
|
|
|
- echo '<img src="../img/lp_quiz_na.gif" border="0" title="'.get_lang('NotMarkActivity').'" alt="" />';
|
|
|
- echo '</td>';
|
|
|
- } else { // student only
|
|
|
- if ($active == 1) {
|
|
|
- $nbrActiveTests = $nbrActiveTests +1;
|
|
|
- echo ' <tr>'.
|
|
|
- ' <td>'.($ind+($page*$limitExPage)).'.<!--<img src="../img/jqz.jpg" alt="HotPotatoes" />--></td>' .
|
|
|
- ' <td><a href="showinframes.php?'.api_get_cidreq().'&file='.$path.'&cid='.$_course['official_code'].'&uid='.$_user['user_id'].'"'.(!$active?'class="invisible"':'').'">'.$title.'</a></td>'.
|
|
|
- ' <td style="text-align: center;">-</td><td style="text-align: center;">-</td>'.
|
|
|
- ' </tr>';
|
|
|
- }
|
|
|
- }
|
|
|
- if ($ind == $limitExPage) {
|
|
|
- break;
|
|
|
- }
|
|
|
- if ($is_allowedToEdit) {
|
|
|
- $ind++;
|
|
|
- } else {
|
|
|
- if ($active == 1) {
|
|
|
- $ind++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } //end if ($origin != 'learnpath') {
|
|
|
-echo '</table>';
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ Display :: display_footer();
|
|
|
exit;
|
|
|
+}
|
|
|
|
|
|
- //everything as always
|
|
|
-
|
|
|
-?>
|
|
|
-<table class="data_table">
|
|
|
- <?php
|
|
|
- if (($is_allowedToEdit) and ($origin != 'learnpath')) {
|
|
|
-?>
|
|
|
- <tr class="row_odd">
|
|
|
- <th colspan="3"><?php echo get_lang('ExerciseName');?></th>
|
|
|
- <th><?php echo get_lang('QuantityQuestions');?></th>
|
|
|
- <th><?php echo get_lang('Modify');?></th>
|
|
|
- </tr>
|
|
|
- <?php
|
|
|
- } else {
|
|
|
- //student only
|
|
|
-?> <tr>
|
|
|
- <th colspan="2"><?php echo get_lang('ExerciseName');?></th>
|
|
|
- <th><?php echo get_lang('QuantityQuestions');?></th>
|
|
|
- <th><?php echo get_lang('State');?></th>
|
|
|
- </tr>
|
|
|
- <?php
|
|
|
- }
|
|
|
- // show message if no HP test to show
|
|
|
- if (!($nbrExercises + $nbrHpTests)) {
|
|
|
-?>
|
|
|
- <tr>
|
|
|
- <td <?php echo ($is_allowedToEdit?'colspan="6"':'colspan="5"'); ?>><?php echo get_lang("NoEx"); ?></td>
|
|
|
- </tr>
|
|
|
- <?php
|
|
|
- }
|
|
|
- $i = 1;
|
|
|
-
|
|
|
- /*
|
|
|
- * Listing exercises
|
|
|
- */
|
|
|
- if ($origin != 'learnpath') {
|
|
|
- //avoid sending empty parameters
|
|
|
- $myorigin = (empty ($origin) ? '' : '&origin=' . $origin);
|
|
|
- $mylpid = (empty ($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id);
|
|
|
- $mylpitemid = (empty ($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id);
|
|
|
-
|
|
|
- $token = Security::get_token();
|
|
|
- while ($row = Database :: fetch_array($result,'ASSOC')) {
|
|
|
- //validacion when belongs to a session
|
|
|
- $session_img = api_get_session_image($row['session_id'], $_user['status']);
|
|
|
-
|
|
|
- $time_limits = false;
|
|
|
- if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') {
|
|
|
- $time_limits = true;
|
|
|
- }
|
|
|
-
|
|
|
- if ($time_limits) {
|
|
|
- // check if start time
|
|
|
- $start_time = api_strtotime($row['start_time']);
|
|
|
- $end_time = api_strtotime($row['end_time']);
|
|
|
- $now = time();
|
|
|
- $is_actived_time = false;
|
|
|
- if ($now > $start_time && $end_time > $now ) {
|
|
|
- $is_actived_time = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if ($i % 2 == 0)
|
|
|
- $s_class = "row_odd";
|
|
|
- else
|
|
|
- $s_class = "row_even";
|
|
|
- // prof only
|
|
|
- if ($is_allowedToEdit) {
|
|
|
- echo '<tr class="' . $s_class . '">';
|
|
|
- echo '<td width="30" align="left">'.Display::return_icon('quiz.gif', get_lang('Exercice')) .'</td>';
|
|
|
- echo '<td width="15" valign="left">'.($i+($page*$limitExPage)).'.'.'</td>';
|
|
|
-
|
|
|
- //Showing exercise title
|
|
|
- $row['title']=text_filter($row['title']);
|
|
|
-
|
|
|
- echo '<td>';
|
|
|
- $class_invisible = '';
|
|
|
- if (!$row['active']) {
|
|
|
- $class_invisible = 'class="invisible"';
|
|
|
- }
|
|
|
- echo '<a href="exercice_submit.php?'.api_get_cidreq().$myorigin.$mylpid.$mylpitemid.'&exerciseId='.$row['id'].'" '.$class_invisible.'>';
|
|
|
- echo Security::remove_XSS($row['title']);
|
|
|
- echo '</a>';
|
|
|
- echo $session_img;
|
|
|
- echo '</td>';
|
|
|
- echo '<td align="center">';
|
|
|
|
|
|
- $exid = $row['id'];
|
|
|
-
|
|
|
- //count number exercice - teacher
|
|
|
- $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '" . Database :: escape_string($exid) . "'";
|
|
|
- $sqlresult = Database::query($sqlquery);
|
|
|
- $rowi = Database :: result($sqlresult, 0);
|
|
|
-
|
|
|
- $random_label = '';
|
|
|
- if ($row['random'] > 0) {
|
|
|
- $random_label = ' ('.get_lang('Random').') ';
|
|
|
- echo $row['random'] . ' ' . api_strtolower(get_lang(($row['random'] > 1 ? 'Questions' : 'Question'))) .$random_label. '</td>';
|
|
|
- } else {
|
|
|
- echo $rowi . ' ' . api_strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question'))) . '</td>';
|
|
|
- }
|
|
|
- echo '<td align="center">';
|
|
|
- if ($session_id == $row['session_id']) {
|
|
|
- ?>
|
|
|
- <a href="admin.php?<?php echo api_get_cidreq()?>&exerciseId=<?php echo $row['id']; ?>">
|
|
|
- <img src="../img/settings.png" border="0" title="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" /></a>
|
|
|
- <a href="exercice.php?<?php echo api_get_cidreq()?>&choice=copy_exercise&sec_token=<?php echo $token; ?>&exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;">
|
|
|
- <img width="22" src="../img/cd.gif" border="0" title="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" /></a>
|
|
|
- <a href="exercice.php?<?php echo api_get_cidreq()?>&choice=clean_results&sec_token=<?php echo $token; ?>&exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;" >
|
|
|
- <img width="22" src="../img/clean_group.png" border="0" title="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" /></a>
|
|
|
- <?php
|
|
|
- //if active
|
|
|
- if ($row['active']) {
|
|
|
- ?>
|
|
|
- <a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=disable&sec_token=<?php echo$token; ?>&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>">
|
|
|
- <img src="../img/visible.gif" border="0" title="<?php echo get_lang('Deactivate'); ?>" alt="<?php echo api_htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset); ?>" /></a>
|
|
|
- <?php
|
|
|
- } else { // else if not active
|
|
|
- ?>
|
|
|
- <a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=enable&sec_token=<?php echo$token; ?>&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>">
|
|
|
- <img src="../img/invisible.gif" border="0" title="<?php echo get_lang('Activate'); ?>" alt="<?php echo api_htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a>
|
|
|
- <?php
|
|
|
- }
|
|
|
- // Export qti ...
|
|
|
- echo '<a href="exercice.php?choice=exportqti2&exerciseId='.$row['id'].'"><img src="../img/export_db.png" border="0" title="IMS/QTI" /></a>';
|
|
|
- } else { // not session resource
|
|
|
- echo Display::return_icon('wizard_gray_small.gif', get_lang('ExerciseEditionNotAvailableInSession'), array('title'=>get_lang('ExerciseEditionNotAvailableInSession')));
|
|
|
- ?>
|
|
|
- <a href="exercice.php?<?php echo api_get_cidreq()?>&choice=copy_exercise&sec_token=<?php echo $token; ?>&exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;"><img width="16" src="../img/cd.gif" border="0" title="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" /></a>
|
|
|
- <?php
|
|
|
- }
|
|
|
-
|
|
|
- //last option is deleted
|
|
|
- if ($session_id == $row['session_id']) {
|
|
|
- ?>
|
|
|
- <a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=delete&sec_token=<?php echo$token; ?>&exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToDelete'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;">
|
|
|
- <img width="22" src="../img/delete.png" border="0" title="<?php echo get_lang('Delete'); ?>" alt="<?php echo api_htmlentities(get_lang('Delete'),ENT_QUOTES,$charset); ?>" /></a>
|
|
|
- <?php
|
|
|
- }
|
|
|
-
|
|
|
- echo "</td>";
|
|
|
- echo "</tr>";
|
|
|
- } else { // student only
|
|
|
- ?>
|
|
|
- <tr>
|
|
|
- <td><?php echo ($i+($page*$limitExPage)).'.'; ?></td>
|
|
|
- <?php $row['title']=text_filter($row['title']);?>
|
|
|
- <td>
|
|
|
-
|
|
|
- <?php
|
|
|
- // if time is actived show link to exercise
|
|
|
- if ($time_limits) {
|
|
|
- if ($is_actived_time) {
|
|
|
- echo '<a href="exercice_submit.php?'.api_get_cidreq().$myorigin.$mylpid.$myllpitemid.'&exerciseId='.$row['id'].'">'.$row['title'].'</a>';
|
|
|
- } else {
|
|
|
- echo $row['title'];
|
|
|
- }
|
|
|
- } else {
|
|
|
- echo '<a href="exercice_submit.php?'.api_get_cidreq().$myorigin.$mylpid.$myllpitemid.'&exerciseId='.$row['id'].'">'.$row['title'].'</a>';
|
|
|
- }
|
|
|
- echo '</td><td align="center">';
|
|
|
- $exid = $row['id'];
|
|
|
- //count number exercise questions
|
|
|
- $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '" . Database :: escape_string($exid) . "'";
|
|
|
- $sqlresult = Database::query($sqlquery);
|
|
|
- $rowi = Database :: result($sqlresult, 0);
|
|
|
- //count number random exercice
|
|
|
- $sql_random_query = 'SELECT type,random,active,results_disabled,max_attempt FROM ' . $TBL_EXERCICES . ' WHERE id="' . Database :: escape_string($exid) . '" ';
|
|
|
- $rs_random = Database::query($sql_random_query);
|
|
|
- $row_random = Database :: fetch_array($rs_random);
|
|
|
- if ($row_random['random'] > 0) {
|
|
|
- echo $row_random['random'] . ' ' . api_strtolower(get_lang(($row_random['random'] > 1 ? 'Questions' : 'Question')));
|
|
|
- } else {
|
|
|
- //show results student
|
|
|
- echo $rowi . ' ' . api_strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question')));
|
|
|
- }
|
|
|
- echo '</td>';
|
|
|
- echo '<td align="center">';
|
|
|
- $eid = $row['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
|
|
|
- $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";
|
|
|
- $qryres = Database::query($qry);
|
|
|
- $num = Database :: num_rows($qryres);
|
|
|
-
|
|
|
- //hide the results
|
|
|
- $my_result_disabled = $row['results_disabled'];
|
|
|
-
|
|
|
- if ($time_limits) {
|
|
|
- if ($my_result_disabled == 0) {
|
|
|
- if ($num > 0) {
|
|
|
- echo sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_get_local_time($row['start_time']), api_get_local_time($row['end_time']));
|
|
|
- } else {
|
|
|
- echo get_lang('NotAttempted');
|
|
|
- }
|
|
|
- } else {
|
|
|
- echo get_lang('CantShowResults');
|
|
|
- }
|
|
|
- } else {
|
|
|
- if ($my_result_disabled == 0) {
|
|
|
- if ($num > 0) {
|
|
|
- $row = Database :: fetch_array($qryres);
|
|
|
- $percentage = 0;
|
|
|
- if ($row['exe_weighting'] != 0) {
|
|
|
- $percentage = ($row['exe_result'] / $row['exe_weighting']) * 100;
|
|
|
- }
|
|
|
- echo get_lang('Attempted') . ' (' . get_lang('Score') . ': ';
|
|
|
- printf("%1.2f\n", $percentage);
|
|
|
- echo " %)";
|
|
|
- } else {
|
|
|
- //echo get_lang('WillBeActivated' .' '. $row['start_time']);
|
|
|
- echo get_lang('NotAttempted');
|
|
|
- }
|
|
|
- } else {
|
|
|
- echo get_lang('CantShowResults');
|
|
|
- }
|
|
|
- }
|
|
|
- echo '</td></tr>';
|
|
|
- }
|
|
|
- // skips the last exercise, that is only used to know if we have or not to create a link "Next page"
|
|
|
- if ($i == $limitExPage) {
|
|
|
- break;
|
|
|
- }
|
|
|
- $i++;
|
|
|
- } // end while()
|
|
|
- $ind = $i;
|
|
|
- if (($from + $limitExPage -1) > $nbrexerc) {
|
|
|
- if ($from > $nbrexerc) {
|
|
|
- $from = $from - $nbrexerc;
|
|
|
- $to = $limitExPage;
|
|
|
- } else {
|
|
|
- $to = $limitExPage - ($nbrexerc - $from);
|
|
|
- $from = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- $to = $limitExPage;
|
|
|
- }
|
|
|
-
|
|
|
- if ($is_allowedToEdit) {
|
|
|
- $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
|
|
|
- FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
|
|
|
- WHERE d.id = ip.ref AND ip.tool = '" . TOOL_DOCUMENT . "' AND (d.path LIKE '%htm%')
|
|
|
- AND d.path LIKE '" . Database :: escape_string($uploadPath) . "/%/%' LIMIT " . (int) $from . "," . (int) $to; // only .htm or .html files listed
|
|
|
- } else {
|
|
|
- $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
|
|
|
- FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
|
|
|
- WHERE d.id = ip.ref AND ip.tool = '" . TOOL_DOCUMENT . "' AND (d.path LIKE '%htm%')
|
|
|
- AND d.path LIKE '" . Database :: escape_string($uploadPath) . "/%/%' AND ip.visibility='1' LIMIT " . (int) $from . "," . (int) $to;
|
|
|
- }
|
|
|
-
|
|
|
- $result = Database::query($sql);
|
|
|
-
|
|
|
- while ($row = Database :: fetch_array($result, 'ASSOC')) {
|
|
|
- $attribute['path'][] = $row['path'];
|
|
|
- $attribute['visibility'][] = $row['visibility'];
|
|
|
- $attribute['comment'][] = $row['comment'];
|
|
|
- }
|
|
|
- $nbrActiveTests = 0;
|
|
|
- if (is_array($attribute['path'])) {
|
|
|
- while (list ($key, $path) = each($attribute['path'])) {
|
|
|
- list ($a, $vis) = each($attribute['visibility']);
|
|
|
- if (strcmp($vis, "1") == 0) {
|
|
|
- $active = 1;
|
|
|
- } else {
|
|
|
- $active = 0;
|
|
|
- }
|
|
|
- echo "<tr>\n";
|
|
|
-
|
|
|
- $title = GetQuizName($path, $documentPath);
|
|
|
- if ($title == '') {
|
|
|
- $title = basename($path);
|
|
|
- }
|
|
|
- // prof only
|
|
|
- if ($is_allowedToEdit) {
|
|
|
- echo ' <tr>'.
|
|
|
- ' <td><img src="../img/hotpotatoes_s.png" alt="HotPotatoes" /></td>'.
|
|
|
- ' <td>'.($ind+($page*$limitExPage)).'.</td>'.
|
|
|
- ' <td><a href="showinframes.php?file='.$path.'&cid='.$_course['official_code'].'&uid='.$_user['user_id'].'"'.(!$active?'class="invisible"':'').'>'.$title.'</a></td>'.
|
|
|
- ' <td align="center">-</td>'.
|
|
|
- ' <td align="center">' .
|
|
|
- ' <a href="adminhp.php?'.api_get_cidreq().'&hotpotatoesName='.$path.'">'.
|
|
|
- ' <img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="'.api_htmlentities(get_lang('Modify'),ENT_QUOTES,$charset).'" />' .
|
|
|
- ' </a>'.
|
|
|
- ' <a href="'.$exercicePath.'?'.api_get_cidreq().'&hpchoice=delete&file='.$path.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('AreYouSure'),ENT_QUOTES,$charset).$title."?").'\')) return false;"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="'.api_htmlentities(get_lang('Delete'),ENT_QUOTES,$charset).'" /></a>';
|
|
|
- // if active
|
|
|
- if ($active) {
|
|
|
- $nbrActiveTests = $nbrActiveTests +1;
|
|
|
- echo ' <a href="'.$exercicePath.'?'.api_get_cidreq().'&hpchoice=disable&page='.$page.'&file='.$path.'"><img src="../img/visible.gif" border="0" title="'.get_lang('Deactivate').'" alt="'.api_htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset).'" /></a>';
|
|
|
- } else { // else if not active
|
|
|
- echo ' <a href="'.$exercicePath.'?'.api_get_cidreq().'&hpchoice=enable&page='.$page.'&file='.$path.'"><img src="../img/invisible.gif" border="0" title="'.get_lang('Activate').'" alt="'.api_htmlentities(get_lang('Activate'),ENT_QUOTES,$charset).'" /></a>';
|
|
|
- }
|
|
|
- echo '<img src="../img/lp_quiz_na.gif" border="0" title="'.get_lang('NotMarkActivity').'" alt="" />';
|
|
|
- echo '</td>';
|
|
|
- } else { // student only
|
|
|
- if ($active == 1) {
|
|
|
- $nbrActiveTests = $nbrActiveTests +1;
|
|
|
- echo ' <tr>'.
|
|
|
- ' <td>'.($ind+($page*$limitExPage)).'.<!--<img src="../img/jqz.jpg" alt="HotPotatoes" />--></td>' .
|
|
|
- ' <td><a href="showinframes.php?'.api_get_cidreq().'&file='.$path.'&cid='.$_course['official_code'].'&uid='.$_user['user_id'].'"'.(!$active?'class="invisible"':'').'">'.$title.'</a></td>'.
|
|
|
- ' <td style="text-align: center;">-</td><td style="text-align: center;">-</td>'.
|
|
|
- ' </tr>';
|
|
|
- }
|
|
|
- }
|
|
|
- if ($ind == $limitExPage) {
|
|
|
- break;
|
|
|
- }
|
|
|
- if ($is_allowedToEdit) {
|
|
|
- $ind++;
|
|
|
- } else {
|
|
|
- if ($active == 1) {
|
|
|
- $ind++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } //end if ($origin != 'learnpath') {
|
|
|
-echo '</table>';
|
|
|
-}
|
|
|
+
|
|
|
|
|
|
/* Exercise Results (uses tracking tool) */
|
|
|
|
|
@@ -1409,356 +940,14 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
|
|
|
$table->set_header(1, get_lang('FirstName'));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
$table->set_header(-$secuence + 2, get_lang('Exercice'));
|
|
|
$table->set_header(-$secuence + 3, get_lang('Duration'),false);
|
|
|
$table->set_header(-$secuence + 4, get_lang('Date'));
|
|
|
$table->set_header(-$secuence + 5, get_lang('Result'),false);
|
|
|
$table->set_header(-$secuence + 6, (($is_allowedToEdit||$is_tutor) ? get_lang('CorrectTest') : get_lang('ViewTest')), false);
|
|
|
- $table->display();
|
|
|
-
|
|
|
+ $table->display();
|
|
|
}
|
|
|
+
|
|
|
if ($origin != 'learnpath') { //so we are not in learnpath tool
|
|
|
Display :: display_footer();
|
|
|
-} else {
|
|
|
-?>
|
|
|
-<link rel="stylesheet" type="text/css" href="<?php echo $clarolineRepositoryWeb ?>css/default.css" />
|
|
|
-<?php
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * Gets count of exam results
|
|
|
- * @todo this function should be moved in a library + no global calls
|
|
|
- */
|
|
|
-function get_count_exam_results($exercise_id = null) {
|
|
|
- global $is_allowedToEdit, $is_tutor,$_cid,$_user,$TBL_USER, $TBL_EXERCICES,$TBL_TRACK_EXERCICES, $TBL_TRACK_ATTEMPT_RECORDING,$filter_by_not_revised,$filter_by_revised,$documentPath;
|
|
|
- $session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' ';
|
|
|
- if ($is_allowedToEdit || $is_tutor) {
|
|
|
- $user_id_and = '';
|
|
|
- if (!empty ($_POST['filter_by_user'])) {
|
|
|
- if ($_POST['filter_by_user'] == 'all') {
|
|
|
- $user_id_and = " AND user_id like '%'";
|
|
|
- } else {
|
|
|
- $user_id_and = " AND user_id = '" . Database :: escape_string((int) $_POST['filter_by_user']) . "' ";
|
|
|
- }
|
|
|
- }
|
|
|
- if ($_GET['gradebook'] == 'view') {
|
|
|
- $exercise_where_query = 'te.exe_exo_id =ce.id AND ';
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $exercise_where = '';
|
|
|
- if (isset($_GET['exerciseId'])) {
|
|
|
- $exercise_where = ' AND te.exe_exo_id = '.intval($_GET['exerciseId']).' ';
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($exercise_id)) {
|
|
|
- $exercise_where = ' AND te.exe_exo_id = '.intval($exercise_id).' ';
|
|
|
- }
|
|
|
-
|
|
|
- //@todo fix to work with COURSE_RELATION_TYPE_RRHH in both queries
|
|
|
-
|
|
|
- /*$sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname col1" : "lastname as userpart1, firstname as col1").", ce.title as extitle, te.exe_result as exresult ,
|
|
|
- te.exe_weighting as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, te.start_date as exstart, steps_counter as exstep,cuser.user_id as excruid,te.exe_duration as exduration
|
|
|
- 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 cuser.relation_type<>".COURSE_RELATION_TYPE_RRHH." 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) . "'
|
|
|
- $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 col1, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";*/
|
|
|
-
|
|
|
- $sql="SELECT count(*) as count
|
|
|
- FROM $TBL_EXERCICES AS ce INNER JOIN $TBL_TRACK_EXERCICES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
|
|
|
- WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($_cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 $exercise_where ";
|
|
|
-
|
|
|
- $hpsql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1").", tth.exe_name, tth.exe_result , tth.exe_weighting, tth.exe_date
|
|
|
- FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
|
|
|
- WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '" . Database :: escape_string($_cid) . " $user_id_and $exercise_where
|
|
|
- ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC";
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- } else {
|
|
|
- // get only this user's results
|
|
|
- $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
|
|
|
-
|
|
|
- /*$sql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1").", ce.title as extitle, te.exe_result as exresult, " .
|
|
|
- "te.exe_weighting as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, " .
|
|
|
- "te.start_date as exstart, steps_counter as exstep, cuser.user_id as excruid, te.exe_duration as exduration, ce.results_disabled as exdisabled
|
|
|
- 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) . "'
|
|
|
- AND cuser.relation_type<>".COURSE_RELATION_TYPE_RRHH." $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 col1, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";*/
|
|
|
-
|
|
|
- $sql="SELECT count(*) as count
|
|
|
- FROM $TBL_EXERCICES AS ce INNER JOIN $TBL_TRACK_EXERCICES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
|
|
|
- WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($_cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND" .
|
|
|
- " orig_lp_id = 0 AND orig_lp_item_id = 0 ";
|
|
|
-
|
|
|
- $hpsql = "SELECT '',exe_name, exe_result , exe_weighting, exe_date
|
|
|
- FROM $TBL_TRACK_HOTPOTATOES
|
|
|
- WHERE exe_user_id = '" . $_user['user_id'] . "' AND exe_cours_id = '" . Database :: escape_string($_cid) . "'
|
|
|
- ORDER BY exe_cours_id ASC, exe_date DESC";
|
|
|
- }
|
|
|
-
|
|
|
- $resx = Database::query($sql);
|
|
|
- $rowx = Database::fetch_array($resx,'ASSOC');
|
|
|
- return $rowx['count'];
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * Gets the exam'data results
|
|
|
- * @todo this function should be moved in a library + no global calls
|
|
|
- */
|
|
|
-function get_exam_results_data($from, $number_of_items, $column, $direction) {
|
|
|
-
|
|
|
- global $is_allowedToEdit, $is_tutor,$_cid,$_user,$TBL_USER, $TBL_EXERCICES,$TBL_TRACK_EXERCICES, $TBL_TRACK_ATTEMPT_RECORDING,$filter_by_not_revised,$filter_by_revised,$documentPath;
|
|
|
- $session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' ';
|
|
|
- if ($is_allowedToEdit || $is_tutor) {
|
|
|
- $user_id_and = '';
|
|
|
- if (!empty ($_POST['filter_by_user'])) {
|
|
|
- if ($_POST['filter_by_user'] == 'all') {
|
|
|
- $user_id_and = " AND user_id like '%'";
|
|
|
- } else {
|
|
|
- $user_id_and = " AND user_id = '" . Database :: escape_string((int) $_POST['filter_by_user']) . "' ";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if ($_GET['gradebook'] == 'view') {
|
|
|
- $exercise_where_query = ' te.exe_exo_id =ce.id AND ';
|
|
|
- }
|
|
|
-
|
|
|
- $exercise_where = '';
|
|
|
- if (isset($_GET['exerciseId'])) {
|
|
|
- $exercise_where .= ' AND te.exe_exo_id = '.intval($_GET['exerciseId']).' ';
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //@todo fix to work with COURSE_RELATION_TYPE_RRHH in both queries
|
|
|
-
|
|
|
- /*$sql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1").", ce.title as extitle, te.exe_result as exresult ,
|
|
|
- te.exe_weighting as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, te.start_date as exstart, steps_counter as exstep,cuser.user_id as excruid,te.exe_duration as exduration
|
|
|
- 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 cuser.relation_type<>".COURSE_RELATION_TYPE_RRHH." 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) . "'
|
|
|
- $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 col1, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";*/
|
|
|
-
|
|
|
- $sql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1").", ce.title as col2, te.exe_result as exresult , te.exe_weighting as exweight,
|
|
|
- te.exe_date as exdate, te.exe_id as exid, email as exemail, te.start_date as col4, steps_counter as exstep, exe_user_id as excruid,te.exe_duration as exduration
|
|
|
- FROM $TBL_EXERCICES AS ce INNER JOIN $TBL_TRACK_EXERCICES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
|
|
|
- WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($_cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 $exercise_where ";
|
|
|
-
|
|
|
- $hpsql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1").", tth.exe_name, tth.exe_result , tth.exe_weighting, tth.exe_date
|
|
|
- FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
|
|
|
- WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '" . Database :: escape_string($_cid)." $user_id_and $exercise_where
|
|
|
- ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC";
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- } else {
|
|
|
- // get only this user's results
|
|
|
- $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
|
|
|
-
|
|
|
- /*$sql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1").", ce.title as extitle, te.exe_result as exresult, " .
|
|
|
- "te.exe_weighting as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, " .
|
|
|
- "te.start_date as exstart, steps_counter as exstep, cuser.user_id as excruid, te.exe_duration as exduration, ce.results_disabled as exdisabled
|
|
|
- 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) . "'
|
|
|
- AND cuser.relation_type<>".COURSE_RELATION_TYPE_RRHH." $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 col1, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $sql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1")." , ce.title as col2, te.exe_result as exresult, " .
|
|
|
- "te.exe_weighting as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, " .
|
|
|
- "te.start_date as col4, steps_counter as exstep, exe_user_id as excruid, te.exe_duration as exduration, ce.results_disabled as exdisabled
|
|
|
- FROM $TBL_EXERCICES AS ce INNER JOIN $TBL_TRACK_EXERCICES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
|
|
|
- WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($_cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND" .
|
|
|
- " orig_lp_id = 0 AND orig_lp_item_id = 0 ";
|
|
|
-
|
|
|
- $hpsql = "SELECT '',exe_name, exe_result , exe_weighting, exe_date
|
|
|
- FROM $TBL_TRACK_HOTPOTATOES
|
|
|
- WHERE exe_user_id = '" . $_user['user_id'] . "' AND exe_cours_id = '" . Database :: escape_string($_cid) . "'
|
|
|
- ORDER BY exe_cours_id ASC, exe_date DESC";
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $column = intval($column);
|
|
|
- $from = intval($from);
|
|
|
- $number_of_items = intval($number_of_items);
|
|
|
- $sql .= " ORDER BY col$column $direction ";
|
|
|
- $sql .= " LIMIT $from,$number_of_items";
|
|
|
-
|
|
|
- $results = array();
|
|
|
-
|
|
|
- $resx = Database::query($sql);
|
|
|
- while ($rowx = Database::fetch_array($resx,'ASSOC')) {
|
|
|
- $results[] = $rowx;
|
|
|
- }
|
|
|
- $hpresults = getManyResultsXCol($hpsql, 5);
|
|
|
-
|
|
|
- $has_test_results = false;
|
|
|
- $list_info = array();
|
|
|
-
|
|
|
- // Print test results.
|
|
|
- $lang_nostartdate = get_lang('NoStartDate') . ' / ';
|
|
|
-
|
|
|
-
|
|
|
- if (is_array($results)) {
|
|
|
- $has_test_results = true;
|
|
|
- $users_array_id = array ();
|
|
|
- if ($_GET['gradebook'] == 'view') {
|
|
|
- $filter_by_no_revised = true;
|
|
|
- $from_gradebook = true;
|
|
|
- }
|
|
|
- $sizeof = sizeof($results);
|
|
|
-
|
|
|
- $user_list_id = array ();
|
|
|
- $user_last_name = '';
|
|
|
- $user_first_name = '';
|
|
|
- $quiz_name_list = '';
|
|
|
- $duration_list = '';
|
|
|
- $date_list = '';
|
|
|
- $result_list = '';
|
|
|
- $more_details_list = '';
|
|
|
- for ($i = 0; $i < $sizeof; $i++) {
|
|
|
- $revised = false;
|
|
|
- $sql_exe = 'SELECT exe_id FROM ' . $TBL_TRACK_ATTEMPT_RECORDING . '
|
|
|
- WHERE author != ' . "''" . ' AND exe_id = ' . "'" . Database :: escape_string($results[$i]['exid']) . "'" . ' LIMIT 1';
|
|
|
- $query = Database::query($sql_exe);
|
|
|
-
|
|
|
- if (Database :: num_rows($query) > 0) {
|
|
|
- $revised = true;
|
|
|
- }
|
|
|
- if ($filter_by_not_revised && $revised) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if ($filter_by_revised && !$revised) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if ($from_gradebook && ($is_allowedToEdit || $is_tutor)) {
|
|
|
- if (in_array($results[$i]['col2'] . $results[$i]['col0'] . $results[$i]['col1'], $users_array_id)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- $users_array_id[] = $results[$i]['col2'] . $results[$i]['col0'] . $results[$i]['col1'];
|
|
|
- }
|
|
|
-
|
|
|
- $user_first_name = $results[$i]['col0'];
|
|
|
- $user_last_name = $results[$i]['col1'];
|
|
|
- $user_list_id[] = $results[$i]['excruid'];
|
|
|
- $id = $results[$i]['exid'];
|
|
|
-
|
|
|
- $user = $results[$i]['col0'] . $results[$i]['col1'];
|
|
|
- $test = $results[$i]['col2'];
|
|
|
- $quiz_name_list = $test;
|
|
|
- $dt = api_convert_and_format_date($results[$i]['exweight'], null, date_default_timezone_get());
|
|
|
- $res = $results[$i]['exresult'];
|
|
|
-
|
|
|
- $duration = intval($results[$i]['exduration']);
|
|
|
- // we filter the results if we have the permission to
|
|
|
- if (isset ($results[$i]['exdisabled']))
|
|
|
- $result_disabled = intval($results[$i]['exdisabled']);
|
|
|
- else
|
|
|
- $result_disabled = 0;
|
|
|
-
|
|
|
- if ($result_disabled == 0) {
|
|
|
- $add_start_date = $lang_nostartdate;
|
|
|
-
|
|
|
- if ($is_allowedToEdit || $is_tutor) {
|
|
|
- $user = $results[$i]['col0'] . $results[$i]['col1'];
|
|
|
- }
|
|
|
- if ($results[$i]['col4'] != "0000-00-00 00:00:00") {
|
|
|
- //echo ceil((($results[$i][4] - $results[$i][7]) / 60)) . ' ' . get_lang('MinMinutes');
|
|
|
- $exe_date_timestamp = api_strtotime($results[$i]['exdate'], date_default_timezone_get());
|
|
|
- $start_date_timestamp = api_strtotime($results[$i]['col4'], date_default_timezone_get());
|
|
|
-
|
|
|
- $my_duration = ceil((($exe_date_timestamp - $start_date_timestamp) / 60));
|
|
|
- if ($my_duration == 1 ) {
|
|
|
- $duration_list = $my_duration . ' ' . get_lang('MinMinute');
|
|
|
- } else {
|
|
|
- $duration_list = $my_duration. ' ' . get_lang('MinMinutes');
|
|
|
- }
|
|
|
- if ($results[$i]['exstep'] > 1) {
|
|
|
- //echo ' ( ' . $results[$i][8] . ' ' . get_lang('Steps') . ' )';
|
|
|
- $duration_list = ' ( ' . $results[$i]['exstep'] . ' ' . get_lang('Steps') . ' )';
|
|
|
- }
|
|
|
- $add_start_date = api_convert_and_format_date($results[$i]['col4'], null, date_default_timezone_get()) . ' / ';
|
|
|
- } else {
|
|
|
- $duration_list = get_lang('NoLogOfDuration');
|
|
|
- //echo get_lang('NoLogOfDuration');
|
|
|
- }
|
|
|
- // Date conversion
|
|
|
- $date_list = api_get_local_time($results[$i]['col4']). ' / ' . api_get_local_time($results[$i]['exdate']);
|
|
|
- // there are already a duration test period calculated??
|
|
|
- //echo '<td>'.sprintf(get_lang('DurationFormat'), $duration).'</td>';
|
|
|
-
|
|
|
- // if the float look like 10.00 we show only 10
|
|
|
-
|
|
|
- $my_res = float_format($results[$i]['exresult'],1);
|
|
|
- $my_total = float_format($results[$i]['exweight'],1);
|
|
|
-
|
|
|
- $result_list = round(($my_res / ($my_total != 0 ? $my_total : 1)) * 100, 2) . '% (' . $my_res . ' / ' . $my_total . ')';
|
|
|
-
|
|
|
- $html_link = '';
|
|
|
- if ($is_allowedToEdit || $is_tutor) {
|
|
|
- if ($revised) {
|
|
|
- $html_link.= "<a href='exercise_show.php?".api_get_cidreq()."&action=edit&id=$id'>".Display :: return_icon('edit.gif', get_lang('Edit'));
|
|
|
- $html_link.= ' ';
|
|
|
- } else {
|
|
|
- $html_link.="<a href='exercise_show.php?".api_get_cidreq()."&action=qualify&id=$id'>".Display :: return_icon('quizz_small.gif', get_lang('Qualify'));
|
|
|
- $html_link.=' ';
|
|
|
- }
|
|
|
- $html_link.="</a>";
|
|
|
- if (api_is_platform_admin() || $is_tutor) {
|
|
|
- $html_link.=' <a href="exercice.php?'.api_get_cidreq().'&show=result&filter=' . $filter . '&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $user, $dt) . '\')) return false;">'.Display :: return_icon('delete.gif', get_lang('Delete')).'</a>';
|
|
|
- $html_link.=' ';
|
|
|
- }
|
|
|
- if ($is_allowedToEdit) {
|
|
|
- if ($filter==2){
|
|
|
- $html_link.=' <a href="exercice_history.php?'.api_get_cidreq().'&exe_id=' . $id . '">' .Display :: return_icon('history.gif', get_lang('ViewHistoryChange')).'</a>';
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if ($revised) {
|
|
|
- $html_link.="<a href='exercise_show.php?".api_get_cidreq()."&id=$id'>" . get_lang('Show') . "</a> ";
|
|
|
- } else {
|
|
|
- $html_link.=' ' . get_lang('NoResult');
|
|
|
- }
|
|
|
- }
|
|
|
- $more_details_list = $html_link;
|
|
|
- if ($is_allowedToEdit || $is_tutor) {
|
|
|
- $list_info [] = array($user_first_name,$user_last_name,$quiz_name_list,$duration_list,$date_list,$result_list,$more_details_list);
|
|
|
- } else {
|
|
|
- $list_info [] = array($quiz_name_list,$duration_list,$date_list,$result_list,$more_details_list);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // Print HotPotatoes test results.
|
|
|
- if (is_array($hpresults)) {
|
|
|
- $has_test_results = true;
|
|
|
- for ($i = 0; $i < sizeof($hpresults); $i++) {
|
|
|
- $hp_title = GetQuizName($hpresults[$i][1], $documentPath);
|
|
|
- if ($hp_title == '') {
|
|
|
- $hp_title = basename($hpresults[$i][1]);
|
|
|
- }
|
|
|
- //$hp_date = api_convert_and_format_date($hpresults[$i][4], null, date_default_timezone_get());
|
|
|
- $hp_date = api_get_local_time($hpresults[$i][4], null, date_default_timezone_get());
|
|
|
- $hp_result = round(($hpresults[$i][2] / ($hpresults[$i][3] != 0 ? $hpresults[$i][3] : 1)) * 100, 2).'% ('.$hpresults[$i][2].' / '.$hpresults[$i][3].')';
|
|
|
- if ($is_allowedToEdit) {
|
|
|
- $list_info[] = array($hpresults[$i][0], $hp_title, '-', $hp_date , $hp_result , '-');
|
|
|
- } else {
|
|
|
- $list_info[] = array($hp_title, '-', $hp_date , $hp_result , '-');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return $list_info;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-?>
|