예제 #1
0
파일: view.php 프로젝트: pzhu2004/moodle
/// Display the choice and possibly results
$eventdata = array();
$eventdata['objectid'] = $choice->id;
$eventdata['context'] = $context;
/// Check to see if groups are being used in this choice
$groupmode = groups_get_activity_groupmode($cm);
if ($groupmode) {
    groups_get_activity_group($cm, true);
    groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/choice/view.php?id=' . $id);
}
// Check if we want to include responses from inactive users.
$onlyactive = $choice->includeinactive ? false : true;
$allresponses = choice_get_response_data($choice, $cm, $groupmode, $onlyactive);
// Big function, approx 6 SQL calls per user.
if (has_capability('mod/choice:readresponses', $context)) {
    choice_show_reportlink($allresponses, $cm);
}
echo '<div class="clearer"></div>';
if ($choice->intro) {
    echo $OUTPUT->box(format_module_intro('choice', $choice, $cm->id), 'generalbox', 'intro');
}
$timenow = time();
$current = choice_get_my_response($choice);
//if user has already made a selection, and they are not allowed to update it or if choice is not open, show their selected answer.
if (isloggedin() && !empty($current) && (empty($choice->allowupdate) || $timenow > $choice->timeclose)) {
    $choicetexts = array();
    foreach ($current as $c) {
        $choicetexts[] = format_string(choice_get_option_text($choice, $c->optionid));
    }
    echo $OUTPUT->box(get_string("yourselection", "choice", userdate($choice->timeopen)) . ": " . implode('; ', $choicetexts), 'generalbox', 'yourselection');
}
예제 #2
0
    } else {
        choice_user_submit_response($answer, $choice, $USER->id, $course->id, $cm);
    }
    redirect("view.php?id={$cm->id}");
    exit;
}
/// Display the choice and possibly results
$navigation = build_navigation('', $cm);
print_header_simple(format_string($choice->name), "", $navigation, "", "", true, update_module_button($cm->id, $course->id, $strchoice), navmenu($course, $cm));
add_to_log($course->id, "choice", "view", "view.php?id={$cm->id}", $choice->id, $cm->id);
/// Check to see if groups are being used in this choice
$groupmode = groups_get_activity_groupmode($cm);
groups_get_activity_group($cm, true);
groups_print_activity_menu($cm, 'view.php?id=' . $id);
if (has_capability('mod/choice:readresponses', $context)) {
    choice_show_reportlink($choice, $course->id, $cm, $groupmode);
}
echo '<div class="clearer"></div>';
if ($choice->text) {
    print_box(format_text($choice->text, $choice->format), 'generalbox', 'intro');
}
//if user has already made a selection, and they are not allowed to update it, show their selected answer.
if (!empty($USER->id) && ($current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $USER->id)) && empty($choice->allowupdate)) {
    print_simple_box(get_string("yourselection", "choice", userdate($choice->timeopen)) . ": " . format_string(choice_get_option_text($choice, $current->optionid)), "center");
}
/// Print the form
$timenow = time();
if ($choice->timeclose != 0) {
    if ($choice->timeopen > $timenow) {
        print_simple_box(get_string("notopenyet", "choice", userdate($choice->timeopen)), "center");
        print_footer($course);