Minor adding comments, removing whitespaces.

skala
jmontoya 12 years ago
parent 76f4c509e1
commit 0946315f20
  1. 8
      main/exercice/answer.class.php
  2. 23
      main/exercice/question.class.php

@ -651,8 +651,8 @@ class Answer
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER); $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || self::getQuestionType( if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
) == MULTIPLE_ANSWER_TRUE_FALSE self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE
) { ) {
// Selecting origin options // Selecting origin options
@ -677,7 +677,7 @@ class Answer
// if at least one answer // if at least one answer
if ($this->nbrAnswers) { if ($this->nbrAnswers) {
// inserts new answers into data base // Insert new answers into database.
$c_id = $course_info['real_id']; $c_id = $course_info['real_id'];
$correct_answers = array(); $correct_answers = array();
@ -693,8 +693,6 @@ class Answer
$answer = Database::escape_string($this->answer[$i]); $answer = Database::escape_string($this->answer[$i]);
$correct = Database::escape_string($this->correct[$i]); $correct = Database::escape_string($this->correct[$i]);
if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE) { if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE) {
$correct = $fixed_list[intval($correct)]; $correct = $fixed_list[intval($correct)];
} }

@ -1255,6 +1255,7 @@ abstract class Question
Database::insert($TBL_QUESTION_OPTIONS, $item); Database::insert($TBL_QUESTION_OPTIONS, $item);
} }
} }
$this->duplicate_category_question($new_question_id, $course_id); $this->duplicate_category_question($new_question_id, $course_id);
// Duplicates the picture of the hotspot // Duplicates the picture of the hotspot
@ -1263,20 +1264,31 @@ abstract class Question
return $new_question_id; return $new_question_id;
} }
/**
* Get categories from question
* @return array
*/
public function get_categories_from_question() public function get_categories_from_question()
{ {
return Testcategory::getCategoryForQuestion($this->id); return Testcategory::getCategoryForQuestion($this->id);
} }
public function duplicate_category_question($question_id, $course_id) /**
* @param int $questionId
* @param int $courseId
*/
public function duplicate_category_question($questionId, $courseId)
{ {
$question = Question::read($question_id, $course_id); $question = Question::read($questionId, $courseId);
$categories = $this->get_categories_from_question(); $categories = $this->get_categories_from_question();
if (!empty($categories)) { if (!empty($categories)) {
$question->saveCategories($categories); $question->saveCategories($categories);
} }
} }
/**
* @return array|string
*/
public function get_question_type_name() public function get_question_type_name()
{ {
$key = self::$questionTypes[$this->type]; $key = self::$questionTypes[$this->type];
@ -1284,6 +1296,10 @@ abstract class Question
return get_lang($key[1]); return get_lang($key[1]);
} }
/**
* @param string $type
* @return null
*/
public static function get_question_type($type) public static function get_question_type($type)
{ {
if ($type == ORAL_EXPRESSION && api_get_setting('enable_nanogong') != 'true') { if ($type == ORAL_EXPRESSION && api_get_setting('enable_nanogong') != 'true') {
@ -1293,6 +1309,9 @@ abstract class Question
return self::$questionTypes[$type]; return self::$questionTypes[$type];
} }
/**
* @return array
*/
public static function get_question_type_list() public static function get_question_type_list()
{ {
if (api_get_setting('enable_nanogong') != 'true') { if (api_get_setting('enable_nanogong') != 'true') {

Loading…
Cancel
Save