Minor - format code, fix query

1.10.x
Julio Montoya 10 years ago
parent 5ca2d2056e
commit cdf406bb8b
  1. 22
      main/exercice/question.class.php

@ -146,13 +146,10 @@ abstract class Question
$tblQuiz = Database::get_course_table(TABLE_QUIZ_TEST); $tblQuiz = Database::get_course_table(TABLE_QUIZ_TEST);
/*$sql = "SELECT exercice_id FROM $TBL_EXERCISE_QUESTION
WHERE c_id = $course_id AND question_id = $id";*/
$sql = "SELECT DISTINCT q.exercice_id $sql = "SELECT DISTINCT q.exercice_id
FROM $TBL_EXERCISE_QUESTION q FROM $TBL_EXERCISE_QUESTION q
INNER JOIN $tblQuiz e INNER JOIN $tblQuiz e
ON e.c_id = q.c_id AND e.id = e.exercice_id ON e.c_id = q.c_id AND e.id = q.exercice_id
WHERE WHERE
q.c_id = $course_id AND q.c_id = $course_id AND
q.question_id = $id AND q.question_id = $id AND
@ -250,7 +247,7 @@ abstract class Question
* @author Nicolas Raynaud * @author Nicolas Raynaud
* @return integer - level of the question, 0 by default. * @return integer - level of the question, 0 by default.
*/ */
function selectLevel() public function selectLevel()
{ {
return $this->level; return $this->level;
} }
@ -274,6 +271,7 @@ abstract class Question
if (!empty($this->picture)) { if (!empty($this->picture)) {
return api_get_path(WEB_COURSE_PATH) . $this->course['path'] . '/document/images/' . $this->picture; return api_get_path(WEB_COURSE_PATH) . $this->course['path'] . '/document/images/' . $this->picture;
} }
return false; return false;
} }
@ -294,7 +292,8 @@ abstract class Question
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @return integer - number of exercises * @return integer - number of exercises
*/ */
public function selectNbrExercises() { public function selectNbrExercises()
{
return sizeof($this->exerciseList); return sizeof($this->exerciseList);
} }
@ -302,6 +301,7 @@ abstract class Question
* changes the question title * changes the question title
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
*
* @param string $title - question title * @param string $title - question title
*/ */
public function updateTitle($title) public function updateTitle($title)
@ -321,6 +321,7 @@ abstract class Question
* changes the question description * changes the question description
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
*
* @param string $description - question description * @param string $description - question description
*/ */
public function updateDescription($description) public function updateDescription($description)
@ -742,7 +743,8 @@ abstract class Question
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @return boolean - true if moved, otherwise false * @return boolean - true if moved, otherwise false
*/ */
function getTmpPicture() { function getTmpPicture()
{
global $picturePath; global $picturePath;
// if the question has got an ID and if the picture exists // if the question has got an ID and if the picture exists
@ -1725,6 +1727,7 @@ abstract class Question
array('class' => 'ribbon') array('class' => 'ribbon')
); );
$header .= Display::div($this->description, array('id' => 'question_description')); $header .= Display::div($this->description, array('id' => 'question_description'));
return $header; return $header;
} }
@ -1807,6 +1810,7 @@ abstract class Question
$tabQuestionList = Question::get_question_type_list(); // [0]=file to include [1]=type name $tabQuestionList = Question::get_question_type_list(); // [0]=file to include [1]=type name
require_once $tabQuestionList[$type][0]; require_once $tabQuestionList[$type][0];
$img = $explanation = null; $img = $explanation = null;
eval('$img = ' . $tabQuestionList[$type][1] . '::$typePicture;'); eval('$img = ' . $tabQuestionList[$type][1] . '::$typePicture;');
eval('$explanation = get_lang(' . $tabQuestionList[$type][1] . '::$explanationLangVar);'); eval('$explanation = get_lang(' . $tabQuestionList[$type][1] . '::$explanationLangVar);');
@ -1824,8 +1828,7 @@ abstract class Question
$sidx = "question", $sidx = "question",
$sord = "ASC", $sord = "ASC",
$where_condition = array() $where_condition = array()
) ) {
{
$table_question = Database::get_course_table(TABLE_QUIZ_QUESTION); $table_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
$default_where = array('c_id = ? AND parent_id = 0 AND type = ?' => array($course_id, MEDIA_QUESTION)); $default_where = array('c_id = ? AND parent_id = 0 AND type = ?' => array($course_id, MEDIA_QUESTION));
$result = Database::select( $result = Database::select(
@ -1837,6 +1840,7 @@ abstract class Question
'order' => "$sidx $sord" 'order' => "$sidx $sord"
) )
); );
return $result; return $result;
} }

Loading…
Cancel
Save