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
 * the first page to view the feedback
19
 *
20
 * @author Andreas Grabs
21
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
22
 * @package mod_feedback
23
 */
24
require_once(__DIR__ . '/../../config.php');
25
require_once($CFG->dirroot . '/mod/feedback/lib.php');
26
 
27
$id = required_param('id', PARAM_INT);
28
$courseid = optional_param('courseid', false, PARAM_INT);
29
 
30
list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
31
require_course_login($course, true, $cm);
32
$feedback = $PAGE->activityrecord;
33
 
34
$feedbackcompletion = new mod_feedback_completion($feedback, $cm, $courseid);
35
 
36
$context = context_module::instance($cm->id);
37
 
38
if ($course->id == SITEID) {
39
    $PAGE->set_pagelayout('incourse');
40
}
41
$PAGE->set_url('/mod/feedback/view.php', array('id' => $cm->id));
1441 ariadna 42
 
43
/** @var \mod_feedback\output\renderer $renderer */
44
$renderer = $PAGE->get_renderer('mod_feedback');
45
$renderer->set_title(
46
    [format_string($feedback->name), format_string($course->fullname)]
47
);
48
 
1 efrain 49
$PAGE->set_heading($course->fullname);
50
$PAGE->add_body_class('limitedwidth');
51
 
52
// Check whether the feedback is mapped to the given courseid.
53
if (!has_capability('mod/feedback:edititems', $context) &&
54
        !$feedbackcompletion->check_course_is_mapped()) {
55
    echo $OUTPUT->header();
56
    echo $OUTPUT->notification(get_string('cannotaccess', 'mod_feedback'));
57
    echo $OUTPUT->footer();
58
    exit;
59
}
60
 
61
$viewcompletion = $feedbackcompletion->is_open() && $feedbackcompletion->can_complete() && $feedbackcompletion->can_submit();
62
$actionbar = new \mod_feedback\output\standard_action_bar(
63
    $cm->id,
64
    $viewcompletion,
65
    $feedbackcompletion->get_resume_page(),
66
    $courseid
67
);
68
 
69
// Trigger module viewed event.
70
$feedbackcompletion->trigger_module_viewed();
71
 
72
/// Print the main part of the page
73
///////////////////////////////////////////////////////////////////////////
74
///////////////////////////////////////////////////////////////////////////
75
///////////////////////////////////////////////////////////////////////////
76
 
77
$previewimg = $OUTPUT->pix_icon('t/preview', get_string('preview'));
78
$previewlnk = new moodle_url('/mod/feedback/print.php', array('id' => $id));
79
if ($courseid) {
80
    $previewlnk->param('courseid', $courseid);
81
}
82
$preview = html_writer::link($previewlnk, $previewimg);
83
 
84
$PAGE->activityheader->set_description("");
85
 
86
// Print the page header.
87
echo $OUTPUT->header();
88
 
89
// Show description.
90
echo $OUTPUT->box_start('generalbox feedback_description');
91
$options = (object)array('noclean' => true);
92
echo format_module_intro('feedback', $feedback, $cm->id);
93
echo $renderer->main_action_bar($actionbar);
94
echo $OUTPUT->box_end();
95
 
96
//show some infos to the feedback
97
if (has_capability('mod/feedback:edititems', $context)) {
98
 
99
    echo $OUTPUT->heading(get_string('overview', 'feedback'), 3);
100
 
101
    //get the groupid
102
    $groupselect = groups_print_activity_menu($cm, $CFG->wwwroot.'/mod/feedback/view.php?id='.$cm->id, true);
103
    $mygroupid = groups_get_activity_group($cm);
104
 
105
    echo $groupselect.'<div class="clearer">&nbsp;</div>';
106
    $summary = new mod_feedback\output\summary($feedbackcompletion, $mygroupid);
107
    echo $OUTPUT->render_from_template('mod_feedback/summary', $summary->export_for_template($OUTPUT));
108
 
109
    if ($pageaftersubmit = $feedbackcompletion->page_after_submit()) {
110
        echo $OUTPUT->heading(get_string("page_after_submit", "feedback"), 3);
111
        echo $OUTPUT->box($pageaftersubmit, 'generalbox feedback_after_submit');
112
    }
113
}
114
 
115
if (!$PAGE->has_secondary_navigation()) {
116
    if (!has_capability('mod/feedback:viewreports', $context) &&
117
        $feedbackcompletion->can_view_analysis()) {
118
        $analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id' => $id));
119
        echo '<div class="mdl-align"><a href="' . $analysisurl->out() . '">';
120
        echo get_string('completed_feedbacks', 'feedback') . '</a>';
121
        echo '</div>';
122
    }
123
 
124
    if (has_capability('mod/feedback:mapcourse', $context) && $feedback->course == SITEID) {
125
        echo $OUTPUT->box_start('generalbox feedback_mapped_courses');
126
        echo $OUTPUT->heading(get_string("mappedcourses", "feedback"), 3);
127
        echo '<p>' . get_string('mapcourse_help', 'feedback') . '</p>';
128
        $mapurl = new moodle_url('/mod/feedback/mapcourse.php', array('id' => $id));
129
        echo '<p class="mdl-align">' . html_writer::link($mapurl, get_string('mapcourses', 'feedback')) . '</p>';
130
        echo $OUTPUT->box_end();
131
    }
132
}
133
 
134
if ($feedbackcompletion->can_complete()) {
135
    echo $OUTPUT->box_start('generalbox boxaligncenter');
136
    if (!$feedbackcompletion->is_open()) {
137
        // Feedback is not yet open or is already closed.
138
        echo $OUTPUT->notification(get_string('feedback_is_not_open', 'feedback'));
139
        echo $OUTPUT->continue_button(course_get_url($courseid ?: $course->id));
140
    } else if (!$feedbackcompletion->can_submit()) {
141
        // Feedback was already submitted.
1441 ariadna 142
        echo $OUTPUT->notification(
143
            get_string('this_feedback_is_already_submitted', 'feedback'),
144
            \core\output\notification::NOTIFY_INFO,
145
            closebutton: false,
146
        );
1 efrain 147
        $OUTPUT->continue_button(course_get_url($courseid ?: $course->id));
148
    }
149
    echo $OUTPUT->box_end();
150
}
151
 
152
echo $OUTPUT->footer();