@@ 676-693 (lines=18) @@ | ||
673 | * Get question count per exercise from DB (any special treatment) |
|
674 | * @return int |
|
675 | */ |
|
676 | public function getQuestionCount() |
|
677 | { |
|
678 | $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
679 | $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
680 | $sql = "SELECT count(q.id) as count |
|
681 | FROM $TBL_EXERCICE_QUESTION e INNER JOIN $TBL_QUESTIONS q |
|
682 | ON (e.question_id = q.id) |
|
683 | WHERE e.c_id = {$this->course_id} AND e.exercice_id = ".Database::escape_string($this->id); |
|
684 | $result = Database::query($sql); |
|
685 | ||
686 | $count = 0; |
|
687 | if (Database::num_rows($result)) { |
|
688 | $row = Database::fetch_array($result); |
|
689 | $count = $row['count']; |
|
690 | } |
|
691 | ||
692 | return $count; |
|
693 | } |
|
694 | ||
695 | /** |
|
696 | * @return array |
|
@@ 698-715 (lines=18) @@ | ||
695 | /** |
|
696 | * @return array |
|
697 | */ |
|
698 | public function getQuestionOrderedListByName() |
|
699 | { |
|
700 | $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
701 | $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
702 | ||
703 | // Getting question list from the order (question list drag n drop interface ). |
|
704 | $sql = "SELECT e.question_id |
|
705 | FROM $TBL_EXERCICE_QUESTION e INNER JOIN $TBL_QUESTIONS q |
|
706 | ON (e.question_id= q.id) |
|
707 | WHERE e.c_id = {$this->course_id} AND e.exercice_id = '".Database::escape_string($this->id)."' |
|
708 | ORDER BY q.question"; |
|
709 | $result = Database::query($sql); |
|
710 | $list = array(); |
|
711 | if (Database::num_rows($result)) { |
|
712 | $list = Database::store_result($result, 'ASSOC'); |
|
713 | } |
|
714 | return $list; |
|
715 | } |
|
716 | ||
717 | /** |
|
718 | * Gets the question list ordered by the question_order setting (drag and drop) |