--- /Users/sbourget/Desktop/MDL/moodle 1.9 CLEAN/mod/choice/lib.php 2007-05-16 10:04:44.000000000 -0400 +++ /Applications/MAMP/htdocs/moodle19/mod/choice/lib.php 2007-07-22 09:31:55.000000000 -0400 @@ -645,5 +645,63 @@ function choice_get_post_actions() { return array('choose','choose again'); } +// Add MyMoodle support to choice module +function choice_print_overview($courses, &$htmlarray) { + global $USER, $CFG; +// These next 6 Lines are constant in all modules (just change module name) + + if (empty($courses) || !is_array($courses) || count($courses) == 0) { + return array(); + } + if (!$choices = get_all_instances_in_courses('choice',$courses)) { + return; + } + +// Get Necessary Sirings + $strchoice = get_string('modulename', 'choice'); + $strnotanswered = get_string('notanswered', 'choice'); + $stranswered = get_string('taken', 'choice'); + $strchoiceclose = get_string('choiceclose', 'choice'); + $strchoiceopen = get_string('choiceopen', 'choice'); + $strresponses = get_string('responses', 'choice'); + + foreach ($choices as $choice) { + if ($choice->timeclose != 0) { // A choice is scheduled + $str = '
'. $strchoice.': visible?'':' class="dimmed"') . ' href="'.$CFG->wwwroot.'/mod/choice/view.php?id='.$choice->coursemodule.'">'.$choice->name.'
'; + if($choice->timeclose != 0) { + $str .= '
'.$strchoiceclose.': '.userdate($choice->timeclose).'
'; + } else { + $str .= '
'.$strchoiceopen.'
'; + } +// Count responses + $context = get_context_instance(CONTEXT_MODULE, $choice->coursemodule); + if (has_capability('mod/choice:readresponses', $context)) { + if ( $allanswers = get_records("choice_answers", "choiceid", $choice->id)) { + $responsecount = 0; + foreach ($allanswers as $aa) { + if (has_capability('mod/choice:readresponses', $context)) { //check to make sure user is enrolled in course. + $responsecount++; + } + } + } else { + $responsecount = 0; + } + $str .= '
'.$responsecount.' '.$strresponses.'
'; + } else { + if (isset($USER->id) && ($current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $USER->id))) { + $str .= '
'.$stranswered.'
'; + } else { + $str .= '
'.$strnotanswered.'
'; + } + } + // Echo String to Screen + if (empty($htmlarray[$choice->course]['choice'])) { + $htmlarray[$choice->course]['choice'] = $str; + } else { + $htmlarray[$choice->course]['choice'] .= $str; + } + } + } +} ?>