Internal - Fix queries, fix exercise creation

pull/3543/head
Julio Montoya 5 years ago
parent 4f7f5a7e2a
commit 221f68727e
  1. 2
      public/main/exercise/TestCategory.php
  2. 3
      public/main/exercise/answer.class.php
  3. 93
      public/main/exercise/exercise.class.php
  4. 2
      public/main/exercise/question.class.php
  5. 2
      public/main/exercise/unique_answer.class.php
  6. 2
      public/main/gradebook/gradebook_add_cat.php
  7. 2
      public/main/inc/lib/exercise.lib.php
  8. 2
      public/main/inc/lib/pear/HTML/QuickForm/radio.php

@ -453,7 +453,7 @@ class TestCategory
$table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
$sql = "SELECT title
FROM $table
WHERE id = $categoryId AND c_id = $courseId";
WHERE iid = $categoryId ";
$res = Database::query($sql);
$data = Database::fetch_array($res);
$result = '';

@ -136,7 +136,6 @@ class Answer
// while a record is found
while ($object = Database::fetch_object($result)) {
$this->id[$i] = $object->id;
$this->answer[$i] = $object->answer;
$this->correct[$i] = $object->correct;
$this->comment[$i] = $object->comment;
@ -145,7 +144,7 @@ class Answer
$this->hotspot_coordinates[$i] = $object->hotspot_coordinates;
$this->hotspot_type[$i] = $object->hotspot_type;
$this->destination[$i] = $object->destination;
$this->autoId[$i] = $object->id_auto;
//$this->autoId[$i] = $object->id_auto;
$this->iid[$i] = $object->iid;
$i++;
}

@ -2353,7 +2353,7 @@ class Exercise
'radio',
'exerciseFeedbackType',
null,
get_lang('NoFeedback'),
get_lang('Exam (no feedback)'),
EXERCISE_FEEDBACK_TYPE_EXAM,
[
'id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_EXAM,
@ -2373,16 +2373,16 @@ class Exercise
}
// Can't convert a question from one feedback to another
$direct = $form->createElement(
'radio',
'exerciseFeedbackType',
null,
get_lang('DirectFeedback'),
EXERCISE_FEEDBACK_TYPE_DIRECT,
[
'id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_DIRECT,
'onclick' => 'check_direct_feedback()',
]
);
'radio',
'exerciseFeedbackType',
null,
get_lang('Adaptative test with immediate feedback'),
EXERCISE_FEEDBACK_TYPE_DIRECT,
[
'id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_DIRECT,
'onclick' => 'check_direct_feedback()',
]
);
if ($freeze) {
$direct->freeze();
@ -2396,7 +2396,7 @@ class Exercise
'radio',
'exerciseFeedbackType',
null,
get_lang('ExerciseDirectPopUp'),
get_lang('Direct feedback as pop-up'),
EXERCISE_FEEDBACK_TYPE_POPUP,
['id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_POPUP, 'onclick' => 'check_direct_feedback()']
);
@ -2405,8 +2405,8 @@ class Exercise
$feedback,
null,
[
get_lang('FeedbackType'),
get_lang('FeedbackDisplayOptions'),
get_lang('Feedback'),
get_lang('How should we show the feedback/comment for each question? This option defines how it will be shown to the learner when taking the test. We recommend you try different options by editing your test options before having learners take it.'),
]
);
@ -3023,11 +3023,11 @@ class Exercise
$label = get_lang('ReviewQuestions');
$class = 'btn btn-success';
} else {
$label = get_lang('EndTest');
$label = get_lang('End test');
$class = 'btn btn-warning';
}
} else {
$label = get_lang('NextQuestion');
$label = get_lang('Next question');
$class = 'btn btn-primary';
}
// used to select it with jquery
@ -3062,35 +3062,35 @@ class Exercise
if ($showPreview && 0 === $this->getPreventBackwards()) {
$buttonList[] = Display::button(
'previous_question_and_save',
get_lang('Previous question'),
[
'type' => 'button',
'class' => 'btn btn-default',
'data-prev' => $prev_question,
'data-question' => $question_id,
]
);
'previous_question_and_save',
get_lang('Previous question'),
[
'type' => 'button',
'class' => 'btn btn-default',
'data-prev' => $prev_question,
'data-question' => $question_id,
]
);
}
}
// Next question
if (!empty($questions_in_media)) {
$buttonList[] = Display::button(
'save_question_list',
$label,
[
'type' => 'button',
'class' => $class,
'data-list' => implode(',', $questions_in_media),
]
);
'save_question_list',
$label,
[
'type' => 'button',
'class' => $class,
'data-list' => implode(',', $questions_in_media),
]
);
} else {
$buttonList[] = Display::button(
'save_now',
$label,
['type' => 'button', 'class' => $class, 'data-question' => $question_id]
);
'save_now',
$label,
['type' => 'button', 'class' => $class, 'data-question' => $question_id]
);
}
$buttonList[] = '<span id="save_for_now_'.$question_id.'" class="exercise_save_mini_message"></span>';
@ -3419,14 +3419,14 @@ class Exercise
$user_answer = '';
// Get answer list for matching
$sql = "SELECT id_auto, id, answer
$sql = "SELECT iid, answer
FROM $table_ans
WHERE c_id = $course_id AND question_id = $questionId";
$res_answer = Database::query($sql);
$answerMatching = [];
while ($real_answer = Database::fetch_array($res_answer)) {
$answerMatching[$real_answer['id_auto']] = $real_answer['answer'];
$answerMatching[$real_answer['iid']] = $real_answer['answer'];
}
$real_answers = [];
@ -7487,11 +7487,10 @@ class Exercise
INNER JOIN $TBL_QUESTIONS q
ON (e.question_id = q.iid AND e.c_id = q.c_id)
INNER JOIN $categoryRelTable catRel
ON (catRel.question_id = e.question_id AND catRel.c_id = e.c_id)
ON (catRel.question_id = e.question_id)
INNER JOIN $categoryTable cat
ON (cat.id = catRel.category_id AND cat.c_id = e.c_id)
ON (cat.iid = catRel.category_id)
WHERE
e.c_id = {$this->course_id} AND
e.exercice_id = ".(int) ($this->getId());
$result = Database::query($sql);
@ -9018,7 +9017,7 @@ class Exercise
$content .= Display::return_icon('quiz.png', '', [], 64);
$content .= '<div class="controls">';
$content .= Display::url(
'<em class="fa fa-plus"></em> '.get_lang('NewEx'),
'<em class="fa fa-plus"></em> '.get_lang('Create a new test'),
'exercise_admin.php?'.api_get_cidreq(),
['class' => 'btn btn-primary']
);
@ -10023,7 +10022,7 @@ class Exercise
'radio',
'results_disabled',
null,
get_lang('TestRankingMode'),
get_lang('Ranking mode: Do not show results details question by question and show a table with the ranking of all other users.'),
RESULT_DISABLE_RANKING,
['id' => 'result_disabled_6']
);
@ -10032,7 +10031,7 @@ class Exercise
'radio',
'results_disabled',
null,
get_lang('TestShowOnlyGlobalScoreAndCorrect answers'),
get_lang('Show only global score (not question score) and show only the correct answers, do not show incorrect answers at all'),
RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,
['id' => 'result_disabled_7']
);
@ -10041,7 +10040,7 @@ class Exercise
'radio',
'results_disabled',
null,
get_lang('TestAutoEvaluationAndRankingMode'),
get_lang('Auto-evaluation mode and ranking'),
RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING,
['id' => 'result_disabled_8']
);
@ -10049,7 +10048,7 @@ class Exercise
return $form->addGroup(
$resultDisabledGroup,
null,
get_lang('ShowResults and feedback and feedback and feedback and feedback and feedback and feedbackToStudents')
get_lang('Show score to learner')
);
}
}

