Hiding an exercise if we added it in a LP see #4546

skala
Julio Montoya 13 years ago
parent 39fd9b3ea1
commit 7e90dd229c
  1. 12
      main/exercice/exercice.php
  2. 12
      main/newscorm/learnpath.class.php

@ -519,7 +519,7 @@ if (!empty($exercise_list)) {
// Teacher only
if ($is_allowedToEdit) {
$show_quiz_edition = true;
$added_to_lp = false;
$sql="SELECT max_score FROM $table_lp_item
WHERE c_id = $course_id AND
@ -527,11 +527,11 @@ if (!empty($exercise_list)) {
path ='".Database::escape_string($row['id'])."'";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$show_quiz_edition = false;
$added_to_lp = true;
}
$lp_blocked = '';
if (!$show_quiz_edition) {
if ($added_to_lp) {
$lp_blocked = Display::label(get_lang('AddedToALP'), 'info');
}
@ -582,12 +582,18 @@ if (!empty($exercise_list)) {
} else {
$actions .= Display::return_icon('clean_na.png', get_lang('ResourceLockedByGradebook'),'',ICON_SIZE_SMALL);
}
//Visible / invisible
//Check if this exercise was added in a LP
if ($added_to_lp) {
$actions .= Display::return_icon('invisible.png', get_lang('AddedToLPCannotBeAccessed'),'',ICON_SIZE_SMALL);
} else {
if ($row['active']) {
$actions .= Display::url(Display::return_icon('visible.png', get_lang('Deactivate'),'',ICON_SIZE_SMALL) , 'exercice.php?'.api_get_cidreq().'&choice=disable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']);
} else { // else if not active
$actions .= Display::url(Display::return_icon('invisible.png', get_lang('Activate'),'',ICON_SIZE_SMALL) , 'exercice.php?'.api_get_cidreq().'&choice=enable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']);
}
}
// Export qti ...
$actions .= Display::url(Display::return_icon('export_qti2.png','IMS/QTI','',ICON_SIZE_SMALL), 'exercice.php?choice=exportqti2&exerciseId='.$row['id']);
} else {

@ -446,6 +446,12 @@ class learnpath {
quiz_rel_question.c_id = $course_id ";
$rsQuiz = Database::query($sql);
$max_score = Database :: result($rsQuiz, 0, 0);
//Disabling the exercise if we add it inside a LP
$exercise = new Exercise();
$exercise->read($id);
$exercise->disable();
$exercise->save();
} else {
$max_score = 100;
}
@ -531,7 +537,7 @@ class learnpath {
SET previous_item_id = " . $new_item_id . "
WHERE c_id = $course_id AND id = " . $next;
$res_update_next = Database::query($sql_update_next);
Database::query($sql_update_next);
// Update the item that should be before the new item.
$sql_update_previous = "
@ -539,7 +545,7 @@ class learnpath {
SET next_item_id = " . $new_item_id . "
WHERE c_id = $course_id AND id = " . $tmp_previous;
$res_update_previous = Database::query($sql_update_previous);
Database::query($sql_update_previous);
// Update all the items after the new item.
$sql_update_order = "
@ -552,7 +558,7 @@ class learnpath {
parent_item_id = " . $parent . " AND
display_order > " . $display_order;
$res_update_previous = Database::query($sql_update_order);
Database::query($sql_update_order);
// Update the item that should come after the new item.
$sql_update_ref = "UPDATE " . $tbl_lp_item . "

Loading…
Cancel
Save