course_poll.module in Course 6
File
modules/course_poll/course_poll.module
View source
<?php
function course_poll_context() {
$node = node_load(arg(1));
if (isset($node->nid) && $node->type == 'poll') {
return array(
'object_type' => 'poll',
'instance' => $node->nid,
);
}
}
function course_poll_course_handlers() {
return array(
'object' => array(
'poll' => array(
'name' => t('Poll'),
'class' => 'CourseObjectPoll',
'description' => t('A poll to be used in a course workflow.'),
),
),
'context' => array(
'poll' => array(
'callback' => 'course_poll_context',
),
),
);
}
function course_poll_form_poll_view_voting_alter(&$form, &$form_state) {
$form['vote']['#submit'][] = 'course_poll_fulfill';
}
function course_poll_fulfill(&$form, &$form_state) {
global $user;
$nid = $form['#node']->nid;
if ($courseObject = course_get_course_object('course_poll', 'poll', $nid, $user)) {
$courseObject
->getFulfillment()
->setComplete()
->save();
}
}