public static function print_attempt($attempt_id) { //create a new attempt object from the given attempt ID $attempt = quiz_attempt::create($attempt_id); //get the coursemodule for the given attempt $cm = $attempt->get_cm(); //and ensure the user can access this context require_login($attempt->get_course(), false, $cm); //get the quiz object from the attempt $quiz = $attempt->get_quiz(); //if the quiz doesn't allow printable PDFs, throw an error if (!$quiz->allowprint) { print_error('nopermissiontoshow'); } //set up the page for PDF rendering self::set_up_pdf(); //and get the unique ID from the attempt $quba_id = $attempt->get_uniqueid(); //get the current context from the coursemodule $context = context_module::instance($cm->id); //create a new print helper $print_helper = new self($quiz, $context); //and use it to print the given quiz $print_helper->print_quba($quba_id, quiz_papercopy_batch_mode::NORMAL, false, true); }