You are here

public function CourseObjectWebform::getReport in Course 3.x

Same name and namespace in other branches
  1. 8.3 modules/course_webform/src/Plugin/course/CourseObject/CourseObjectWebform.php \Drupal\course_webform\Plugin\course\CourseObject\CourseObjectWebform::getReport()
  2. 8.2 modules/course_webform/src/Plugin/course/CourseObject/CourseObjectWebform.php \Drupal\course_webform\Plugin\course\CourseObject\CourseObjectWebform::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_webform/src/Plugin/course/CourseObject/CourseObjectWebform.php, line 95

Class

CourseObjectWebform
Plugin annotation @CourseObject( id = "webform", label = "Webform", handlers = { "fulfillment" = "\Drupal\course_webform\Plugin\course\CourseObject\CourseObjectWebformFulfillment" } )

Namespace

Drupal\course_webform\Plugin\course\CourseObject

Code

public function getReport($key) {
  switch ($key) {
    case 'submissions':
      return array(
        'title' => t('Webform results'),
        'modal' => 'node/1',
        'content' => webform_results_submissions($this
          ->getNode(), FALSE, 50),
      );
    case 'analysis':
      return array(
        'title' => t('Webform results'),
        'modal' => 'node/1',
        'content' => webform_results_analysis($this
          ->getNode()),
      );
    case 'download':
      $out = drupal_get_form('webform_results_download_form', $this
        ->getNode());
      return array(
        'title' => t('Webform results'),
        'url ' => 'node/1',
        'content' => \Drupal::service('renderer')
          ->render($out),
      );
  }
  return parent::getReport($key);
}