You are here

function course_get_course in Course 7.2

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 course.module \course_get_course()
  5. 3.x course.module \course_get_course()

Get a loaded Course.

@todo The static cache here may no longer be necessary as we are separating fulfillment data from courses.

Parameters

stdClass $node: The course node object.

Return value

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

34 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 1662
course.module Core functionality for Courses.

Code

function course_get_course($node) {
  if (course_node_is_course($node)) {
    $static =& drupal_static(__FUNCTION__, array());
    if (!isset($static[$node->nid])) {
      if ($course = entity_load_single('course', $node->nid)) {
        $static[$node->nid] = $course;
      }
      else {
        return FALSE;
      }
    }
    return $static[$node->nid];
  }
  else {
    return FALSE;
  }
}