| Línea 8... |
Línea 8... |
| 8 |
global $CFG, $DB, $COURSE;
|
8 |
global $CFG, $DB, $COURSE;
|
| Línea 9... |
Línea 9... |
| 9 |
|
9 |
|
| 10 |
$id = required_param('id', PARAM_INT); // Course Module ID.
|
10 |
$id = required_param('id', PARAM_INT); // Course Module ID.
|
| Línea 11... |
Línea 11... |
| 11 |
$rating = required_param('rating', PARAM_INT); // User selection.
|
11 |
$rating = required_param('rating', PARAM_INT); // User selection.
|
| 12 |
|
12 |
|
| 13 |
if (! $course = $DB->get_record('course', array('id'=>$id))) {
|
13 |
if (! $course = $DB->get_record('course', array('id' => $id))) {
|
| Línea 14... |
Línea 14... |
| 14 |
print_error('Course ID not found');
|
14 |
print_error('Course ID not found');
|
| 15 |
}
|
15 |
}
|
| Línea 22... |
Línea 22... |
| 22 |
|
22 |
|
| 23 |
require_capability('block/cesa_course_rating:rate', $context);
|
23 |
require_capability('block/cesa_course_rating:rate', $context);
|
| Línea 24... |
Línea 24... |
| 24 |
global $USER;
|
24 |
global $USER;
|
| 25 |
|
25 |
|
| 26 |
if ($form = data_submitted()) {
|
26 |
if ($form = data_submitted()) {
|
| 27 |
if ($DB->count_records('block_cesa_course_rating', array('course'=>$COURSE->id, 'user'=>$USER->id))) {
|
27 |
if ($DB->count_records('block_cesa_course_rating', array('course' => $COURSE->id, 'user' => $USER->id))) {
|
| 28 |
$test = $DB->get_record('block_cesa_course_rating', array('course'=>$COURSE->id, 'user'=>$USER->id));
|
28 |
$test = $DB->get_record('block_cesa_course_rating', array('course' => $COURSE->id, 'user' => $USER->id));
|
| Línea 29... |
Línea 29... |
| 29 |
$DB->update_record('block_cesa_course_rating', array('id'=>$test->id, 'rating'=>$rating));
|
29 |
$DB->update_record('block_cesa_course_rating', array('id' => $test->id, 'rating' => $rating));
|
| 30 |
} else {
|
30 |
} else {
|
| 31 |
|
- |
|
| 32 |
$DB->insert_record( 'block_cesa_course_rating', array('course'=>$COURSE->id, 'user'=>$USER->id, 'rating'=>$rating));
|
- |
|
| 33 |
}
|
31 |
|