You are here

function course_course_credit_check_completion in Course 6

Implements course_credit_check_completion().

Require the user to choose a user type before they claim credit.

File

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

Code

function course_course_credit_check_completion($course_node) {
  global $user;

  // Check if course user types enabled, has user types, and there is actually valid credit for this course.
  if (variable_get('course_user_types_enabled', 0) && count(course_user_type_get_options())) {

    // Check for active credit types. No user checking at this point.
    // @todo break out into function to get active credit types on a course.
    $active = FALSE;
    foreach ($course_node->course_credit as $type) {
      if ($type->active) {
        $active = TRUE;
      }
    }
    if ($active) {
      $enrolment = course_enrolment_load($course_node, $user);
      if (!$enrolment->user_type && arg(2) == 'course-credit-app') {
        drupal_goto("node/{$course_node->nid}/course-user-type", drupal_get_destination());
      }
    }
  }
}