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
 * shows an analysed view of feedback
19
 *
20
 * @copyright Andreas Grabs
21
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
22
 * @package mod_feedback
23
 */
24
 
25
require_once("../../config.php");
26
require_once("lib.php");
27
 
28
$id = required_param('id', PARAM_INT);  // Course module id.
29
 
30
$url = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id));
31
$PAGE->set_url($url);
32
 
33
list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
34
require_course_login($course, true, $cm);
35
 
36
$feedback = $PAGE->activityrecord;
37
$feedbackstructure = new mod_feedback_structure($feedback, $cm);
38
 
39
$context = context_module::instance($cm->id);
40
 
41
if (!$feedbackstructure->can_view_analysis()) {
42
    throw new \moodle_exception('error');
43
}
44
 
45
/// Print the page header
46
 
47
$PAGE->set_heading($course->fullname);
1441 ariadna 48
 
49
$renderer = $PAGE->get_renderer('mod_feedback');
50
$renderer->set_title(
51
    [format_string($feedback->name), format_string($course->fullname)],
52
    get_string('analysis', 'feedback')
53
);
54
 
1 efrain 55
$PAGE->activityheader->set_attrs([
56
    'hidecompletion' => true,
57
    'description' => ''
58
]);
59
$PAGE->add_body_class('limitedwidth');
60
echo $OUTPUT->header();
61
echo $OUTPUT->heading(get_string('analysis', 'mod_feedback'), 3);
62
 
63
//get the groupid
64
$mygroupid = groups_get_activity_group($cm, true);
65
groups_print_activity_menu($cm, $url);
66
 
67
// Button "Export to excel".
68
if (has_capability('mod/feedback:viewreports', $context) && $feedbackstructure->get_items()) {
69
    echo $OUTPUT->container_start('form-buttons');
70
    $aurl = new moodle_url('/mod/feedback/analysis_to_excel.php', ['sesskey' => sesskey(), 'id' => $id]);
71
    echo $OUTPUT->single_button($aurl, get_string('export_to_excel', 'feedback'));
72
    echo $OUTPUT->container_end();
73
}
74
 
75
// Show the summary.
76
$summary = new mod_feedback\output\summary($feedbackstructure, $mygroupid);
77
echo $OUTPUT->render_from_template('mod_feedback/summary', $summary->export_for_template($OUTPUT));
78
 
79
// Get the items of the feedback.
80
$items = $feedbackstructure->get_items(true);
81
 
82
$check_anonymously = true;
83
if ($mygroupid > 0 AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES) {
84
    $completedcount = $feedbackstructure->count_completed_responses($mygroupid);
85
    if ($completedcount < FEEDBACK_MIN_ANONYMOUS_COUNT_IN_GROUP) {
86
        $check_anonymously = false;
87
    }
88
}
89
 
90
echo '<div>';
91
if ($check_anonymously) {
92
    // Print the items in an analysed form.
93
    foreach ($items as $item) {
94
        $itemobj = feedback_get_item_class($item->typ);
95
        $printnr = ($feedback->autonumbering && $item->itemnr) ? ($item->itemnr . '.') : '';
96
        $itemobj->print_analysed($item, $printnr, $mygroupid);
97
    }
98
} else {
99
    echo $OUTPUT->heading_with_help(get_string('insufficient_responses_for_this_group', 'feedback'),
100
                                    'insufficient_responses',
101
                                    'feedback', '', '', 3);
102
}
103
echo '</div>';
104
 
105
echo $OUTPUT->footer();