@ -2083,7 +2083,7 @@ abstract class Question
$count = $em
->createQuery('
SELECT COUNT(qq.iid) FROM ChamiloCourseBundle:CQuizRelQuestion qq
WHERE qq.questionId = :id
WHERE qq.question = :id
')
->setParameters(['id' => (int) $this->id])
->getSingleScalarResult();

@ -205,7 +205,7 @@ class UniqueAnswer extends Question
null,
null,
$i,
'class="checkbox"'
['class' => 'checkbox']
);
$form->addHtmlEditor('answer['.$i.']', null, null, false, $editor_config);

@ -113,7 +113,7 @@ if (!$_in_course) {
'name' => get_lang('Assessments'),
];
}
$interbreadcrumb[] = ['url' => 'index.php?'.api_get_cidreq(), 'name' => get_lang('ToolAssessments')];
$interbreadcrumb[] = ['url' => 'index.php?'.api_get_cidreq(), 'name' => get_lang('Assessments')];
Display :: display_header(get_lang('New category'));
$display_form = true;

@ -1668,7 +1668,7 @@ HOTSPOT;
$exercise_id = (int) $exercise_id;
$table = Database::get_course_table(TABLE_QUIZ_TEST);
$sql = "SELECT expired_time FROM $table
WHERE c_id = $course_id AND id = $exercise_id";
WHERE c_id = $course_id AND iid = $exercise_id";
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
if (!empty($row['expired_time'])) {

@ -54,7 +54,7 @@ class HTML_QuickForm_radio extends HTML_QuickForm_input
$elementLabel = null,
$text = null,
$value = null,
$attributes = null
array $attributes = []
) {
$this->labelClass = isset($attributes['label-class']) ? $attributes['label-class'] : '';
$this->radioClass = isset($attributes['radio-class']) ? $attributes['radio-class'] : 'form-check';

Loading…
Cancel
Save