You are here

function course_object_reports_page in Course 6

Same name and namespace in other branches
  1. 8.3 includes/course.reports.inc \course_object_reports_page()
  2. 8.2 includes/course.reports.inc \course_object_reports_page()
  3. 7.2 includes/course.reports.inc \course_object_reports_page()
  4. 7 includes/course.reports.inc \course_object_reports_page()

Page handler for course object reports.

1 string reference to 'course_object_reports_page'
course_menu in ./course.module
Implements hook_menu().

File

includes/course.reports.inc, line 11
course.reports.inc Reporting framework for course objects.

Code

function course_object_reports_page($node) {
  $coid = arg(4);
  $report_key = arg(5);
  $report_subkey = arg(6);

  // Report navigation.
  $nav = '';

  // Report header.
  $header = '';

  // Report content.
  $content = '';
  $course = course_get_course($node);
  foreach ($course
    ->getObjects() as $courseObject) {
    $lis = array();
    if (method_exists($courseObject, 'getReports')) {
      foreach ($courseObject
        ->getReports() as $key => $report) {
        $report_li = array(
          'data' => course_object_single_report_link($courseObject, $key, $report),
        );
        $lis[] = $report_li;
      }
    }
    if ($lis) {
      $nav .= theme('item_list', $lis, $courseObject
        ->getTitle());
    }
  }
  if ($coid) {
    $courseObject = course_get_course_object_by_id($coid);
    $report = $courseObject
      ->getReport($report_key, $report_subkey);
    if ($report) {
      if (isset($report['url'])) {
        $content = course_iframe($report['url']);
      }
      if (isset($report['content'])) {
        $content = $report['content'];
      }
      $header = '<h3>' . $courseObject
        ->getTitle() . ': ' . $report['title'] . '</h3>';
    }
    else {
      $content = 'Sorry, no report is available for this type.';
    }
  }
  return theme('course_report', $nav, $header, $content);
}