public function preload_questions()
 {
     if (empty($this->questionids)) {
         throw new moodle_quiz_exception($this, 'noquestions', $this->edit_url());
     }
     $this->questions = question_preload_questions($this->questionids, 'qqi.grade AS maxgrade, qqi.id AS instance', '{quiz_question_instances} qqi ON qqi.quiz = :quizid AND q.id = qqi.question', array('quizid' => $this->quiz->id));
     $this->number_questions();
 }
Example #2
0
 /**
  * Load just basic information about all the questions in this quiz.
  */
 public function preload_questions()
 {
     $this->questions = question_preload_questions(null, 'slot.maxmark, slot.id AS slotid, slot.slot, slot.page', '{quiz_slots} slot ON slot.quizid = :quizid AND q.id = slot.questionid', array('quizid' => $this->quiz->id), 'slot.slot');
 }
/**
 * Load a set of questions, given a list of ids. The $join and $extrafields arguments can be used
 * together to pull in extra data. See, for example, the usage in mod/quiz/attempt.php, and
 * read the code below to see how the SQL is assembled. Throws exceptions on error.
 *
 * @param array $questionids array of question ids.
 * @param string $extrafields extra SQL code to be added to the query.
 * @param string $join extra SQL code to be added to the query.
 * @param array $extraparams values for any placeholders in $join.
 * You are strongly recommended to use named placeholder.
 *
 * @return array question objects.
 */
function question_load_questions($questionids, $extrafields = '', $join = '')
{
    $questions = question_preload_questions($questionids, $extrafields, $join);
    // Load the question type specific information
    if (!get_question_options($questions)) {
        return 'Could not load the question options';
    }
    return $questions;
}