|
@@ -663,6 +663,7 @@ if (!empty($exerciseList)) {
|
|
|
$mylpid = (empty($learnpath_id) ? '' : '&learnpath_id='.$learnpath_id);
|
|
|
$mylpitemid = (empty($learnpath_item_id) ? '' : '&learnpath_item_id='.$learnpath_item_id);
|
|
|
$i = 1;
|
|
|
+
|
|
|
foreach ($exerciseList as $row) {
|
|
|
$my_exercise_id = $row['id'];
|
|
|
|
|
@@ -734,6 +735,12 @@ if (!empty($exerciseList)) {
|
|
|
}
|
|
|
|
|
|
// Teacher only
|
|
|
+ // Count number exercise - teacher
|
|
|
+ $sql = "SELECT count(*) count FROM $TBL_EXERCISE_QUESTION
|
|
|
+ WHERE c_id = $courseId AND exercice_id = $my_exercise_id";
|
|
|
+ $sqlresult = Database::query($sql);
|
|
|
+ $rowi = intval(Database :: result($sqlresult, 0, 0));
|
|
|
+
|
|
|
if ($is_allowedToEdit) {
|
|
|
$lp_blocked = null;
|
|
|
if ($exercise->exercise_was_added_in_lp == true) {
|
|
@@ -805,19 +812,13 @@ if (!empty($exerciseList)) {
|
|
|
|
|
|
$listExercise['id'] = $row['id'];
|
|
|
$listExercise['title'] = $title;
|
|
|
- $listExercise['description'] = $row['description'];
|
|
|
+ $listExercise['description'] = cut($row['description'],150, false);
|
|
|
$listExercise['url'] = "overview.php?".api_get_cidreq().$mylpid.$mylpitemid.'&exerciseId='.$row['id'];
|
|
|
$listExercise['lp_blocked'] = $lp_blocked;
|
|
|
$listExercise['visibility'] = $visibility;
|
|
|
$listExercise['active'] = $row['active'];
|
|
|
|
|
|
- $item = Display::tag('td', $url.' '.$session_img.$lp_blocked);
|
|
|
-
|
|
|
- // Count number exercise - teacher
|
|
|
- $sql = "SELECT count(*) count FROM $TBL_EXERCISE_QUESTION
|
|
|
- WHERE c_id = $courseId AND exercice_id = $my_exercise_id";
|
|
|
- $sqlresult = Database::query($sql);
|
|
|
- $rowi = intval(Database :: result($sqlresult, 0, 0));
|
|
|
+ //$item = Display::tag('td', $url.' '.$session_img.$lp_blocked);
|
|
|
|
|
|
if ($sessionId == $row['session_id']) {
|
|
|
// Questions list
|
|
@@ -1065,6 +1066,7 @@ if (!empty($exerciseList)) {
|
|
|
$actions .= $delete;
|
|
|
|
|
|
// Number of questions
|
|
|
+
|
|
|
$random_label = null;
|
|
|
if ($row['random'] > 0 || $row['random'] == -1) {
|
|
|
// if random == -1 means use random questions with all questions
|
|
@@ -1093,7 +1095,7 @@ if (!empty($exerciseList)) {
|
|
|
$number_of_questions = $rowi;
|
|
|
}
|
|
|
$listExercise['number_questions'] = $number_of_questions;
|
|
|
- $item .= Display::tag('td', $number_of_questions);
|
|
|
+ //$item .= Display::tag('td', $number_of_questions);
|
|
|
} else {
|
|
|
// Student only.
|
|
|
$visibility = api_get_item_visibility(
|
|
@@ -1114,7 +1116,7 @@ if (!empty($exerciseList)) {
|
|
|
$listExercise['url'] = 'overview.php?'.api_get_cidreq().$mylpid.$mylpitemid.'&exerciseId='.$row['id'];
|
|
|
|
|
|
// Link of the exercise.
|
|
|
- $item = Display::tag('td', $url.' '.$session_img);
|
|
|
+ //$item = Display::tag('td', $url.' '.$session_img);
|
|
|
|
|
|
// Count number exercise questions.
|
|
|
/*$sql = "SELECT count(*) FROM $TBL_EXERCISE_QUESTION
|
|
@@ -1231,10 +1233,12 @@ if (!empty($exerciseList)) {
|
|
|
if ($num > 0) {
|
|
|
$row_track = Database :: fetch_array($qryres);
|
|
|
$attempt_text = get_lang('LatestAttempt').' : ';
|
|
|
- $attempt_text .= ExerciseLib::show_score(
|
|
|
+ $score = ExerciseLib::show_score(
|
|
|
$row_track['score'],
|
|
|
$row_track['max_score']
|
|
|
);
|
|
|
+ $attempt_text .= $score['html'];
|
|
|
+
|
|
|
} else {
|
|
|
$attempt_text = get_lang('NotAttempted');
|
|
|
}
|
|
@@ -1259,9 +1263,10 @@ if (!empty($exerciseList)) {
|
|
|
}
|
|
|
|
|
|
$listExercise['status'] = $attempt_text;
|
|
|
- $listExercise['description'] = $row['description'];
|
|
|
+ $listExercise['description'] = cut($row['description'], 150, false);
|
|
|
$listExercise['score'] = $score;
|
|
|
- $item .= Display::tag('td', $attempt_text);
|
|
|
+ $listExercise['number_questions'] = $rowi;
|
|
|
+ //$item .= Display::tag('td', $attempt_text);
|
|
|
}
|
|
|
|
|
|
if ($is_allowedToEdit) {
|
|
@@ -1270,8 +1275,8 @@ if (!empty($exerciseList)) {
|
|
|
if (!empty($additionalActions)) {
|
|
|
$actions .= $additionalActions.PHP_EOL;
|
|
|
}
|
|
|
- $listExercise['actions'] = $actions;
|
|
|
- $item .= Display::tag('td', $actions, ['class' => 'td_actions']);
|
|
|
+ $listExercise['actions'] = $actions;
|
|
|
+ //$item .= Display::tag('td', $actions, ['class' => 'td_actions']);
|
|
|
} else {
|
|
|
if ($isDrhOfCourse) {
|
|
|
|
|
@@ -1279,18 +1284,18 @@ if (!empty($exerciseList)) {
|
|
|
Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
|
|
|
$listExercise['actions'] = $actions;
|
|
|
|
|
|
- $item .= Display::tag('td', $actions, ['class' => 'td_actions']);
|
|
|
+ // .= Display::tag('td', $actions, ['class' => 'td_actions']);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $tableRows[] = Display::tag(
|
|
|
+ /*$tableRows[] = Display::tag(
|
|
|
'tr',
|
|
|
$item,
|
|
|
[
|
|
|
'id' => 'exercise_list_'.$my_exercise_id,
|
|
|
]
|
|
|
- );
|
|
|
+ );*/
|
|
|
|
|
|
$list[] = $listExercise;
|
|
|
}
|
|
@@ -1332,11 +1337,16 @@ while ($row = Database :: fetch_array($result, 'ASSOC')) {
|
|
|
}
|
|
|
|
|
|
$nbrActiveTests = 0;
|
|
|
+$itemHotpotatoes = [];
|
|
|
+$listHotpotatoes = [];
|
|
|
+
|
|
|
if (isset($attribute['path']) && is_array($attribute['path'])) {
|
|
|
$hotpotatoes_exist = true;
|
|
|
foreach ($attribute['path'] as $key => $path) {
|
|
|
- $item = '';
|
|
|
+
|
|
|
+ //$item = '';
|
|
|
$title = GetQuizName($path, $documentPath);
|
|
|
+
|
|
|
if ($title == '') {
|
|
|
$title = basename($path);
|
|
|
}
|
|
@@ -1363,7 +1373,11 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- $item = Display::tag(
|
|
|
+ $url = 'showinframes.php?'.api_get_cidreq().'&'.http_build_query(['file' => $path, 'uid' => $userId]);
|
|
|
+ $itemHotpotatoes['url'] = $url;
|
|
|
+ $itemHotpotatoes['visibility'] = $visibility;
|
|
|
+
|
|
|
+ /*$item = Display::tag(
|
|
|
'td',
|
|
|
implode(PHP_EOL, [
|
|
|
Display::return_icon('hotpotatoes_s.png', "HotPotatoes"),
|
|
@@ -1376,9 +1390,11 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
|
|
|
['class' => $visibility == 0 ? 'text-muted' : null]
|
|
|
),
|
|
|
])
|
|
|
- );
|
|
|
+ );*/
|
|
|
+
|
|
|
+ $itemHotpotatoes['title'] = $title;
|
|
|
|
|
|
- $item .= Display::tag('td', '-');
|
|
|
+ //$item .= Display::tag('td', '-');
|
|
|
|
|
|
$actions = Display::url(
|
|
|
Display::return_icon(
|
|
@@ -1404,8 +1420,13 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
|
|
|
}
|
|
|
$actions .= '<a href="'.$exercisePath.'?'.api_get_cidreq().'&hpchoice=delete&file='.$path.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('AreYouSureToDeleteJS'), ENT_QUOTES, $charset).' '.$title."?").'\')) return false;">'.
|
|
|
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
|
|
|
- $item .= Display::tag('td', $actions);
|
|
|
- $tableRows[] = Display::tag('tr', $item);
|
|
|
+
|
|
|
+ $itemHotpotatoes['actions'] = $actions;
|
|
|
+
|
|
|
+ $listHotpotatoes[] = $itemHotpotatoes;
|
|
|
+ //$item .= Display::tag('td', $actions);
|
|
|
+ //$tableRows[] = Display::tag('tr', $item);
|
|
|
+
|
|
|
} else {
|
|
|
$visibility = api_get_item_visibility(
|
|
|
['real_id' => $courseId],
|
|
@@ -1413,6 +1434,7 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
|
|
|
$attribute['id'][$key],
|
|
|
$sessionId
|
|
|
);
|
|
|
+ $itemHotpotatoes['visibility'] = $visibility;
|
|
|
|
|
|
if (0 == $visibility) {
|
|
|
continue;
|
|
@@ -1426,8 +1448,14 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
|
|
|
api_get_session_id()
|
|
|
);
|
|
|
|
|
|
+
|
|
|
+ $url = 'showinframes.php?'.api_get_cidreq().'&'.http_build_query(['file' => $path, 'cid' => api_get_course_id(), 'uid' => $userId]);
|
|
|
+ $itemHotpotatoes['url'] = $url;
|
|
|
+ $itemHotpotatoes['title'] = $title;
|
|
|
+ $itemHotpotatoes['attempt'] = $attempt;
|
|
|
+
|
|
|
$nbrActiveTests = $nbrActiveTests + 1;
|
|
|
- $item .= Display::tag(
|
|
|
+ /*$item .= Display::tag(
|
|
|
'td',
|
|
|
Display::url(
|
|
|
$title,
|
|
@@ -1437,34 +1465,50 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
|
|
|
'uid' => $userId,
|
|
|
])
|
|
|
)
|
|
|
- );
|
|
|
+ );*/
|
|
|
|
|
|
if (!empty($attempt)) {
|
|
|
- $actions = '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'&filter_by_user='.$userId.'">'.Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
|
|
|
- $attemptText = get_lang('LatestAttempt').' : ';
|
|
|
- $attemptText .= ExerciseLib::show_score(
|
|
|
+ $urlResults = 'hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'&filter_by_user='.$userId;
|
|
|
+ $itemHotpotatoes['results'] = $url;
|
|
|
+
|
|
|
+ /*$actions = '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'&filter_by_user='.$userId.'">'
|
|
|
+ .Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).
|
|
|
+ '</a>';*/
|
|
|
+
|
|
|
+ $attemptText = get_lang('LatestAttempt');
|
|
|
+
|
|
|
+ $score = ExerciseLib::show_score(
|
|
|
$attempt['score'],
|
|
|
$attempt['max_score']
|
|
|
- ).' ';
|
|
|
- $attemptText .= $actions;
|
|
|
+ );
|
|
|
+
|
|
|
+ $itemHotpotatoes['score'] = $score;
|
|
|
+
|
|
|
+
|
|
|
} else {
|
|
|
// No attempts.
|
|
|
$attemptText = get_lang('NotAttempted').' ';
|
|
|
}
|
|
|
|
|
|
- $item .= Display::tag('td', $attemptText);
|
|
|
+ $itemHotpotatoes['status'] = $attemptText;
|
|
|
+
|
|
|
+ //$item .= Display::tag('td', $attemptText);
|
|
|
|
|
|
if ($isDrhOfCourse) {
|
|
|
- $actions = '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'">'.
|
|
|
+ $urlResults = 'hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path;
|
|
|
+ $itemHotpotatoes['results'] = $urlResults;
|
|
|
+ /*$actions = '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'">'.
|
|
|
Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
|
|
|
|
|
|
$item .= Display::tag(
|
|
|
'td',
|
|
|
$actions,
|
|
|
['class' => 'td_actions']
|
|
|
- );
|
|
|
+ );*/
|
|
|
}
|
|
|
- $tableRows[] = Display::tag('tr', $item);
|
|
|
+
|
|
|
+ $listHotpotatoes[] = $itemHotpotatoes;
|
|
|
+ //$tableRows[] = Display::tag('tr', $item);
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -1485,7 +1529,7 @@ if (empty($exerciseList) && $hotpotatoes_exist == false) {
|
|
|
echo '</div>';
|
|
|
}
|
|
|
} else {
|
|
|
- if ($is_allowedToEdit) {
|
|
|
+ /*if ($is_allowedToEdit) {
|
|
|
$headers = [
|
|
|
get_lang('ExerciseName'),
|
|
|
get_lang('QuantityQuestions'),
|
|
@@ -1521,10 +1565,11 @@ if (empty($exerciseList) && $hotpotatoes_exist == false) {
|
|
|
|
|
|
echo '</tbody>';
|
|
|
echo '</table>';
|
|
|
- echo '</div>';
|
|
|
+ echo '</div>'*/;
|
|
|
|
|
|
$tpl = new Template(null);
|
|
|
$tpl->assign('data', $list);
|
|
|
+ $tpl->assign('hotpotatoes', $listHotpotatoes);
|
|
|
$tpl->assign('is_teacher', $is_allowedToEdit);
|
|
|
$layout = $tpl->get_template('exercise/index.html.twig');
|
|
|
$content = $tpl->fetch($layout);
|