Skip to content
Permalink
Browse files

Add "show_question_id" config to show question id in the exercises BT…

…#15230

Add DESCRIPTION option when importing exercises with AIKEN

Remove unused setting "allow_question_code"
  • Loading branch information...
jmontoyaa committed Jan 30, 2019
1 parent 1177c7e commit dc21353812ade069dff4465067620db9fa932f08
@@ -196,13 +196,6 @@ function aiken_import_exercise($file)
$question->type = constant($type);
$question->save($exercise);
if (isset($question_array['code'])) {
$result = $question->addCode($question_array['code']);
if (empty($result)) {
Display::addFlash(Display::return_message(get_lang('QuestionCodeNotSaved')));
}
}
$last_question_id = $question->selectId();
//3. Create answer
$answer = new Answer($last_question_id);
@@ -307,8 +300,8 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
$exercise_info['question'][$question_index]['weighting'][$correct_answer_index] = 1;
} elseif (preg_match('/^SCORE:\s?(.*)/', $info, $matches)) {
$exercise_info['question'][$question_index]['score'] = (float) $matches[1];
} elseif (preg_match('/^CODE:\s?(.*)/', $info, $matches)) {
$exercise_info['question'][$question_index]['code'] = $matches[1];
} elseif (preg_match('/^DESCRIPTION:\s?(.*)/', $info, $matches)) {
$exercise_info['question'][$question_index]['description'] = $matches[1];
} elseif (preg_match('/^ANSWER_EXPLANATION:\s?(.*)/', $info, $matches)) {
//Comment of correct answer
$correct_answer_index = array_search($matches[1], $answers_array);
@@ -350,10 +343,10 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
} else {
//Question itself (use a 100-chars long title and a larger description)
$exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)).'...';
$exercise_info['question'][$question_index]['description'] = $info;
//$exercise_info['question'][$question_index]['description'] = $info;

This comment has been minimized.

Copy link
@ywarnier

ywarnier Mar 26, 2019

Member

Porquééééééééé???
Sin ninguna explicación...
El agregar el código de la pregunta no debería eliminar su descripción. Eso es raro. Ver comentarios en f4a130e

This comment has been minimized.

Copy link
@jmontoyaa

jmontoyaa Mar 27, 2019

Author Member

Ya no existe el concepto de "código de pregunta". El código de pregunta ahora es el campo c_quiz_question.iid.
La descripción de la pregunta sigue ahí.

}
} else {
$exercise_info['question'][$question_index]['description'] = $info;
//$exercise_info['question'][$question_index]['description'] = $info;
}
}
}
@@ -18,6 +18,7 @@
abstract class Question
{
public $id;
public $iid;
public $question;
public $description;
public $weighting;
@@ -77,6 +78,7 @@ abstract class Question
public function __construct()
{
$this->id = 0;
$this->iid = 0;
$this->question = '';
$this->description = '';
$this->weighting = 0;
@@ -155,6 +157,7 @@ public static function read($id, $course_id = null)
$objQuestion = self::getInstance($object->type);
if (!empty($objQuestion)) {
$objQuestion->id = (int) $id;
$objQuestion->iid = (int) $object->iid;
$objQuestion->question = $object->question;
$objQuestion->description = $object->description;
$objQuestion->weighting = $object->ponderation;
@@ -232,8 +235,8 @@ public function getTitleToDisplay($itemNumber)
{
$showQuestionTitleHtml = api_get_configuration_value('save_titles_as_html');
$title = '';
if (!empty($this->code) && api_get_configuration_value('allow_question_code')) {
$title .= '<h4>'.$this->code.'</h4>';
if (api_get_configuration_value('show_question_id')) {
$title .= '<h4>#'.$this->iid.'</h4>';
}
$title .= $showQuestionTitleHtml ? '' : '<strong>';
@@ -1683,10 +1686,6 @@ public function createForm(&$form, $exercise)
//$form->addElement('select', 'parent_id', get_lang('AttachToMedia'), $course_medias);
}
if (api_get_configuration_value('allow_question_code') && api_is_platform_admin()) {
$form->addText('code', get_lang('QuestionCode'));
}
$form->addElement('html', '</div>');
if (!isset($_GET['fromExercise'])) {
@@ -1726,10 +1725,6 @@ public function createForm(&$form, $exercise)
$defaults['questionCategory'] = $this->category;
$defaults['feedback'] = $this->feedback;
if (api_get_configuration_value('allow_question_code') && api_is_platform_admin()) {
$defaults['code'] = $this->code;
}
// Came from he question pool
if (isset($_GET['fromExercise'])) {
$form->setDefaults($defaults);
@@ -1764,13 +1759,6 @@ public function processCreation($form, $exercise)
// modify the exercise
$exercise->addToList($this->id);
$exercise->update_question_positions();
if (api_is_platform_admin()) {
$result = $this->addCode($form->getSubmitValue('code'));
if (empty($result)) {
Display::addFlash(Display::return_message(get_lang('QuestionCodeNotSaved')));
}
}
}
}
@@ -2371,33 +2359,6 @@ public function existsInAnotherExercises()
return $count > 1;
}
/**
* @param string $code
*
* @return bool
*/
public function addCode($code)
{
if (api_get_configuration_value('allow_question_code') && !empty($this->id)) {
$code = Database::escape_string($code);
$table = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "SELECT * FROM $table WHERE code = '$code' AND iid <> {$this->id} ";
$result = Database::query($sql);
$rows = Database::num_rows($result);
if (empty($rows)) {
$sql = "UPDATE $table SET code = '$code'
WHERE iid = {$this->id} AND c_id = {$this->course['real_id']}";
Database::query($sql);
return true;
}
}
return false;
}
/**
* Resizes a picture || Warning!: can only be called after uploadPicture,
* or if picture is already available in object.
@@ -15,7 +15,6 @@
* It is included from the script admin.php
*/
$limitTeacherAccess = api_get_configuration_value('limit_exercise_teacher_access');
// deletes a question from the exercise (not from the data base)
@@ -1072,9 +1072,8 @@
// Hide social media links
//$_configuration['hide_social_media_links'] = false;
// Allow code field in exercise questions
//ALTER TABLE c_quiz_question ADD COLUMN code VARCHAR(255) NULL DEFAULT NULL;
// $_configuration['allow_question_code'] = false;
// Show chamilo unique question id in exercises
// $_configuration['show_question_id'] = false;
// Show pagination if question list is bigger than "x" value, if 0 pagination will not appear.
// Option only when building an exercise as a teacher

0 comments on commit dc21353

Please sign in to comment.
You can’t perform that action at this time.