Adding commenting code to manage exercise order see BT#5222

skala
Julio Montoya 13 years ago
parent f6021507ac
commit 8dd6df1d9d
  1. 51
      main/exercice/exercice.php
  2. 15
      main/exercice/exercise.class.php
  3. 5
      main/exercice/question.class.php
  4. 22
      main/inc/ajax/exercise.ajax.php
  5. 11
      main/inc/lib/database.constants.inc.php

@ -162,7 +162,23 @@ $htmlHeadXtra[] = '<script>
hide: true, //
});
});*/
});
/*
$(".data_table tbody").sortable({
cursor: "move", // works?
update: function(event, ui) {
var order = $(this).sortable("serialize") + "&a=update_exercise_list_order";
$.get("'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php", order, function(reponse) {
$("#message").html(reponse);
});
},
axis: "y",
placeholder: "ui-state-highlight", //defines the yellow highlight
handle: ".moved", //only the class "moved"
});*/
});
</script>';
if ($origin != 'learnpath') {
@ -174,7 +190,6 @@ if ($origin != 'learnpath') {
}
}
} else {
//echo '<link rel="stylesheet" type="text/css" href="' . api_get_path(WEB_CODE_PATH) . 'css/default.css"/>';
Display :: display_reduced_header();
}
@ -399,8 +414,20 @@ $online_icon = Display::return_icon('online.png', get_lang('Visible'), array('wi
$offline_icon = Display::return_icon('offline.png', get_lang('Invisible'), array('width' => '12px'));
$exercise_list = array();
$exercise_obj = new Exercise();
//$list_ordered = $exercise_obj->get_exercise_list_ordered();
$list_ordered = null;
while ($row = Database :: fetch_array($result, 'ASSOC')) {
$exercise_list[] = $row;
$exercise_list[$row['id']] = $row;
}
if (isset($list_ordered) && !empty($list_ordered)) {
$new_question_list = array();
foreach ($list_ordered as $exercise_id) {
$new_question_list[] = $exercise_list[$exercise_id];
}
$exercise_list = $new_question_list;
}
echo '<table class="'.Display::return_default_table_class().'">';
@ -516,16 +543,20 @@ if (!empty($exercise_list)) {
$title = $cut_title;
}
$count = intval(count_exercise_result_not_validated($my_exercise_id, $course_code, $session_id));
$count_exercise_not_validated = intval(count_exercise_result_not_validated($my_exercise_id, $course_code, $session_id));
//$move = Display::return_icon('all_directions.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;'));
$move = null;
$class_tip = '';
if (!empty($count)) {
$results_text = $count == 1 ? get_lang('ResultNotRevised') : get_lang('ResultsNotRevised');
$title .= '<span class="exercise_tooltip" style="display: none;">'.$count.' '.$results_text.' </span>';
if (!empty($count_exercise_not_validated)) {
$results_text = $count_exercise_not_validated == 1 ? get_lang('ResultNotRevised') : get_lang('ResultsNotRevised');
$title .= '<span class="exercise_tooltip" style="display: none;">'.$count_exercise_not_validated.' '.$results_text.' </span>';
$class_tip = 'link_tooltip';
}
$url = '<a '.$alt_title.' class="'.$class_tip.'" id="tooltip_'.$row['id'].'" href="overview.php?'.api_get_cidreq().$myorigin.$mylpid.$mylpitemid.'&exerciseId='.$row['id'].'"><img src="../img/quiz.gif" /> '.$title.' </a>';
//$class_tip = 'exercise_link';
$url = $move.'<a '.$alt_title.' class="'.$class_tip.'" id="tooltip_'.$row['id'].'" href="overview.php?'.api_get_cidreq().$myorigin.$mylpid.$mylpitemid.'&exerciseId='.$row['id'].'"><img src="../img/quiz.gif" /> '.$title.' </a>';
$item = Display::tag('td', $url.' '.$session_img.$lp_blocked);
@ -740,7 +771,7 @@ if (!empty($exercise_list)) {
if ($is_allowedToEdit) {
$item .= Display::tag('td', $actions, array('class' => 'td_actions'));
}
echo Display::tag('tr', $item, array('class' => $class));
echo Display::tag('tr', $item, array('id' => 'exercise_list_'.$my_exercise_id, 'class' => $class));
$count++;
} // end foreach()

@ -3689,5 +3689,20 @@ class Exercise {
$html .= '<div id="exercise_clock_warning" class="well count_down"></div>';
return $html;
}
function get_exercise_list_ordered() {
$table_exercise_order = Database::get_course_table(TABLE_QUIZ_ORDER);
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
$sql = "SELECT exercise_id, exercise_order FROM $table_exercise_order WHERE c_id = $course_id AND session_id = $session_id ORDER BY exercise_order";
$result = Database::query($sql);
$list = array();
if (Database::num_rows($result)) {
while($row = Database::fetch_array($result, 'ASSOC')) {
$list[$row['exercise_order']] = $row['exercise_id'];
}
}
return $list;
}
}
endif;

@ -143,7 +143,7 @@ abstract class Question
// if the question has been found
if ($object = Database::fetch_object($result)) {
$objQuestion = Question::getInstance($object->type);
$objQuestion = Question::getInstance($object->type);
if (!empty($objQuestion)) {
$objQuestion->id = $id;
@ -417,7 +417,6 @@ abstract class Question
Database::query($sql);
}
/**
* changes the question position
*
@ -946,7 +945,7 @@ abstract class Question
* @return - boolean - true if removed, otherwise false
*/
function removeFromList($exerciseId) {
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$id = $this->id;

@ -139,9 +139,27 @@ switch ($action) {
}
echo json_encode($response);
break;
case 'update_exercise_list_order':
$session_id = api_get_session_id();
if (api_is_allowed_to_edit(null, true)) {
$new_list = $_REQUEST['exercise_list'];
$table = Database::get_course_table(TABLE_QUIZ_ORDER);
$counter = 1;
//Drop all
Database::query("DELETE FROM $table WHERE session_id = $session_id AND c_id = $course_id");
//Insert alll
foreach ($new_list as $new_order_id) {
/*Database::update($table, array('exercise_order' => $counter),
array('session_id = ? AND exercise_id = ? AND c_id = ? '=> array($session_id, intval($new_order_id), $course_id)));*/
Database::insert($table, array('exercise_order' => $counter, 'session_id' => $session_id, 'exercise_id' => intval($new_order_id), 'c_id' => $course_id));
$counter++;
}
Display::display_confirmation_message(get_lang('Saved'));
}
break;
case 'update_question_order':
if (api_is_allowed_to_edit(null, true)) {
$new_question_list = $_POST['question_id_list'];
$new_question_list = $_POST['question_id_list'];
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$counter = 1;
foreach ($new_question_list as $new_order_id) {
@ -313,7 +331,7 @@ switch ($action) {
if ($objQuestionTmp->type == HOT_SPOT) {
delete_attempt_hotspot($exe_id, api_get_user_id() , api_get_course_id(), $my_question_id);
}
if (isset($attempt_list[$my_question_id]) && isset($attempt_list[$my_question_id]['marks'])) {
$total_score -= $attempt_list[$my_question_id]['marks'];
}

@ -2,16 +2,16 @@
/* For licensing terms, see /license.txt */
/**
* This is the database constants definition for Chamilo
* This file is called by database.lib.php and database.mysqli.lib.php
*
* This file is called by database.lib.php and database.mysqli.lib.php
*
* @todo the table constants have all to start with TABLE_
* This is because of the analogy with the tool constants TOOL_
*
* @package chamilo.library
* @package chamilo.library
*/
/**
* CONSTANTS
* CONSTANTS
*/
//See #3910 defines the default prefix for the single course database
@ -113,7 +113,7 @@ define('TABLE_MAIN_LEGAL', 'legal');
// Dashboard blocks plugin
define('TABLE_MAIN_BLOCK', 'block');
// Statistic database tables
// Statistic database tables
define('TABLE_STATISTIC_TRACK_E_LASTACCESS', 'track_e_lastaccess');
define('TABLE_STATISTIC_TRACK_E_ACCESS', 'track_e_access');
define('TABLE_STATISTIC_TRACK_E_LOGIN', 'track_e_login');
@ -193,6 +193,7 @@ define('TABLE_DROPBOX_PERSON', 'dropbox_person');
// Course quiz (or test, or exercice) tables
define('TABLE_QUIZ_QUESTION', 'quiz_question');
define('TABLE_QUIZ_TEST', 'quiz');
define('TABLE_QUIZ_ORDER', 'quiz_order');
define('TABLE_QUIZ_ANSWER', 'quiz_answer');
define('TABLE_QUIZ_TEST_QUESTION', 'quiz_rel_question');
define('TABLE_QUIZ_QUESTION_OPTION', 'quiz_question_option');

Loading…
Cancel
Save