You are here

function course_outline_list in Course 7

Same name and namespace in other branches
  1. 6 includes/course.outline.inc \course_outline_list()
  2. 7.2 includes/course.outline.inc \course_outline_list()

Generate HTML of the course outline.

Parameters

object $node:

Return value

course outline list.

1 call to course_outline_list()
_course_block_outline_view in includes/course.block.inc
Course block callback: define outline view block.
1 string reference to 'course_outline_list'
course_course_handlers in ./course.module
Implements hook_course_handlers().

File

includes/course.outline.inc, line 425
course_outline.inc

Code

function course_outline_list($node) {
  global $user;
  $course = course_get_course($node, $user);

  // Iterate over objects.
  $workflow = array();
  $img = NULL;
  foreach ($course
    ->getObjects() as $key => $courseObject) {
    if ($courseObject
      ->access('see')) {

      // The item will be in the list only if the user can see it. If they can
      // take it, entity_view() will output a link instead of text.
      $entity = entity_load_single('course_object', $courseObject
        ->getId());
      $view = entity_view('course_object', array(
        $entity,
      ));
      $data = drupal_render($view);
      $item = array(
        'data' => $data,
        'id' => $courseObject
          ->getId(),
      );
      if ($courseObject
        ->access('take')) {

        // User can take this course object.
        $item['class'][] = 'accessible';

        // Step is complete.
        if ($courseObject
          ->getFulfillment()
          ->isComplete()) {
          $item['class'][] = 'completed';
        }
        elseif ($courseObject
          ->getFulfillment()
          ->getId()) {
          $item['class'][] = 'in-progress';
        }
        if ($course
          ->getActive() === $courseObject) {
          $item['class'][] = 'active';
        }
      }

      // Allow other modules to modify this list item.
      $courseObject
        ->overrideOutlineListItem($item);

      // Add this item to the list.
      $workflow[] = $item;
    }
  }
  if ($course
    ->getTracker()
    ->getOption('complete')) {
    $img = theme('image', array(
      'path' => 'misc/watchdog-ok.png',
      'alt' => t('Complete'),
    ));
    $workflow[] = array(
      'data' => $img . l(t('Complete'), "node/{$node->nid}/course-complete", array(
        'html' => TRUE,
      )),
      'id' => 'complete',
    );
  }
  $output = '';
  if ($workflow) {
    return theme('course_outline', array(
      'node' => $node,
      'items' => $workflow,
    ));
  }
  return $output;
}