Minor - format code

pull/2789/head
Julio Montoya 7 years ago
parent 0dc6ec0097
commit df87f77a6f
  1. 10
      main/exercise/TestCategory.php
  2. 75
      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
*/
public static function getCategoryNameForQuestion(
$questionId,
$courseId = 0
) {
public static function getCategoryNameForQuestion($questionId, $courseId = 0)
{
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
@ -399,9 +397,7 @@ class TestCategory
public static function getListOfCategoriesNameForTest($exerciseId, $grouped_by_category = true)
{
$result = [];
$categories = self::getListOfCategoriesIDForTest(
$exerciseId
);
$categories = self::getListOfCategoriesIDForTest($exerciseId);
foreach ($categories as $catInfo) {
$categoryId = $catInfo['id'];

@ -432,7 +432,10 @@ if ($exerciseId > 0) {
$from = '';
if (isset($courseCategoryId) && $courseCategoryId > 0) {
$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) {
$where .= ' AND level='.$exerciseLevel;
@ -466,7 +469,8 @@ if ($exerciseId > 0) {
$level_where = '';
$from = '';
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
crc.c_id = $selected_course AND
crc.category_id = $courseCategoryId";
@ -485,12 +489,13 @@ if ($exerciseId > 0) {
INNER JOIN $TBL_EXERCISE_QUESTION r
ON (q.c_id = r.c_id AND q.id = r.question_id)
INNER JOIN $TBL_EXERCISES ex
ON (ex.id = r.exercice_id AND ex.c_id = r.c_id )
ON (ex.id = r.exercice_id AND ex.c_id = r.c_id)
$from
WHERE
ex.c_id = '$selected_course' AND
ex.active = '-1'
$level_where $answer_where
$level_where
$answer_where
)
UNION
(
@ -501,7 +506,8 @@ if ($exerciseId > 0) {
WHERE
q.c_id = '$selected_course' AND
r.question_id is null
$level_where $answer_where
$level_where
$answer_where
)
UNION
(
@ -512,7 +518,8 @@ if ($exerciseId > 0) {
WHERE
r.c_id = '$selected_course' AND
(r.exercice_id = '-1' OR r.exercice_id = '0')
$level_where $answer_where
$level_where
$answer_where
)";
$result = Database::query($sql);
while ($row = Database::fetch_array($result, 'ASSOC')) {
@ -667,14 +674,14 @@ if ($fromExercise <= 0) {
// NOT IN A TEST - IN THE COURSE
if ($selected_course == api_get_course_int_id()) {
$actionLabel = get_lang('Modify');
$actionIcon1 = "edit";
$actionIcon2 = "delete";
$actionIcon1 = 'edit';
$actionIcon2 = 'delete';
// We are in the course, question title can be a link to the question edit page
$questionTagA = 1;
} else { // NOT IN A TEST - NOT IN THE COURSE
$actionLabel = get_lang('Reuse');
$actionIcon1 = get_lang('MustBeInATest');
$actionIcon2 = "";
$actionIcon2 = '';
// We are not in this course, to messy if we link to the question in another course
$questionTagA = 0;
}
@ -682,51 +689,52 @@ if ($fromExercise <= 0) {
// IN A TEST - IN THE COURSE
if ($selected_course == api_get_course_int_id()) {
$actionLabel = get_lang('Reuse');
$actionIcon1 = "add";
$actionIcon2 = "";
$actionIcon1 = 'add';
$actionIcon2 = '';
$questionTagA = 1;
} else {
// IN A TEST - NOT IN THE COURSE
$actionLabel = get_lang('Reuse');
$actionIcon1 = "clone";
$actionIcon2 = "";
$actionIcon1 = 'clone';
$actionIcon2 = '';
$questionTagA = 0;
}
}
// Display table
$header = [
[
get_lang('QuestionUpperCaseFirstLetter'),
false,
["style" => "text-align:center"],
['style' => 'text-align:center'],
'',
],
[
get_lang('Type'),
false,
["style" => "text-align:center"],
["style" => "text-align:center"],
['style' => 'text-align:center'],
['style' => 'text-align:center'],
'',
],
[
get_lang('QuestionCategory'),
false,
["style" => "text-align:center"],
["style" => "text-align:center"],
['style' => 'text-align:center'],
['style' => 'text-align:center'],
'',
],
[
get_lang('Difficulty'),
false,
["style" => "text-align:center"],
["style" => "text-align:center"],
['style' => 'text-align:center'],
['style' => 'text-align:center'],
'',
],
[
$actionLabel,
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)) {
foreach ($mainQuestionList as $question) {
/*if ($hideDoubles) {
if (in_array($question['question'], $questionAdded)) {
continue;
}
}
$questionAdded[$question['question']] = $question;*/
$row = [];
// This function checks if the question can be read
$question_type = get_question_type_for_question(
$selected_course,
$question['id']
);
$question_type = get_question_type_for_question($selected_course, $question['id']);
if (empty($question_type)) {
continue;
@ -779,7 +776,7 @@ if (is_array($mainQuestionList)) {
$answerType,
$session_id,
$exerciseId
)."&nbsp;".
).'&nbsp;'.
get_action_icon_for_question(
$actionIcon2,
$fromExercise,
@ -900,7 +897,6 @@ function get_action_icon_for_question(
$in_session_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";
switch ($in_action) {
case 'delete':
@ -931,7 +927,8 @@ function get_action_icon_for_question(
unset($myObjEx);
break;
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(
Display::return_icon('cd.png', get_lang('ReUseACopyInCurrentTest')),
$url
@ -968,9 +965,9 @@ function get_question_type_for_question($in_selectedcourse, $in_questionid)
*
* @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;
}

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

@ -3204,7 +3204,7 @@ EOT;
// only end is set
$time_conditions .= " (start_time IS NULL AND end_time <> '' AND end_time > '$now') OR ";
// 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 '?' " : '';

Loading…
Cancel
Save