Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * print the single entries
19
 *
20
 * @author Andreas Grabs
21
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
22
 * @package mod_feedback
23
 */
24
 
1441 ariadna 25
use mod_feedback\manager;
26
 
1 efrain 27
require_once("../../config.php");
28
require_once("lib.php");
29
 
30
////////////////////////////////////////////////////////
31
//get the params
32
////////////////////////////////////////////////////////
33
$id = required_param('id', PARAM_INT);
34
$userid = optional_param('userid', false, PARAM_INT);
35
$showcompleted = optional_param('showcompleted', false, PARAM_INT);
36
$deleteid = optional_param('delete', null, PARAM_INT);
37
$courseid = optional_param('courseid', null, PARAM_INT);
38
 
39
////////////////////////////////////////////////////////
40
//get the objects
41
////////////////////////////////////////////////////////
42
 
43
list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
44
 
45
$baseurl = new moodle_url('/mod/feedback/show_entries.php', array('id' => $cm->id));
46
$PAGE->set_url(new moodle_url($baseurl, array('userid' => $userid, 'showcompleted' => $showcompleted,
47
        'delete' => $deleteid)));
48
$context = context_module::instance($cm->id);
49
 
50
require_login($course, true, $cm);
51
$feedback = $PAGE->activityrecord;
52
 
53
require_capability('mod/feedback:viewreports', $context);
54
 
55
$actionbar = new \mod_feedback\output\responses_action_bar($cm->id, $baseurl);
56
 
57
if ($deleteid) {
58
    // This is a request to delete a reponse.
59
    require_capability('mod/feedback:deletesubmissions', $context);
60
    require_sesskey();
61
    $feedbackstructure = new mod_feedback_completion($feedback, $cm, 0, true, $deleteid);
62
    feedback_delete_completed($feedbackstructure->get_completed(), $feedback, $cm);
63
    redirect($baseurl);
64
} else if ($showcompleted || $userid) {
65
    // Viewing individual response.
66
    $feedbackstructure = new mod_feedback_completion($feedback, $cm, 0, true, $showcompleted, $userid);
67
} else {
68
    // Viewing list of reponses.
69
    $feedbackstructure = new mod_feedback_structure($feedback, $cm, $courseid);
70
}
71
 
72
$responsestable = new mod_feedback_responses_table($feedbackstructure);
73
$anonresponsestable = new mod_feedback_responses_anon_table($feedbackstructure);
74
 
75
if ($responsestable->is_downloading()) {
76
    $responsestable->download();
77
}
78
if ($anonresponsestable->is_downloading()) {
79
    $anonresponsestable->download();
80
}
81
 
82
// Process course select form.
83
$courseselectform = new mod_feedback_course_select_form($baseurl, $feedbackstructure, $feedback->course == SITEID);
84
if ($data = $courseselectform->get_data()) {
85
    redirect(new moodle_url($baseurl, ['courseid' => $data->courseid]));
86
}
87
// Print the page header.
88
navigation_node::override_active_url($baseurl);
89
$PAGE->set_heading($course->fullname);
1441 ariadna 90
 
91
/** @var \mod_feedback\output\renderer $renderer */
92
$renderer = $PAGE->get_renderer('mod_feedback');
93
$renderer->set_title(
94
        [format_string($feedback->name), format_string($course->fullname)],
95
        get_string('responses', 'feedback')
96
);
97
 
1 efrain 98
$PAGE->activityheader->set_attrs([
99
    'hidecompletion' => true,
100
    'description' => ''
101
]);
1441 ariadna 102
 
1 efrain 103
echo $OUTPUT->header();
104
echo $renderer->main_action_bar($actionbar);
105
echo $OUTPUT->heading(get_string('show_entries', 'mod_feedback'), 3);
106
 
107
/// Print the main part of the page
108
///////////////////////////////////////////////////////////////////////////
109
///////////////////////////////////////////////////////////////////////////
110
///////////////////////////////////////////////////////////////////////////
111
 
112
if ($userid || $showcompleted) {
113
    // Print the response of the given user.
114
    $completedrecord = $feedbackstructure->get_completed();
115
 
116
    if ($userid) {
117
        $usr = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
118
        $responsetitle = userdate($completedrecord->timemodified) . ' (' . fullname($usr) . ')';
119
    } else {
120
        $responsetitle = get_string('response_nr', 'feedback') . ': ' .
121
                $completedrecord->random_response . ' (' . get_string('anonymous', 'feedback') . ')';
122
    }
123
 
124
    echo $OUTPUT->heading($responsetitle, 4);
125
 
126
    $form = new mod_feedback_complete_form(mod_feedback_complete_form::MODE_VIEW_RESPONSE,
127
            $feedbackstructure, 'feedback_viewresponse_form');
128
    $form->display();
129
 
130
    list($prevresponseurl, $returnurl, $nextresponseurl) = $userid ?
131
            $responsestable->get_reponse_navigation_links($completedrecord) :
132
            $anonresponsestable->get_reponse_navigation_links($completedrecord);
133
 
134
    echo html_writer::start_div('response_navigation');
135
 
136
    $responsenavigation = [
137
        'col1content' => '',
138
        'col2content' => html_writer::link($returnurl, get_string('back'), ['class' => 'back_to_list']),
139
        'col3content' => '',
140
    ];
141
 
142
    if ($prevresponseurl) {
143
        $responsenavigation['col1content'] = html_writer::link($prevresponseurl, get_string('prev'), ['class' => 'prev_response']);
144
    }
145
 
146
    if ($nextresponseurl) {
147
        $responsenavigation['col3content'] = html_writer::link($nextresponseurl, get_string('next'), ['class' => 'next_response']);
148
    }
149
 
150
    echo $OUTPUT->render_from_template('core/columns-1to1to1', $responsenavigation);
151
    echo html_writer::end_div();
152
 
153
} else {
154
    // Print the list of responses.
155
    $courseselectform->display();
156
 
1441 ariadna 157
    if (!manager::can_see_others_in_groups($feedbackstructure->get_cm())) {
158
        echo $OUTPUT->notification(get_string('notingroup'));
159
        echo $OUTPUT->footer();
160
        exit();
161
    }
1 efrain 162
    // Show non-anonymous responses (always retrieve them even if current feedback is anonymous).
163
    $totalrows = $responsestable->get_total_responses_count();
164
    if (!$feedbackstructure->is_anonymous() || $totalrows) {
165
        echo $OUTPUT->heading(get_string('non_anonymous_entries', 'feedback', $totalrows), 4);
166
        $responsestable->display();
167
    }
168
 
169
    // Show anonymous responses (always retrieve them even if current feedback is not anonymous).
170
    $feedbackstructure->shuffle_anonym_responses();
171
    $totalrows = $anonresponsestable->get_total_responses_count();
172
    if ($feedbackstructure->is_anonymous() || $totalrows) {
173
        echo $OUTPUT->heading(get_string('anonymous_entries', 'feedback', $totalrows), 4);
174
        $anonresponsestable->display();
175
    }
176
 
177
}
178
 
179
// Finish the page.
180
echo $OUTPUT->footer();