You are here

public function CourseObjectQuiz::getReport in Course 8.3

Same name and namespace in other branches
  1. 8.2 modules/course_quiz/src/Plugin/course/CourseObject/CourseObjectQuiz.php \Drupal\course_quiz\Plugin\course\CourseObject\CourseObjectQuiz::getReport()
  2. 3.x modules/course_quiz/src/Plugin/course/CourseObject/CourseObjectQuiz.php \Drupal\course_quiz\Plugin\course\CourseObject\CourseObjectQuiz::getReport()

Let the course object provide its own reports.

Return value

array An array containing:

  • title: The title of this report as show on the page
  • content: Content to be displayed.
  • url: URL to be loaded in an iframe.

Reports should return either 'content' or 'url'.

Overrides CourseObject::getReport

File

modules/course_quiz/src/Plugin/course/CourseObject/CourseObjectQuiz.php, line 141

Class

CourseObjectQuiz
Plugin annotation @CourseObject( id = "quiz", label = "Quiz", handlers = { "fulfillment" = "\Drupal\course_quiz\Plugin\course\CourseObject\CourseObjectQuizFulfillment" } )

Namespace

Drupal\course_quiz\Plugin\course\CourseObject

Code

public function getReport($key) {
  module_load_include('inc', 'quiz', 'quiz.admin');
  switch ($key) {
    case 'results':
      if (course_quiz_quiz_version() >= 5) {
        $out = views_embed_view('quiz_results', 'default', $this
          ->getInstanceId());
      }
      else {
        $out = drupal_get_form('quiz_results_manage_results_form', $this
          ->getNode());
      }
      return array(
        'title' => t('Quiz results'),
        'content' => $out,
      );
    case 'statistics':
      module_load_include('inc', 'quiz_stats', 'quiz_stats.admin');
      return array(
        'title' => t('Quiz statistics'),
        'content' => quiz_stats_get_adv_stats($this
          ->getNode()->vid),
      );
  }
  return parent::getReport($key);
}