Minor - format code + fixing PHP warnings.

1.9.x
Julio Montoya 10 years ago
parent 18f7281211
commit 600bb6a1fa
  1. 124
      main/exercice/exercise_reminder.php
  2. 16
      main/exercice/testcategory.class.php

@ -6,9 +6,7 @@
* @package chamilo.exercise
* @author Julio Montoya Armas switchable fill in blank option added
*/
/**
* INIT SECTION
*/
require_once 'exercise.class.php';
require_once 'question.class.php';
require_once 'answer.class.php';
@ -85,7 +83,7 @@ if (empty($exercise_stat_info) || empty($question_list)) {
}
$nameTools = get_lang('Exercice');
$interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
$interbreadcrumb[] = array("url" => "exercice.php?".api_get_cidreq(), "name" => get_lang('Exercices'));
if ($origin != 'learnpath') {
//so we are not in learnpath tool
@ -112,72 +110,67 @@ if ($time_control) {
echo Display::div('', array('id'=>'message'));
echo '<script>
lp_data = $.param({"learnpath_id": '.$learnpath_id.', "learnpath_item_id" : '.$learnpath_item_id.', "learnpath_item_view_id": '.$learnpath_item_view_id.'});
function final_submit() {
//Normal inputs
window.location = "exercise_result.php?origin='.$origin.'&exe_id='.$exe_id.'&" + lp_data;
}
function review_questions() {
var is_checked = 1;
$("input[type=checkbox]").each(function () {
if ($(this).attr("checked") == "checked") {
is_checked = 2;
return false;
}
});
if (is_checked == 1) {
$("#message").addClass("warning-message");
$("#message").html("'.addslashes(get_lang('SelectAQuestionToReview')).'");
}
window.location = "exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&reminder=2&origin='.$origin.'&" + lp_data;
}
function save_remind_item(obj, question_id) {
var action = "";
if ($(obj).is(\':checked\')) {
action = "add";
} else {
action = "delete";
}
$.ajax({
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=add_question_to_reminder",
data: "question_id="+question_id+"&exe_id='.$exe_id.'&action="+action,
success: function(return_value) {
},
});
}
</script>';
lp_data = $.param({"learnpath_id": '.$learnpath_id.', "learnpath_item_id" : '.$learnpath_item_id.', "learnpath_item_view_id": '.$learnpath_item_view_id.'});
$attempt_list = get_all_exercise_event_by_exe_id($exe_id);
function final_submit() {
//Normal inputs
window.location = "exercise_result.php?origin='.$origin.'&exe_id='.$exe_id.'&" + lp_data;
}
$remind_list = $exercise_stat_info['questions_to_check'];
$remind_list = explode(',', $remind_list);
function review_questions() {
var is_checked = 1;
$("input[type=checkbox]").each(function () {
if ($(this).attr("checked") == "checked") {
is_checked = 2;
return false;
}
});
if (is_checked == 1) {
$("#message").addClass("warning-message");
$("#message").html("'.addslashes(get_lang('SelectAQuestionToReview')).'");
}
window.location = "exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&reminder=2&origin='.$origin.'&" + lp_data;
}
function save_remind_item(obj, question_id) {
var action = "";
if ($(obj).is(\':checked\')) {
action = "add";
} else {
action = "delete";
}
$.ajax({
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=add_question_to_reminder",
data: "question_id="+question_id+"&exe_id='.$exe_id.'&action="+action,
success: function(return_value) {
}
});
}
</script>';
$attempt_list = get_all_exercise_event_by_exe_id($exe_id);
$remind_list = $exercise_stat_info['questions_to_check'];
$remind_list = explode(',', $remind_list);
$exercise_result = array();
foreach ($attempt_list as $question_id => $options) {
//echo $question_id.'<br />';
foreach($options as $item) {
$question_obj = Question::read($item['question_id']);
switch($question_obj->type) {
case FILL_IN_BLANKS:
$item['answer'] = $objExercise->fill_in_blank_answer_to_string($item['answer']);
break;
case HOT_SPOT:
//var_dump($item['answer']);
break;
}
if ($item['answer'] != '0' && !empty($item['answer'])) {
$exercise_result[] = $question_id;
break;
}
}
foreach ($options as $item) {
$question_obj = Question::read($item['question_id']);
switch ($question_obj->type) {
case FILL_IN_BLANKS:
$item['answer'] = $objExercise->fill_in_blank_answer_to_string($item['answer']);
break;
case HOT_SPOT:
break;
}
if ($item['answer'] != '0' && !empty($item['answer'])) {
$exercise_result[] = $question_id;
break;
}
}
}
echo Display::label(get_lang('QuestionWithNoAnswer'), 'warning');
echo '<div class="clear"></div><br />';
@ -192,7 +185,6 @@ foreach ($question_list as $questionId) {
// creates a temporary Question object
$objQuestionTmp = Question :: read($questionId);
// initialize question information
$quesId = $objQuestionTmp->selectId();
$check_id = 'remind_list['.$questionId.']';
@ -233,6 +225,6 @@ echo Display::div('', array('class'=>'clear'));
echo Display::div($exercise_actions, array('class'=>'form-actions'));
if ($origin != 'learnpath') {
//we are not in learnpath tool
// We are not in learnpath tool
Display::display_footer();
}

@ -386,9 +386,8 @@ class Testcategory
* tabres[24] = array of question id with category id = 24
* In this version, a question has 0 or 1 category
*/
public function getQuestionsByCat($in_exerciceId)
public static function getQuestionsByCat($in_exerciceId)
{
$tabres = array();
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTION_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$in_exerciceId = intval($in_exerciceId);
@ -401,20 +400,21 @@ class Testcategory
eq.c_id=qrc.c_id
ORDER BY category_id, question_id";
$res = Database::query($sql);
$list = array();
while ($data = Database::fetch_array($res)) {
if (!is_array($tabres[$data['category_id']])) {
$tabres[$data['category_id']] = array();
if (!isset($tabres[$data['category_id']])) {
$list[$data['category_id']] = array();
}
$tabres[$data['category_id']][] = $data['question_id'];
$list[$data['category_id']][] = $data['question_id'];
}
return $tabres;
return $list;
}
/**
* return a tab of $in_number random elements of $in_tab
*/
public function getNElementsFromArray($in_tab, $in_number)
public static function getNElementsFromArray($in_tab, $in_number)
{
$tabres = $in_tab;
shuffle($tabres);
@ -473,7 +473,7 @@ class Testcategory
* value is the array of question id of this category
* Sort question by Category
*/
public function sortTabByBracketLabel($in_tab)
public static function sortTabByBracketLabel($in_tab)
{
$tabResult = array();
$tabCatName = array(); // tab of category name

Loading…
Cancel
Save