Minor fixes from 1.10

skala
Julio Montoya 12 years ago
parent e6fad2876a
commit 2d2d1c008c
  1. 41
      main/exercice/exercise_submit.php
  2. 134
      main/exercice/question.class.php
  3. 4
      main/inc/ajax/model.ajax.php
  4. 2
      main/inc/lib/internationalization.lib.php
  5. 3
      main/inc/lib/sortable_table.class.php

@ -541,24 +541,17 @@ if ($question_count != 0) {
} else {
$sql_exe_result = ", exe_result = 0";
if ($debug) { error_log('12. exercise_time_control_is_valid is NOT valid then exe_result = 0 '); }
}
/*
//Clean incomplete - @todo why setting to blank the status?
$update_query = "UPDATE $stat_table SET status = '', exe_date = '".api_get_utc_datetime() ."' , orig_lp_item_view_id = '$learnpath_item_view_id' $sql_exe_result WHERE exe_id = ".$exe_id;
//if ($debug) { error_log('Updating track_e_exercises '.$update_query); }
Database::query($update_query);*/
}
}
if ($objExercise->review_answers) {
header('Location: exercise_reminder.php?'.$params);
exit;
} else {
header("Location: exercise_result.php?exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
}
}
} else {
if ($debug) { error_log('Redirecting to exercise_submit.php'); }
//header("Location: exercise_submit.php?exerciseId=$exerciseId");
exit;
}
}
@ -745,7 +738,7 @@ if (!empty($error)) {
$onsubmit = '';
$i = 0;
if (!strcmp($questionList[0], '') === 0) {
if (!empty($questionList)) {
foreach ($questionList as $questionId) {
$i++;
$objQuestionTmp = Question::read($questionId);
@ -774,7 +767,7 @@ if (!empty($error)) {
echo '<script>
$(function() {
$(function() {
//$(".exercise_save_now_button").hide();
$(".main_question").mouseover(function() {
//$(this).find(".exercise_save_now_button").show();
@ -800,7 +793,24 @@ if (!empty($error)) {
save_now(question_id_to_save, url);
}
function save_now(question_id, url_extra) {
function save_question_list(question_list) {
$.each(question_list, function(key, question_id) {
save_now(question_id, null, false);
});
var url = "";
if ('.$reminder.' == 1 ) {
url = "exercise_reminder.php?'.$params.'&num='.$current_question.'";
} else if ('.$reminder.' == 2 ) {
url = "exercise_submit.php?'.$params.'&num='.$current_question.'&remind_question_id='.$remind_question_id.'&reminder=2";
} else {
url = "exercise_submit.php?'.$params.'&num='.$current_question.'&remind_question_id='.$remind_question_id.'";
}
//$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL)).'");
window.location = url;
}
function save_now(question_id, url_extra) {
//1. Normal choice inputs
var my_choice = $(\'*[name*="choice[\'+question_id+\']"]\').serialize();
@ -855,6 +865,9 @@ if (!empty($error)) {
if (url_extra) {
url = url_extra;
}
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL)).'");
window.location = url;
}
},
@ -943,10 +956,6 @@ if (!empty($error)) {
$attempt_list = get_all_exercise_event_by_exe_id($exe_id);
}
if (!empty($attempt_list) && $current_question == 1) {
//Display::display_normal_message(get_lang('YouTriedToResolveThisExerciseEarlier'));
}
$remind_list = array();
if (isset($exercise_stat_info['questions_to_check']) && !empty($exercise_stat_info['questions_to_check'])) {
$remind_list = explode(',', $exercise_stat_info['questions_to_check']);

@ -294,6 +294,10 @@ abstract class Question
$this->question=$title;
}
function updateParentId($id) {
$this->parent_id = intval($id);
}
/**
* changes the question description
*
@ -314,7 +318,6 @@ abstract class Question
$this->weighting=$weighting;
}
/**
* @author - Hubert Borderiou 12-10-2011
* @param - array of category $in_category
@ -339,6 +342,40 @@ abstract class Question
$this->uncheckedMayScore=$in_positive;
}
/**
* Save category of a question
*
* A question can have n categories
* if category is empty, then question has no category then delete the category entry
*
* @param - int $in_positive
* @author - Julio Montoya - Adding multiple cat support
*/
function saveCategories($category_list) {
if (!empty($category_list)) {
$this->deleteCategory();
$TBL_QUESTION_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
// update or add category for a question
foreach ($category_list as $category_id) {
$category_id = intval($category_id);
$question_id = Database::escape_string($this->id);
$sql = "SELECT count(*) AS nb FROM $TBL_QUESTION_REL_CATEGORY WHERE category_id = $category_id AND question_id = $question_id AND c_id=".api_get_course_int_id();
$res = Database::query($sql);
$row = Database::fetch_array($res);
if ($row['nb'] > 0) {
//DO nothing
//$sql = "UPDATE $TBL_QUESTION_REL_CATEGORY SET category_id = $category_id WHERE question_id=$question_id AND c_id=".api_get_course_int_id();
//$res = Database::query($sql);
} else {
$sql = "INSERT INTO $TBL_QUESTION_REL_CATEGORY (c_id, question_id, category_id) VALUES (".api_get_course_int_id().", $question_id, $category_id)";
$res = Database::query($sql);
}
}
}
}
/**
* @author - Hubert Borderiou 12-10-2011
* @param - interger $in_positive
@ -377,7 +414,7 @@ abstract class Question
$TBL_QUESTION_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$question_id = Database::escape_string($this->id);
$sql = "DELETE FROM $TBL_QUESTION_REL_CATEGORY WHERE question_id=$question_id AND c_id=".api_get_course_int_id();
$res = Database::query($sql);
Database::query($sql);
}
@ -1203,13 +1240,25 @@ abstract class Question
$form->addElement('hidden','myid', intval($_REQUEST['myid']));
if (!isset($_GET['fromExercise'])) {
switch($answerType) {
case 1: $this->question = get_lang('DefaultUniqueQuestion'); break;
case 2: $this->question = get_lang('DefaultMultipleQuestion'); break;
case 3: $this->question = get_lang('DefaultFillBlankQuestion'); break;
case 4: $this->question = get_lang('DefaultMathingQuestion'); break;
case 5: $this->question = get_lang('DefaultOpenQuestion'); break;
case 9: $this->question = get_lang('DefaultMultipleQuestion'); break;
switch ($answerType) {
case 1:
$this->question = get_lang('DefaultUniqueQuestion');
break;
case 2:
$this->question = get_lang('DefaultMultipleQuestion');
break;
case 3:
$this->question = get_lang('DefaultFillBlankQuestion');
break;
case 4:
$this->question = get_lang('DefaultMathingQuestion');
break;
case 5:
$this->question = get_lang('DefaultOpenQuestion');
break;
case 9:
$this->question = get_lang('DefaultMultipleQuestion');
break;
}
}
@ -1461,5 +1510,72 @@ abstract class Question
eval('$explanation = get_lang('.$tabQuestionList[$type][1].'::$explanationLangVar);');
return array($img, $explanation);
}
/**
* Get course medias
* @param int course id
*/
static function get_course_medias($course_id, $start = 0, $limit = 100, $sidx = "question", $sord = "ASC", $where_condition = array()) {
$table_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
$default_where = array('c_id = ? AND parent_id = 0 AND type = ?' => array($course_id, MEDIA_QUESTION));
if (!empty($where_condition)) {
//$where_condition
}
$result = Database::select('*', $table_question,
array(
'limit' => " $start, $limit",
'where' => $default_where,
'order' => "$sidx $sord"));
return $result;
}
/**
* Get count course medias
* @param int course id
*/
static function get_count_course_medias($course_id) {
$table_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
$result = Database::select('count(*) as count', $table_question, array('where'=>array('c_id = ? AND parent_id = 0 AND type = ?' => array($course_id, MEDIA_QUESTION))),'first');
if ($result && isset($result['count'])) {
return $result['count'];
}
return 0;
}
static function prepare_course_media_select($course_id) {
$medias = self::get_course_medias($course_id);
$media_list = array();
$media_list[0] = get_lang('NoMedia');
if (!empty($medias)) {
foreach($medias as $media) {
$media_list[$media['id']] = empty($media['question']) ? get_lang('Untitled') : $media['question'];
}
}
return $media_list;
}
static function get_default_levels() {
$select_level = array (
1=>1,
2=>2,
3=>3,
4=>4,
5=>5
);
return $select_level;
}
function show_media_content() {
$html = null;
if ($this->parent_id != 0) {
$parent_question = Question::read($this->parent_id);
$html = $parent_question->show_media_content();
} else {
$html .= Display::page_subheader($this->selectTitle());
$html .= $this->selectDescription();
}
return $html;
}
}
endif;

@ -27,6 +27,10 @@ if (strpos(strtolower($sidx), 'desc') !== false) {
$sord = 'desc';
}
if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc';
}
if (!in_array($action, array(
'get_exercise_results',
'get_hotpotatoes_exercise_results',

@ -563,8 +563,10 @@ function _api_get_timezone() {
* Returns the given date as a DATETIME in UTC timezone. This function should be used before entering any date in the DB.
*
* @param mixed The date to be converted (can be a string supported by date() or a timestamp)
* @param bool if the date is not correct return null instead of the current date
* @return string The DATETIME in UTC to be inserted in the DB, or null if the format of the argument is not supported
*
* @author Julio Montoya - Adding the 2nd parameter
* @author Guillaume Viguier <guillaume.viguier@beeznest.com>
*/
function api_get_utc_datetime($time = null, $return_null_if_invalid_date = false) {

@ -96,6 +96,9 @@ class SortableTable extends HTML_Table {
* Activates the odd even rows
* **/
public $odd_even_rows_enabled = true;
public $use_jqgrid = false;
public $table_id = null;
public $headers = array();
/**
* Create a new SortableTable

Loading…
Cancel
Save