You are here

public function CourseReport::__construct in Course 6

Parameters

Course $course:

Overrides CourseHandler::__construct

File

includes/course.core.inc, line 273
course.core.inc File for main Course class.

Class

CourseReport
Holds a user's total progress through a course and functionality to check for completion of required objects.

Code

public function __construct($course) {
  $this->primaryKey = 'crid';
  $this->handlerType = 'course_report';
  $this->serializedField = 'data';
  $this->table = 'course_report';
  $this->course = $course;
  $sql = "SELECT * FROM {course_report} WHERE nid = %d AND uid = %d";
  $result = db_query($sql, $this->course
    ->getNode()->nid, $this->course
    ->getUser()->uid);
  if ($config = db_fetch_array($result)) {
    parent::__construct($config);
  }
  else {
    parent::__construct(array(
      'nid' => $this->course
        ->getNode()->nid,
      'uid' => $this->course
        ->getUser()->uid,
    ));
  }
}