$eventdata = array(); $eventdata['objectid'] = $randchoice->id; $eventdata['context'] = $context; $event = \mod_randchoice\event\course_module_viewed::create($eventdata); $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('course', $course); $event->trigger(); /// Check to see if groups are being used in this randchoice $groupmode = groups_get_activity_groupmode($cm); if ($groupmode) { groups_get_activity_group($cm, true); groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/randchoice/view.php?id=' . $id); } // Check if we want to include responses from inactive users. $onlyactive = $randchoice->includeinactive ? false : true; $allresponses = randchoice_get_response_data($randchoice, $cm, $groupmode, $onlyactive); // Big function, approx 6 SQL calls per user. if (has_capability('mod/randchoice:readresponses', $context)) { randchoice_show_reportlink($allresponses, $cm); } echo '<div class="clearer"></div>'; if ($randchoice->intro) { echo $OUTPUT->box(format_module_intro('randchoice', $randchoice, $cm->id), 'generalbox', 'intro'); } $timenow = time(); //var_dump($timenow); die; $current = $DB->get_records('randchoice_answers', array('randchoiceid' => $randchoice->id, 'userid' => $USER->id)); //if user has already made a selection, and they are not allowed to update it or if randchoice is not open, show their selected answer. if (isloggedin() && !empty($current) && (empty($randchoice->allowupdate) || $timenow > $randchoice->timeclose)) { $randchoicetexts = array(); foreach ($current as $c) {
/** * Adds module specific settings to the settings block * * @param settings_navigation $settings The settings navigation object * @param navigation_node $randchoicenode The node to add module settings to */ function randchoice_extend_settings_navigation(settings_navigation $settings, navigation_node $randchoicenode) { global $PAGE; if (has_capability('mod/randchoice:readresponses', $PAGE->cm->context)) { $groupmode = groups_get_activity_groupmode($PAGE->cm); if ($groupmode) { groups_get_activity_group($PAGE->cm, true); } $randchoice = randchoice_get_randchoice($PAGE->cm->instance); // Check if we want to include responses from inactive users. $onlyactive = $randchoice->includeinactive ? false : true; // Big function, approx 6 SQL calls per user. $allresponses = randchoice_get_response_data($randchoice, $PAGE->cm, $groupmode, $onlyactive); $responsecount = 0; foreach ($allresponses as $optionid => $userlist) { if ($optionid) { $responsecount += count($userlist); } } $randchoicenode->add(get_string("viewallresponses", "randchoice", $responsecount), new moodle_url('/mod/randchoice/report.php', array('id' => $PAGE->cm->id))); } }