course_poll.module in Course 7
File
modules/course_poll/course_poll.module
View source
<?php
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.'),
),
),
);
}
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;
$chid = $form_state['values']['choice'];
if ($courseObject = course_get_course_object('course_poll', 'poll', $nid, $user)) {
$courseObject
->getFulfillment($user)
->setOption('instance', $chid)
->setComplete()
->save();
}
}