Proyectos de Subversion Moodle

Rev

| 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
 * Rate this course
19
 *
20
 * @package    block
21
 * @subpackage rate_course
22
 * @copyright  2009 Jenny Gray
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 *
25
 * Code was Rewritten for Moodle 2.X By Atar + Plus LTD for Comverse LTD.
26
 * @copyright &copy; 2011 Comverse LTD.
27
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
28
 */
29
 
30
require_once( '../../config.php' );
31
require_once( $CFG->dirroot .'/lib/pagelib.php' );
32
 
33
$courseid = required_param( 'courseid', PARAM_INT );
34
//  Load the course.
35
$course = $DB->get_record('course', array('id'=>$courseid));
36
global $COURSE, $PAGE;
37
$COURSE = $course;
38
$context = get_context_instance(CONTEXT_COURSE, $courseid);
39
$PAGE->set_context($context);
40
$PAGE->set_url('/blocks/rate_course/rate.php', array('courseid'=>$courseid));
41
$title = get_string('giverating', 'block_rate_course');
42
$link[] = array('name' => $title, 'link' => '', 'type' => 'misc');
43
$link = build_navigation($link);
44
print_header_simple($title, $title, $link);
45
 
46
//  Require user to be logged in to view this page.
47
if ((!isloggedin() || isguestuser())) {
48
    notice_yesno(get_string('noguestuseage', 'block_rate_course').'<br /><br />'.get_string('liketologin'),
49
    $CFG->wwwroot.'/login/index.php', get_referer(false));
50
    echo $OUTPUT->footer();
51
    exit();
52
}
53
require_capability('block/rate_course:rate', $context);
54
 
55
echo "<div style='text-align:center'>";
56
$block = block_instance('rate_course');
57
$block->display_rating($course->id);
58
 
59
$existing_answer = $DB->get_record('block_rate_course',
60
        array('course'=>$course->id, 'userid'=>$USER->id));
61
if ($existing_answer) {
62
    $rate_text = get_string('completed', 'block_rate_course');
63
} else {
64
    $rate_text = get_string('intro', 'block_rate_course');
65
}
66
echo "<div><p>$rate_text</p></div>";
67
 
68
// Now output the form.
69
echo '<form method="post" action="'.
70
        $CFG->wwwroot.'/blocks/rate_course/update.php">
71
        <p><input name="id" type="hidden" value="'.$course->id.'" /></p><p>';
72
 
73
for ($i = 1; $i <= 5; $i++) {
74
    $checked = '';
75
    if (isset($existing_answer) && ($existing_answer !== false)) {
76
        if ($existing_answer->rating == $i) {
77
                $checked = 'checked="checked"';
78
        }
79
    }
80
 
81
    echo '<input type="radio" name="grade" ';
82
    if ($existing_answer) {
83
        echo 'disabled="disabled" ';
84
    }
85
    echo 'value="'.$i.'" '.$checked.' alt="Rating of '.$i.'"  />'.$i.' ';
86
}
87
 
88
echo '</p><p><input type="submit" value="'.get_string('submit', 'block_rate_course').'"';
89
if ($existing_answer) {
90
    echo 'disabled';
91
}
92
echo '/></p></form>';
93
 
94
echo '</div>';
95
 
96
echo $OUTPUT->footer($course);