} else { echo $OUTPUT->header(); } /// Display the choicegroup and possibly results $event = \mod_choicegroup\event\course_module_viewed::create($eventparams); $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('course', $course); $event->add_record_snapshot('choicegroup', $choicegroup); $event->trigger(); /// Check to see if groups are being used in this choicegroup $groupmode = groups_get_activity_groupmode($cm); if ($groupmode) { groups_get_activity_group($cm, true); groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/choicegroup/view.php?id=' . $id); } $allresponses = choicegroup_get_response_data($choicegroup, $cm); // Big function, approx 6 SQL calls per user if (has_capability('mod/choicegroup:readresponses', $context)) { choicegroup_show_reportlink($choicegroup, $allresponses, $cm); } echo '<div class="clearer"></div>'; if ($choicegroup->intro) { echo $OUTPUT->box(format_module_intro('choicegroup', $choicegroup, $cm->id), 'generalbox', 'intro'); } //if user has already made a selection, and they are not allowed to update it, show their selected answer. if (isloggedin() && $current !== false) { if ($choicegroup->multipleenrollmentspossible == 1) { $currents = choicegroup_get_user_answer($choicegroup, $USER, TRUE); $names = array(); foreach ($currents as $current) { $names[] = format_string($current->name);
/** * Adds module specific settings to the settings block * * @param settings_navigation $settings The settings navigation object * @param navigation_node $choicegroupnode The node to add module settings to */ function choicegroup_extend_settings_navigation(settings_navigation $settings, navigation_node $choicegroupnode) { global $PAGE; if (has_capability('mod/choicegroup:readresponses', $PAGE->cm->context)) { $groupmode = groups_get_activity_groupmode($PAGE->cm); if ($groupmode) { groups_get_activity_group($PAGE->cm, true); } if (!($choicegroup = choicegroup_get_choicegroup($PAGE->cm->instance))) { print_error('invalidcoursemodule'); return false; } $allresponses = choicegroup_get_response_data($choicegroup, $PAGE->cm, $groupmode); // Big function, approx 6 SQL calls per user $responsecount = 0; $respondents = array(); foreach ($allresponses as $optionid => $userlist) { if ($optionid) { $responsecount += count($userlist); if ($choicegroup->multipleenrollmentspossible) { foreach ($userlist as $user) { if (!in_array($user->id, $respondents)) { $respondents[] = $user->id; } } } } } $viewallresponsestext = get_string("viewallresponses", "choicegroup", $responsecount); if ($choicegroup->multipleenrollmentspossible == 1) { $viewallresponsestext .= ' ' . get_string("byparticipants", "choicegroup", count($respondents)); } $choicegroupnode->add($viewallresponsestext, new moodle_url('/mod/choicegroup/report.php', array('id' => $PAGE->cm->id))); } }
echo $OUTPUT->header(); /// Check to see if groups are being used in this choicegroup $groupmode = groups_get_activity_groupmode($cm); if ($groupmode) { groups_get_activity_group($cm, true); groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/choicegroup/report.php?id=' . $id); } } else { $groupmode = groups_get_activity_groupmode($cm); $groups = choicegroup_get_groups($choicegroup); $groups_ids = array(); foreach ($groups as $group) { $groups_ids[] = $group->id; } } $users = choicegroup_get_response_data($choicegroup, $cm, $groupmode); if ($download == "ods" && has_capability('mod/choicegroup:downloadresponses', $context)) { require_once "{$CFG->libdir}/odslib.class.php"; /// Calculate file name $filename = clean_filename("{$course->shortname} " . strip_tags(format_string($choicegroup->name, true))) . '.ods'; /// Creating a workbook $workbook = new MoodleODSWorkbook("-"); /// Send HTTP headers $workbook->send($filename); /// Creating the first worksheet $myxls = $workbook->add_worksheet($strresponses); /// Print names of all the fields $myxls->write_string(0, 0, get_string("lastname")); $myxls->write_string(0, 1, get_string("firstname")); $myxls->write_string(0, 2, get_string("idnumber")); $myxls->write_string(0, 3, get_string("email"));