Minor adding comments, removing whitespaces.

skala
jmontoya 12 years ago
parent 76f4c509e1
commit 0946315f20
  1. 12
      main/exercice/answer.class.php
  2. 31
      main/exercice/question.class.php
  3. 4
      src/ChamiloLMS/Controller/ExerciseController.php

@ -649,13 +649,13 @@ class Answer
$course_info = $course_info; $course_info = $course_info;
} }
$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
$origin_options = Question::readQuestionOption($this->selectQuestionId(), $this->course['real_id']); $origin_options = Question::readQuestionOption($this->selectQuestionId(), $this->course['real_id']);
if (!empty($origin_options)) { if (!empty($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)];
} }

@ -1212,7 +1212,7 @@ abstract class Question
$question = $this->question; $question = $this->question;
$description = $this->description; $description = $this->description;
//Using the same method used in the course copy to transform URLs // Using the same method used in the course copy to transform URLs
if ($this->course['id'] != $course_info['id']) { if ($this->course['id'] != $course_info['id']) {
$description = DocumentManager::replace_urls_inside_content_html_from_copy_course( $description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
@ -1229,11 +1229,11 @@ abstract class Question
$course_id = $course_info['real_id']; $course_id = $course_info['real_id'];
//Read the source options // Read the source options
$options = self::readQuestionOption($this->id, $this->course['real_id']); $options = self::readQuestionOption($this->id, $this->course['real_id']);
//Inserting in the new course db / or the same course db // Inserting in the new course db / or the same course db
$params = array( $params = array(
'c_id' => $course_id, 'c_id' => $course_id,
'question' => $question, 'question' => $question,
'description' => $description, 'description' => $description,
@ -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') {

@ -40,7 +40,7 @@ class ExerciseController extends CommonController
if ($question) { if ($question) {
$newQuestionTitle = $question->selectTitle().' - '.get_lang('Copy'); $newQuestionTitle = $question->selectTitle().' - '.get_lang('Copy');
$question->updateTitle($newQuestionTitle); $question->updateTitle($newQuestionTitle);
//Duplicating the source question, in the current course // Duplicating the source question, in the current course
$courseInfo = api_get_course_info(); $courseInfo = api_get_course_info();
$newId = $question->duplicate($courseInfo); $newId = $question->duplicate($courseInfo);
// Reading new question // Reading new question
@ -50,7 +50,7 @@ class ExerciseController extends CommonController
// Reading Answers obj of the current course // Reading Answers obj of the current course
$newAnswer = new \Answer($questionId); $newAnswer = new \Answer($questionId);
$newAnswer->read(); $newAnswer->read();
//Duplicating the Answers in the current course // Duplicating the Answers in the current course
$newAnswer->duplicate($newId); $newAnswer->duplicate($newId);
/*$params = array( /*$params = array(
'cidReq' => api_get_course_id(), 'cidReq' => api_get_course_id(),

Loading…
Cancel
Save