Minor - format code, fixing PHP warnings.

1.9.x
Julio Montoya 11 years ago
parent 895c635458
commit 51a76eefdd
  1. 26
      main/exercice/exercise.lib.php
  2. 72
      main/exercice/question_pool.php

@ -1,5 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Exercise library * Exercise library
* @todo convert this lib into a static class * @todo convert this lib into a static class
@ -941,7 +942,7 @@ function get_exercise_track_exercise_info($exe_id)
$exe_id = intval($exe_id); $exe_id = intval($exe_id);
$result = array(); $result = array();
if (!empty($exe_id)) { if (!empty($exe_id)) {
$sql_fb_type = "SELECT q.*, tee.* $sql = " SELECT q.*, tee.*
FROM $TBL_EXERCICES as q FROM $TBL_EXERCICES as q
INNER JOIN $TBL_TRACK_EXERCICES as tee INNER JOIN $TBL_TRACK_EXERCICES as tee
ON q.id=tee.exe_exo_id ON q.id=tee.exe_exo_id
@ -950,13 +951,13 @@ function get_exercise_track_exercise_info($exe_id)
WHERE tee.exe_id=$exe_id WHERE tee.exe_id=$exe_id
AND q.c_id=c.id"; AND q.c_id=c.id";
$res_fb_type = Database::query($sql_fb_type); $res_fb_type = Database::query($sql);
$result = Database::fetch_array($res_fb_type, 'ASSOC'); $result = Database::fetch_array($res_fb_type, 'ASSOC');
} }
return $result; return $result;
} }
/** /**
* Validates the time control key * Validates the time control key
*/ */
@ -965,7 +966,8 @@ function exercise_time_control_is_valid($exercise_id, $lp_id = 0 , $lp_item_id =
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$exercise_id = intval($exercise_id); $exercise_id = intval($exercise_id);
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$sql = "SELECT expired_time FROM $TBL_EXERCICES WHERE c_id = $course_id AND id = $exercise_id"; $sql = "SELECT expired_time FROM $TBL_EXERCICES
WHERE c_id = $course_id AND id = $exercise_id";
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC'); $row = Database::fetch_array($result, 'ASSOC');
if (!empty($row['expired_time'])) { if (!empty($row['expired_time'])) {
@ -1122,8 +1124,8 @@ function getLatestHotPotatoResult(
$exercisePath, $exercisePath,
$userId, $userId,
$courseId, $courseId,
$sessionId) $sessionId
{ ) {
$table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); $table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
$courseInfo = api_get_course_info_by_id($courseId); $courseInfo = api_get_course_info_by_id($courseId);
@ -1678,11 +1680,10 @@ function get_all_exercises(
$course_info = null, $course_info = null,
$session_id = 0, $session_id = 0,
$check_publication_dates = false, $check_publication_dates = false,
$search_exercise = '', $search = '',
$search_all_sessions = false, $search_all_sessions = false,
$active = 2 $active = 2
) { ) {
$TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
if (!empty($course_info) && !empty($course_info['real_id'])) { if (!empty($course_info) && !empty($course_info['real_id'])) {
@ -1703,8 +1704,8 @@ function get_all_exercises(
$time_conditions .= " (start_time = '0000-00-00 00:00:00' AND end_time = '0000-00-00 00:00:00')) "; // nothing is set $time_conditions .= " (start_time = '0000-00-00 00:00:00' AND end_time = '0000-00-00 00:00:00')) "; // nothing is set
} }
$needle_where = (!empty($search_exercise)) ? " AND title LIKE '?' " : ''; $needle_where = !empty($search) ? " AND title LIKE '?' " : '';
$needle = (!empty($search_exercise)) ? "%" . $search_exercise . "%" : ''; $needle = !empty($search) ? "%" . $search . "%" : '';
//Show courses by active status //Show courses by active status
$active_sql = ''; $active_sql = '';
@ -1733,8 +1734,11 @@ function get_all_exercises(
} }
} }
return Database::select('*',$TBL_EXERCICES, $conditions); $table = Database :: get_course_table(TABLE_QUIZ_TEST);
return Database::select('*', $table, $conditions);
} }
/** /**
* Get exercise information by id * Get exercise information by id
* @param int $exerciseId Exercise Id * @param int $exerciseId Exercise Id

@ -50,11 +50,6 @@ if (!isset($_GET['selected_course']) && !isset($_GET['exerciseId'])) {
$_course = api_get_course_info(); $_course = api_get_course_info();
// document path
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
// picture path
$picturePath = $documentPath.'/images';
if (empty($objExercise) && !empty($fromExercise)) { if (empty($objExercise) && !empty($fromExercise)) {
$objExercise = new Exercise(); $objExercise = new Exercise();
$objExercise->read($fromExercise); $objExercise->read($fromExercise);
@ -136,7 +131,7 @@ if ($is_allowedToEdit) {
// Adds the question ID represented by $recup into the list of questions for the current exercise // Adds the question ID represented by $recup into the list of questions for the current exercise
$objExercise->addToList($recup); $objExercise->addToList($recup);
Session::write('objExercise', $objExercise); Session::write('objExercise', $objExercise);
} else if( isset($_POST['recup']) && is_array($_POST['recup']) && $fromExercise) { } else if (isset($_POST['recup']) && is_array($_POST['recup']) && $fromExercise) {
$list_recup = $_POST['recup']; $list_recup = $_POST['recup'];
foreach ($list_recup as $course_id => $question_data) { foreach ($list_recup as $course_id => $question_data) {
@ -403,9 +398,10 @@ $question_list = Question::get_question_type_list();
$new_question_list = array(); $new_question_list = array();
$new_question_list['-1'] = get_lang('All'); $new_question_list['-1'] = get_lang('All');
$objExercise = new Exercise(); if (!empty($_course)) {
$objExercise->read($fromExercise); $objExercise = new Exercise();
foreach ($question_list as $key=>$item) { $objExercise->read($fromExercise);
foreach ($question_list as $key => $item) {
if ($objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_DIRECT) { if ($objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (!in_array($key, array(HOT_SPOT_DELINEATION, UNIQUE_ANSWER))) { if (!in_array($key, array(HOT_SPOT_DELINEATION, UNIQUE_ANSWER))) {
continue; continue;
@ -417,8 +413,8 @@ foreach ($question_list as $key=>$item) {
} }
$new_question_list[$key] = get_lang($item[1]); $new_question_list[$key] = get_lang($item[1]);
} }
}
} }
// Answer type list // Answer type list
$select_answer_html = Display::select( $select_answer_html = Display::select(
'answerType', 'answerType',
@ -439,7 +435,7 @@ echo "<input type='hidden' id='exercice_id_changed' name='exercice_id_changed' v
<form method="post" action="<?php echo $url.'?'.api_get_cidreq().'&fromExercise='.$fromExercise; ?>" > <form method="post" action="<?php echo $url.'?'.api_get_cidreq().'&fromExercise='.$fromExercise; ?>" >
<?php <?php
echo '<input type="hidden" name="course_id" value="'.$selected_course.'">'; echo '<input type="hidden" name="course_id" value="'.$selected_course.'">';
$main_question_list = array(); $mainQuestionList = array();
// if we have selected an exercise in the list-box 'Filter' // if we have selected an exercise in the list-box 'Filter'
@ -475,7 +471,7 @@ if ($exerciseId > 0) {
$result = Database::query($sql); $result = Database::query($sql);
while($row = Database::fetch_array($result, 'ASSOC')) { while($row = Database::fetch_array($result, 'ASSOC')) {
$main_question_list[] = $row; $mainQuestionList[] = $row;
} }
} elseif ($exerciseId == -1) { } elseif ($exerciseId == -1) {
// If we have selected the option 'Orphan questions' in the list-box 'Filter' // If we have selected the option 'Orphan questions' in the list-box 'Filter'
@ -532,7 +528,7 @@ if ($exerciseId > 0) {
)"; )";
$result = Database::query($sql); $result = Database::query($sql);
while($row = Database::fetch_array($result, 'ASSOC')) { while($row = Database::fetch_array($result, 'ASSOC')) {
$main_question_list[] = $row; $mainQuestionList[] = $row;
} }
} else { } else {
// All tests for selected course // All tests for selected course
@ -555,7 +551,7 @@ if ($exerciseId > 0) {
} }
if (!empty($session_id) && $session_id != '-1') { if (!empty($session_id) && $session_id != '-1') {
$main_question_list = array(); $mainQuestionList = array();
if (!empty($course_list)) { if (!empty($course_list)) {
foreach ($course_list as $course_item) { foreach ($course_list as $course_item) {
$courseItemId = $course_item['real_id']; $courseItemId = $course_item['real_id'];
@ -565,6 +561,7 @@ if ($exerciseId > 0) {
continue; continue;
} }
} }
$exerciseList = get_all_exercises($course_item, $session_id); $exerciseList = get_all_exercises($course_item, $session_id);
if (!empty($exerciseList)) { if (!empty($exerciseList)) {
@ -603,7 +600,9 @@ if ($exerciseId > 0) {
continue; continue;
} }
if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) { if (!empty($objExercise) &&
$objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT
) {
if ($question_obj->type == HOT_SPOT_DELINEATION) { if ($question_obj->type == HOT_SPOT_DELINEATION) {
continue; continue;
} }
@ -615,9 +614,10 @@ if ($exerciseId > 0) {
'type' => $question_obj->type, 'type' => $question_obj->type,
'level' => $question_obj->level, 'level' => $question_obj->level,
'exercise_id' => $exercise['id'], 'exercise_id' => $exercise['id'],
'exercise_name' => $exercise['title'],
'course_id' => $courseItemId, 'course_id' => $courseItemId,
); );
$main_question_list[] = $question_row; $mainQuestionList[] = $question_row;
} }
} }
} }
@ -626,7 +626,6 @@ if ($exerciseId > 0) {
} }
} }
} else { } else {
if ($session_id == -1 or empty($session_id)) { if ($session_id == -1 or empty($session_id)) {
$session_id = 0; $session_id = 0;
} }
@ -648,14 +647,14 @@ if ($exerciseId > 0) {
ORDER BY session_id ASC"; ORDER BY session_id ASC";
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result, 'ASSOC')) { while ($row = Database::fetch_array($result, 'ASSOC')) {
$main_question_list[] = $row; $mainQuestionList[] = $row;
} }
} }
// forces the value to 0 // forces the value to 0
$exerciseId=0; $exerciseId = 0;
} }
$nbrQuestions = count($main_question_list); $nbrQuestions = count($mainQuestionList);
// build the line of the array to display questions // build the line of the array to display questions
// Actions are different if you launch the question_pool page // Actions are different if you launch the question_pool page
@ -715,38 +714,41 @@ $header = array(
); );
$data = array(); $data = array();
if (is_array($main_question_list)) {
foreach ($main_question_list as $tabQuestion) { if (is_array($mainQuestionList)) {
foreach ($mainQuestionList as $question) {
$row = array(); $row = array();
// This function checks if the question can be read // This function checks if the question can be read
$question_type = get_question_type_for_question( $question_type = get_question_type_for_question(
$selected_course, $selected_course,
$tabQuestion['id'] $question['id']
); );
if (empty($question_type)) { if (empty($question_type)) {
continue; continue;
} }
$sessionId = isset($tabQuestion['session_id']) ? $tabQuestion['session_id'] : null; $sessionId = isset($question['session_id']) ? $question['session_id'] : null;
//$exerciseName = isset($question['exercise_name']) ? '<br />('.$question['exercise_id'].') ' : null;
$row[] = get_a_tag_for_question( $row[] = get_a_tag_for_question(
$questionTagA, $questionTagA,
$fromExercise, $fromExercise,
$tabQuestion['id'], $question['id'],
$tabQuestion['type'], $question['type'],
$tabQuestion['question'], $question['question'],
$sessionId $sessionId
); );
$row[] = $question_type; $row[] = $question_type;
$row[] = get_question_categorie_for_question($selected_course, $tabQuestion['id']); $row[] = get_question_categorie_for_question($selected_course, $question['id']);
$row[] = $tabQuestion['level']; $row[] = $question['level'];
$row[] = get_action_icon_for_question( $row[] = get_action_icon_for_question(
$actionIcon1, $actionIcon1,
$fromExercise, $fromExercise,
$tabQuestion['id'], $question['id'],
$tabQuestion['type'], $question['type'],
$tabQuestion['question'], $question['question'],
$selected_course, $selected_course,
$courseCategoryId, $courseCategoryId,
$exerciseLevel, $exerciseLevel,
@ -758,9 +760,9 @@ if (is_array($main_question_list)) {
get_action_icon_for_question( get_action_icon_for_question(
$actionIcon2, $actionIcon2,
$fromExercise, $fromExercise,
$tabQuestion['id'], $question['id'],
$tabQuestion['type'], $question['type'],
$tabQuestion['question'], $question['question'],
$selected_course, $selected_course,
$courseCategoryId, $courseCategoryId,
$exerciseLevel, $exerciseLevel,

Loading…
Cancel
Save