-
Notifications
You must be signed in to change notification settings - Fork 0
/
show_entries.php
149 lines (123 loc) · 6.26 KB
/
show_entries.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* print the single entries
*
* @author Andreas Grabs
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_individualfeedback
*/
require_once("../../config.php");
require_once("lib.php");
////////////////////////////////////////////////////////
//get the params
////////////////////////////////////////////////////////
$id = required_param('id', PARAM_INT);
$userid = optional_param('userid', false, PARAM_INT);
$showcompleted = optional_param('showcompleted', false, PARAM_INT);
$deleteid = optional_param('delete', null, PARAM_INT);
$courseid = optional_param('courseid', null, PARAM_INT);
////////////////////////////////////////////////////////
//get the objects
////////////////////////////////////////////////////////
list($course, $cm) = get_course_and_cm_from_cmid($id, 'individualfeedback');
$baseurl = new moodle_url('/mod/individualfeedback/show_entries.php', array('id' => $cm->id));
$PAGE->set_url(new moodle_url($baseurl, array('userid' => $userid, 'showcompleted' => $showcompleted,
'delete' => $deleteid)));
$context = context_module::instance($cm->id);
require_login($course, true, $cm);
$individualfeedback = $PAGE->activityrecord;
require_capability('mod/individualfeedback:viewreports', $context);
if ($deleteid) {
// This is a request to delete a reponse.
require_capability('mod/individualfeedback:deletesubmissions', $context);
require_sesskey();
$individualfeedbackstructure = new mod_individualfeedback_completion($individualfeedback, $cm, 0, true, $deleteid);
individualfeedback_delete_completed($individualfeedbackstructure->get_completed(), $individualfeedback, $cm);
redirect($baseurl);
} else if ($showcompleted || $userid) {
// Viewing individual response.
$individualfeedbackstructure = new mod_individualfeedback_completion($individualfeedback, $cm, 0, true, $showcompleted, $userid);
} else {
// Viewing list of reponses.
$individualfeedbackstructure = new mod_individualfeedback_structure($individualfeedback, $cm, $courseid);
}
$responsestable = new mod_individualfeedback_responses_table($individualfeedbackstructure);
$anonresponsestable = new mod_individualfeedback_responses_anon_table($individualfeedbackstructure);
if ($responsestable->is_downloading()) {
$responsestable->download();
}
if ($anonresponsestable->is_downloading()) {
$anonresponsestable->download();
}
// Process course select form.
$courseselectform = new mod_individualfeedback_course_select_form($baseurl, $individualfeedbackstructure, $individualfeedback->course == SITEID);
if ($data = $courseselectform->get_data()) {
redirect(new moodle_url($baseurl, ['courseid' => $data->courseid]));
}
// Print the page header.
navigation_node::override_active_url($baseurl);
$PAGE->set_heading($course->fullname);
$PAGE->set_title($individualfeedback->name);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($individualfeedback->name));
$current_tab = 'showentries';
require('tabs.php');
/// Print the main part of the page
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
if ($userid || $showcompleted) {
// Print the response of the given user.
$completedrecord = $individualfeedbackstructure->get_completed();
if ($userid) {
$usr = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
$responsetitle = userdate($completedrecord->timemodified) . ' (' . fullname($usr) . ')';
} else {
$responsetitle = get_string('response_nr', 'individualfeedback') . ': ' .
$completedrecord->random_response . ' (' . get_string('anonymous', 'individualfeedback') . ')';
}
echo $OUTPUT->heading($responsetitle, 4);
$form = new mod_individualfeedback_complete_form(mod_individualfeedback_complete_form::MODE_VIEW_RESPONSE,
$individualfeedbackstructure, 'individualfeedback_viewresponse_form');
$form->display();
list($prevresponseurl, $returnurl, $nextresponseurl) = $userid ?
$responsestable->get_reponse_navigation_links($completedrecord) :
$anonresponsestable->get_reponse_navigation_links($completedrecord);
echo html_writer::start_div('response_navigation');
echo $prevresponseurl ? html_writer::link($prevresponseurl, get_string('prev'), ['class' => 'prev_response']) : '';
echo html_writer::link($returnurl, get_string('back'), ['class' => 'back_to_list']);
echo $nextresponseurl ? html_writer::link($nextresponseurl, get_string('next'), ['class' => 'next_response']) : '';
echo html_writer::end_div();
} else {
// Print the list of responses.
$courseselectform->display();
// Show non-anonymous responses (always retrieve them even if current individualfeedback is anonymous).
$totalrows = $responsestable->get_total_responses_count();
if (!$individualfeedbackstructure->is_anonymous() || $totalrows) {
echo $OUTPUT->heading(get_string('non_anonymous_entries', 'individualfeedback', $totalrows), 4);
$responsestable->display();
}
// Show anonymous responses (always retrieve them even if current individualfeedback is not anonymous).
$individualfeedbackstructure->shuffle_anonym_responses();
$totalrows = $anonresponsestable->get_total_responses_count();
if ($individualfeedbackstructure->is_anonymous() || $totalrows) {
echo $OUTPUT->heading(get_string('anonymous_entries', 'individualfeedback', $totalrows), 4);
$anonresponsestable->display();
}
}
// Finish the page.
echo $OUTPUT->footer();