You are here

class CourseObjectFulfillment in Course 6

Same name and namespace in other branches
  1. 7.2 includes/CourseObjectFulfillment.inc \CourseObjectFulfillment
  2. 7 includes/CourseObjectFulfillment.inc \CourseObjectFulfillment

Parent class for course object fulfillment.

Represents the fulfillment record in the database.

Hierarchy

Expanded class hierarchy of CourseObjectFulfillment

File

includes/course_object.core.inc, line 969

View source
class CourseObjectFulfillment extends CourseHandler {
  private $courseObject;

  /**
   * Construct the fulfillment object.
   *
   * A CourseObject and user are required to construct a fulfillment object.
   *
   * @param CourseObject $courseObject
   * @param Object $user
   */
  function __construct(CourseObject $courseObject, $user) {

    // Set storage.
    $this->handlerType = 'course_object_fulfillment';
    $this->table = 'course_outline_fulfillment';
    $this->primaryKey = 'cofid';
    $this->serializedField = 'info';
    $this->courseObject = $courseObject;
    $sql = "SELECT * FROM {course_outline_fulfillment} WHERE coid = %d AND uid = %d";
    $fulfillment = db_fetch_array(db_query($sql, $this->courseObject
      ->getId(), $user->uid));
    $this
      ->setOptions($fulfillment);

    // Set course object ID.
    $this
      ->setOption('coid', $this->courseObject
      ->getId());
    $this
      ->setOption('uid', $user->uid);
  }

  /**
   * Is this fulfillment complete?
   *
   * @return bool
   */
  function isComplete() {
    return (bool) $this
      ->getOption('complete');
  }

  /**
   * Set this fulfillment complete.
   *
   * @param bool $complete
   *   Set to 0 to un-complete, 1 or omit to complete.
   */
  function setComplete($complete = 1) {
    if (!$this
      ->getOption('date_completed')) {
      $this
        ->setOption('date_completed', time());
    }
    return $this
      ->setOption('complete', $complete);
  }

  /**
   * Set this fulfillment's grade.
   *
   * @param float $grade
   */
  function setGrade($grade) {
    return $this
      ->setOption('grade_result', $grade);
  }

  /**
   * Get this fulfillment's grade.
   *
   * @return float
   *   A float value of the user's grade for this fulfillment.
   */
  function getGrade() {
    return $this
      ->getOption('grade_result');
  }

  /**
   * Get this fulfillment's course object.
   */
  function getCourseObject() {
    return $this->courseObject;
  }
  public function delete() {
    $sql = "DELETE FROM {course_outline_fulfillment} WHERE cofid = %d";
    db_query($sql, $this
      ->getId());
  }

  /**
   * Track course after saving fulfillment.
   */
  public function save() {
    parent::save();
    $this
      ->getCourseObject()
      ->getCourse()
      ->track();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CourseHandler::$accessMessages private property
CourseHandler::$config protected property
CourseHandler::$handlerType public property
CourseHandler::$primaryKey public property
CourseHandler::$serializedField public property
CourseHandler::$table public property
CourseHandler::addOptions final public function Merge an array of options onto the existing options.
CourseHandler::getAccessMessages public function Get an array of access messages.
CourseHandler::getDatabaseFields protected function Return an array of database fields. This determines what fields should be serialized instead of stored.
CourseHandler::getId function
CourseHandler::getOption final public function Get an option stored in this CourseObject.
CourseHandler::getOptions public function Get an object's configuration. 1
CourseHandler::getOptionsSummary public function Stub. Get the summary of an object's options. 1
CourseHandler::getWarnings public function Return a list of warning strings about this handler. 1
CourseHandler::optionsDefinition protected function Handlers need to declare their defaults if they have a configuration form. 4
CourseHandler::optionsForm public function Handlers can declare a form. 4
CourseHandler::optionsMerge private function Merge arrays with replace, not append.
CourseHandler::optionsSubmit public function Save data somewhere. 1
CourseHandler::optionsValidate public function Validate? 3
CourseHandler::setAccessMessage public function Set an access message to be displayed along with the course object when it is in the outline. For example, "This activity will open on XYZ" or "Please complete Step 1 to take this activity."
CourseHandler::setOption final public function Set an option for this handler.
CourseHandler::setOptions final public function Set this entire handler's options.
CourseObjectFulfillment::$courseObject private property
CourseObjectFulfillment::delete public function
CourseObjectFulfillment::getCourseObject function Get this fulfillment's course object.
CourseObjectFulfillment::getGrade function Get this fulfillment's grade.
CourseObjectFulfillment::isComplete function Is this fulfillment complete?
CourseObjectFulfillment::save public function Track course after saving fulfillment. Overrides CourseHandler::save
CourseObjectFulfillment::setComplete function Set this fulfillment complete.
CourseObjectFulfillment::setGrade function Set this fulfillment's grade.
CourseObjectFulfillment::__construct function Construct the fulfillment object. Overrides CourseHandler::__construct