You are here

public function CourseObjectPoll::create in Course 6

Same name and namespace in other branches
  1. 7.2 modules/course_poll/course_poll.classes.inc \CourseObjectPoll::create()
  2. 7 modules/course_poll/course_poll.classes.inc \CourseObjectPoll::create()

Creates a course object.

For example, this would create the new node and return the node ID if this was a CourseObjectNode.

Do not confuse this with save(), which saves the course outline record for tracking.

Course objects should call setInstanceId() if this is a course object that creates external resources.

Overrides CourseObjectNode::create

File

modules/course_poll/course_poll.classes.inc, line 20

Class

CourseObjectPoll
Parent class for poll tracking.

Code

public function create() {
  $poll = new stdClass();
  $poll->choice[0]['chtext'] = 'Yes';
  $poll->choice[1]['chtext'] = 'No';
  $poll->type = 'poll';
  $poll->title = $this
    ->getTitle();
  $poll->uid = $this->user->uid;
  $poll->active = 1;
  node_save($poll);
  $this
    ->setNode($poll);
}