You are here

function course_get_course in Course 7

Same name and namespace in other branches
  1. 8.3 course.module \course_get_course()
  2. 8.2 course.module \course_get_course()
  3. 6 course.module \course_get_course()
  4. 7.2 course.module \course_get_course()
  5. 3.x course.module \course_get_course()

Get a loaded Course.

Parameters

stdClass $node: The course node object.

stdClass $account: The user with which to instantiate course objects and fulfillment.

Return value

Course|boolean The Course entity, or FALSE if provided node was not a Course.

37 calls to course_get_course()
CourseGradeTestCase::testCourseFinalGrade in tests/CourseGradeTestCase.test
Test that the final grade is calculated correctly.
CourseGradeTestCase::testCourseGradeAccess in tests/CourseGradeTestCase.test
Test that the course grade access plugin functions properly.
CourseObjectAccessConditionalTestCase::testTimeAfterCompletion in tests/CourseObjectAccessConditionalTestCase.test
Test the completion based trigger for object access.
CourseObjectAccessConditionalTestCase::testTimeAfterStart in tests/CourseObjectAccessConditionalTestCase.test
Test the time based trigger for object access.
CourseObjectAccessTestCase::testCourseObjectLinearWorkflow in tests/CourseObjectAccessTestCase.test
Test sequential object access.

... See full list

File

./course.module, line 1627
course.module Core functionality for Courses.

Code

function course_get_course($node, $account = NULL) {
  if (course_node_is_course($node)) {
    $static =& drupal_static(__FUNCTION__, array());

    /** @deprecated */
    if (!$account) {
      global $user;
      $account = $user;
    }
    if (!isset($static[$node->nid][$account->uid])) {
      $course = entity_load_single('course', $node->nid);
      $course
        ->setUser($account);
      $static[$node->nid][$account->uid] = $course;
    }
    return $static[$node->nid][$account->uid];
  }
  else {
    return FALSE;
  }
}