You are here

function course_get_course in Course 6

Same name and namespace in other branches
  1. 8.3 course.module \course_get_course()
  2. 8.2 course.module \course_get_course()
  3. 7.2 course.module \course_get_course()
  4. 7 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

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.
CourseObject::setCourse in includes/course_object.core.inc
Set the Course for this CourseObject.
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.

... See full list

File

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

Code

function course_get_course($node, $account = NULL, $flush = FALSE) {
  if (!$node) {
    return FALSE;
  }
  if (!$account) {
    global $user;
    $account = $user;
  }
  static $courses = array();
  if ($flush || !isset($courses[$node->nid]) || !isset($courses[$node->nid][$account->uid])) {
    $course = new Course($node, $account);
    $courses[$node->nid][$account->uid] = $course;
  }
  return $courses[$node->nid][$account->uid];
}