Minor - format code

pull/2789/head
Julio Montoya 7 years ago
parent 0dc6ec0097
commit df87f77a6f
  1. 10
      main/exercise/TestCategory.php
  2. 73
      main/exercise/question_pool.php
  3. 1
      main/inc/ajax/model.ajax.php
  4. 2
      main/inc/lib/exercise.lib.php

@ -305,10 +305,8 @@ class TestCategory
* *
* @return string * @return string
*/ */
public static function getCategoryNameForQuestion( public static function getCategoryNameForQuestion($questionId, $courseId = 0)
$questionId, {
$courseId = 0
) {
if (empty($courseId)) { if (empty($courseId)) {
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
} }
@ -399,9 +397,7 @@ class TestCategory
public static function getListOfCategoriesNameForTest($exerciseId, $grouped_by_category = true) public static function getListOfCategoriesNameForTest($exerciseId, $grouped_by_category = true)
{ {
$result = []; $result = [];
$categories = self::getListOfCategoriesIDForTest( $categories = self::getListOfCategoriesIDForTest($exerciseId);
$exerciseId
);
foreach ($categories as $catInfo) { foreach ($categories as $catInfo) {
$categoryId = $catInfo['id']; $categoryId = $catInfo['id'];

@ -432,7 +432,10 @@ if ($exerciseId > 0) {
$from = ''; $from = '';
if (isset($courseCategoryId) && $courseCategoryId > 0) { if (isset($courseCategoryId) && $courseCategoryId > 0) {
$from = ", $TBL_COURSE_REL_CATEGORY crc "; $from = ", $TBL_COURSE_REL_CATEGORY crc ";
$where .= " AND crc.c_id=$selected_course AND crc.question_id=qu.id AND crc.category_id=$courseCategoryId"; $where .= " AND
crc.c_id = $selected_course AND
crc.question_id = qu.id AND
crc.category_id = $courseCategoryId";
} }
if (isset($exerciseLevel) && $exerciseLevel != -1) { if (isset($exerciseLevel) && $exerciseLevel != -1) {
$where .= ' AND level='.$exerciseLevel; $where .= ' AND level='.$exerciseLevel;
@ -466,7 +469,8 @@ if ($exerciseId > 0) {
$level_where = ''; $level_where = '';
$from = ''; $from = '';
if (isset($courseCategoryId) && $courseCategoryId > 0) { if (isset($courseCategoryId) && $courseCategoryId > 0) {
$from = " INNER JOIN $TBL_COURSE_REL_CATEGORY crc ON crc.question_id=q.id AND crc.c_id= q.c_id "; $from = " INNER JOIN $TBL_COURSE_REL_CATEGORY crc
ON crc.question_id = q.id AND crc.c_id = q.c_id ";
$level_where .= " AND $level_where .= " AND
crc.c_id = $selected_course AND crc.c_id = $selected_course AND
crc.category_id = $courseCategoryId"; crc.category_id = $courseCategoryId";
@ -490,7 +494,8 @@ if ($exerciseId > 0) {
WHERE WHERE
ex.c_id = '$selected_course' AND ex.c_id = '$selected_course' AND
ex.active = '-1' ex.active = '-1'
$level_where $answer_where $level_where
$answer_where
) )
UNION UNION
( (
@ -501,7 +506,8 @@ if ($exerciseId > 0) {
WHERE WHERE
q.c_id = '$selected_course' AND q.c_id = '$selected_course' AND
r.question_id is null r.question_id is null
$level_where $answer_where $level_where
$answer_where
) )
UNION UNION
( (
@ -512,7 +518,8 @@ if ($exerciseId > 0) {
WHERE WHERE
r.c_id = '$selected_course' AND r.c_id = '$selected_course' AND
(r.exercice_id = '-1' OR r.exercice_id = '0') (r.exercice_id = '-1' OR r.exercice_id = '0')
$level_where $answer_where $level_where
$answer_where
)"; )";
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result, 'ASSOC')) { while ($row = Database::fetch_array($result, 'ASSOC')) {
@ -667,14 +674,14 @@ if ($fromExercise <= 0) {
// NOT IN A TEST - IN THE COURSE // NOT IN A TEST - IN THE COURSE
if ($selected_course == api_get_course_int_id()) { if ($selected_course == api_get_course_int_id()) {
$actionLabel = get_lang('Modify'); $actionLabel = get_lang('Modify');
$actionIcon1 = "edit"; $actionIcon1 = 'edit';
$actionIcon2 = "delete"; $actionIcon2 = 'delete';
// We are in the course, question title can be a link to the question edit page // We are in the course, question title can be a link to the question edit page
$questionTagA = 1; $questionTagA = 1;
} else { // NOT IN A TEST - NOT IN THE COURSE } else { // NOT IN A TEST - NOT IN THE COURSE
$actionLabel = get_lang('Reuse'); $actionLabel = get_lang('Reuse');
$actionIcon1 = get_lang('MustBeInATest'); $actionIcon1 = get_lang('MustBeInATest');
$actionIcon2 = ""; $actionIcon2 = '';
// We are not in this course, to messy if we link to the question in another course // We are not in this course, to messy if we link to the question in another course
$questionTagA = 0; $questionTagA = 0;
} }
@ -682,51 +689,52 @@ if ($fromExercise <= 0) {
// IN A TEST - IN THE COURSE // IN A TEST - IN THE COURSE
if ($selected_course == api_get_course_int_id()) { if ($selected_course == api_get_course_int_id()) {
$actionLabel = get_lang('Reuse'); $actionLabel = get_lang('Reuse');
$actionIcon1 = "add"; $actionIcon1 = 'add';
$actionIcon2 = ""; $actionIcon2 = '';
$questionTagA = 1; $questionTagA = 1;
} else { } else {
// IN A TEST - NOT IN THE COURSE // IN A TEST - NOT IN THE COURSE
$actionLabel = get_lang('Reuse'); $actionLabel = get_lang('Reuse');
$actionIcon1 = "clone"; $actionIcon1 = 'clone';
$actionIcon2 = ""; $actionIcon2 = '';
$questionTagA = 0; $questionTagA = 0;
} }
} }
// Display table // Display table
$header = [ $header = [
[ [
get_lang('QuestionUpperCaseFirstLetter'), get_lang('QuestionUpperCaseFirstLetter'),
false, false,
["style" => "text-align:center"], ['style' => 'text-align:center'],
'', '',
], ],
[ [
get_lang('Type'), get_lang('Type'),
false, false,
["style" => "text-align:center"], ['style' => 'text-align:center'],
["style" => "text-align:center"], ['style' => 'text-align:center'],
'', '',
], ],
[ [
get_lang('QuestionCategory'), get_lang('QuestionCategory'),
false, false,
["style" => "text-align:center"], ['style' => 'text-align:center'],
["style" => "text-align:center"], ['style' => 'text-align:center'],
'', '',
], ],
[ [
get_lang('Difficulty'), get_lang('Difficulty'),
false, false,
["style" => "text-align:center"], ['style' => 'text-align:center'],
["style" => "text-align:center"], ['style' => 'text-align:center'],
'', '',
], ],
[ [
$actionLabel, $actionLabel,
false, false,
["style" => "text-align:center"], ['style' => 'text-align:center'],
["style" => "text-align:center"], ['style' => 'text-align:center'],
'', '',
], ],
]; ];
@ -735,20 +743,9 @@ $data = [];
if (is_array($mainQuestionList)) { if (is_array($mainQuestionList)) {
foreach ($mainQuestionList as $question) { foreach ($mainQuestionList as $question) {
/*if ($hideDoubles) {
if (in_array($question['question'], $questionAdded)) {
continue;
}
}
$questionAdded[$question['question']] = $question;*/
$row = []; $row = [];
// 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, $question['id']);
$selected_course,
$question['id']
);
if (empty($question_type)) { if (empty($question_type)) {
continue; continue;
@ -779,7 +776,7 @@ if (is_array($mainQuestionList)) {
$answerType, $answerType,
$session_id, $session_id,
$exerciseId $exerciseId
)."&nbsp;". ).'&nbsp;'.
get_action_icon_for_question( get_action_icon_for_question(
$actionIcon2, $actionIcon2,
$fromExercise, $fromExercise,
@ -900,7 +897,6 @@ function get_action_icon_for_question(
$in_session_id, $in_session_id,
$in_exercise_id $in_exercise_id
) { ) {
$res = "";
$getParams = "&selected_course=$in_selected_course&courseCategoryId=$in_courseCategoryId&exerciseId=$in_exercise_id&exerciseLevel=$in_exerciseLevel&answerType=$in_answerType&session_id=$in_session_id"; $getParams = "&selected_course=$in_selected_course&courseCategoryId=$in_courseCategoryId&exerciseId=$in_exercise_id&exerciseLevel=$in_exerciseLevel&answerType=$in_answerType&session_id=$in_session_id";
switch ($in_action) { switch ($in_action) {
case 'delete': case 'delete':
@ -931,7 +927,8 @@ function get_action_icon_for_question(
unset($myObjEx); unset($myObjEx);
break; break;
case 'clone': case 'clone':
$url = api_get_self()."?".api_get_cidreq().$getParams."&question_copy=$in_questionid&course_id=$in_selected_course&fromExercise=$from_exercise"; $url = api_get_self()."?".api_get_cidreq().$getParams.
"&question_copy=$in_questionid&course_id=$in_selected_course&fromExercise=$from_exercise";
$res = Display::url( $res = Display::url(
Display::return_icon('cd.png', get_lang('ReUseACopyInCurrentTest')), Display::return_icon('cd.png', get_lang('ReUseACopyInCurrentTest')),
$url $url
@ -968,9 +965,9 @@ function get_question_type_for_question($in_selectedcourse, $in_questionid)
* *
* @author hubert.borderiou 13-10-2011 * @author hubert.borderiou 13-10-2011
*/ */
function get_question_categorie_for_question($in_courseid, $in_questionid) function get_question_categorie_for_question($courseId, $questionId)
{ {
$cat = TestCategory::getCategoryNameForQuestion($in_questionid, $in_courseid); $cat = TestCategory::getCategoryNameForQuestion($questionId, $courseId);
return $cat; return $cat;
} }

@ -1332,7 +1332,6 @@ switch ($action) {
$overwriteColumnHeaderExport['only_score'] = get_lang('Score').' - '.get_lang('ScoreNote'); $overwriteColumnHeaderExport['only_score'] = get_lang('Score').' - '.get_lang('ScoreNote');
$overwriteColumnHeaderExport['total'] = get_lang('Score').' - '.get_lang('ScoreTest'); $overwriteColumnHeaderExport['total'] = get_lang('Score').' - '.get_lang('ScoreTest');
} }
$categoryList = TestCategory::getListOfCategoriesIDForTest($exerciseId, $courseId); $categoryList = TestCategory::getListOfCategoriesIDForTest($exerciseId, $courseId);
if (!empty($categoryList)) { if (!empty($categoryList)) {

@ -3204,7 +3204,7 @@ EOT;
// only end is set // only end is set
$time_conditions .= " (start_time IS NULL AND end_time <> '' AND end_time > '$now') OR "; $time_conditions .= " (start_time IS NULL AND end_time <> '' AND end_time > '$now') OR ";
// nothing is set // nothing is set
$time_conditions .= " (start_time IS NULL AND end_time IS NULL)) "; $time_conditions .= ' (start_time IS NULL AND end_time IS NULL)) ';
} }
$needle_where = !empty($search) ? " AND title LIKE '?' " : ''; $needle_where = !empty($search) ? " AND title LIKE '?' " : '';

Loading…
Cancel
Save