| Línea 11... |
Línea 11... |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
// GNU General Public License for more details.
|
12 |
// GNU General Public License for more details.
|
| 13 |
//
|
13 |
//
|
| 14 |
// You should have received a copy of the GNU General Public License
|
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/>.
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
| - |
|
16 |
|
| 16 |
/**
|
17 |
/**
|
| 17 |
* Endorsement information
|
18 |
* Endorsement information
|
| 18 |
*
|
19 |
*
|
| 19 |
* @package core
|
20 |
* @package core_badges
|
| 20 |
* @subpackage badges
|
21 |
* @subpackage badges
|
| 21 |
* @copyright 2018 Tung Thai
|
22 |
* @copyright 2018 Tung Thai
|
| 22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 23 |
* @author Tung Thai <Tung.ThaiDuc@nashtechglobal.com>
|
24 |
* @author Tung Thai <Tung.ThaiDuc@nashtechglobal.com>
|
| 24 |
*/
|
25 |
*/
|
| - |
|
26 |
|
| - |
|
27 |
use core_badges\form\endorsement;
|
| - |
|
28 |
|
| 25 |
require_once(__DIR__ . '/../config.php');
|
29 |
require_once(__DIR__ . '/../config.php');
|
| 26 |
require_once($CFG->libdir . '/badgeslib.php');
|
30 |
require_once($CFG->libdir . '/badgeslib.php');
|
| 27 |
require_once($CFG->dirroot . '/badges/endorsement_form.php');
|
- |
|
| Línea 28... |
Línea 31... |
| 28 |
|
31 |
|
| Línea 29... |
Línea 32... |
| 29 |
$badgeid = required_param('id', PARAM_INT);
|
32 |
$badgeid = required_param('id', PARAM_INT);
|
| Línea 34... |
Línea 37... |
| 34 |
throw new \moodle_exception('badgesdisabled', 'badges');
|
37 |
throw new \moodle_exception('badgesdisabled', 'badges');
|
| 35 |
}
|
38 |
}
|
| Línea 36... |
Línea 39... |
| 36 |
|
39 |
|
| 37 |
$badge = new badge($badgeid);
|
40 |
$badge = new badge($badgeid);
|
| - |
|
41 |
$context = $badge->get_context();
|
| 38 |
$context = $badge->get_context();
|
42 |
$title = [get_string('bendorsement', 'badges'), $badge->name];
|
| 39 |
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type));
|
43 |
$navurl = new moodle_url('/badges/index.php', ['type' => $badge->type]);
|
| Línea 40... |
Línea 44... |
| 40 |
require_capability('moodle/badges:configuredetails', $context);
|
44 |
require_capability('moodle/badges:configuredetails', $context);
|
| 41 |
|
45 |
|
| 42 |
if ($badge->type == BADGE_TYPE_COURSE) {
|
46 |
if ($badge->type == BADGE_TYPE_COURSE) {
|
| 43 |
if (empty($CFG->badges_allowcoursebadges)) {
|
47 |
if (empty($CFG->badges_allowcoursebadges)) {
|
| 44 |
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
48 |
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
| 45 |
}
|
49 |
}
|
| 46 |
require_login($badge->courseid);
|
50 |
require_login($badge->courseid);
|
| - |
|
51 |
$course = get_course($badge->courseid);
|
| 47 |
$course = get_course($badge->courseid);
|
52 |
$heading = format_string($course->fullname, true, ['context' => $context]);
|
| 48 |
$heading = format_string($course->fullname, true, ['context' => $context]);
|
53 |
$title[] = $heading;
|
| 49 |
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid));
|
54 |
$navurl = new moodle_url('/badges/index.php', ['type' => $badge->type, 'id' => $badge->courseid]);
|
| 50 |
$PAGE->set_pagelayout('standard');
|
55 |
$PAGE->set_pagelayout('standard');
|
| 51 |
navigation_node::override_active_url($navurl);
|
56 |
navigation_node::override_active_url($navurl);
|
| 52 |
} else {
|
57 |
} else {
|
| 53 |
$PAGE->set_pagelayout('admin');
|
58 |
$PAGE->set_pagelayout('admin');
|
| 54 |
$heading = get_string('administrationsite');
|
59 |
$heading = get_string('administrationsite');
|
| Línea 55... |
Línea 60... |
| 55 |
navigation_node::override_active_url($navurl, true);
|
60 |
navigation_node::override_active_url($navurl, true);
|
| 56 |
}
|
61 |
}
|
| 57 |
|
62 |
|
| 58 |
$currenturl = new moodle_url('/badges/endorsement.php', array('id' => $badgeid));
|
63 |
$currenturl = new moodle_url('/badges/endorsement.php', ['id' => $badgeid]);
|
| 59 |
$PAGE->set_context($context);
|
64 |
$PAGE->set_context($context);
|
| 60 |
$PAGE->set_url($currenturl);
|
65 |
$PAGE->set_url($currenturl);
|
| Línea 61... |
Línea 66... |
| 61 |
$PAGE->set_heading($heading);
|
66 |
$PAGE->set_heading($heading);
|
| 62 |
$PAGE->set_title($badge->name);
|
67 |
$PAGE->set_title(implode(\moodle_page::TITLE_SEPARATOR, $title));
|
| 63 |
$PAGE->navbar->add($badge->name);
|
68 |
$PAGE->navbar->add($badge->name);
|
| Línea 76... |
Línea 81... |
| 76 |
echo $output->render_tertiary_navigation($actionbar);
|
81 |
echo $output->render_tertiary_navigation($actionbar);
|
| Línea 77... |
Línea 82... |
| 77 |
|
82 |
|
| 78 |
echo $OUTPUT->heading(print_badge_image($badge, $context, 'small') . ' ' . $badge->name);
|
83 |
echo $OUTPUT->heading(print_badge_image($badge, $context, 'small') . ' ' . $badge->name);
|
| Línea 79... |
Línea 84... |
| 79 |
echo $output->print_badge_status_box($badge);
|
84 |
echo $output->print_badge_status_box($badge);
|
| 80 |
|
85 |
|
| 81 |
$form = new endorsement_form($currenturl, array('badge' => $badge));
|
86 |
$form = new endorsement($currenturl, ['badge' => $badge]);
|
| 82 |
if ($form->is_cancelled()) {
|
87 |
if ($form->is_cancelled()) {
|
| 83 |
redirect(new moodle_url('/badges/overview.php', array('id' => $badgeid)));
|
88 |
redirect(new moodle_url('/badges/overview.php', ['id' => $badgeid]));
|
| 84 |
} else if ($form->is_submitted() && $form->is_validated() && ($data = $form->get_data())) {
|
89 |
} else if ($form->is_submitted() && $form->is_validated() && ($data = $form->get_data())) {
|
| 85 |
$endorsement = new stdClass();
|
90 |
$endorsement = new stdClass();
|
| 86 |
$endorsement->badgeid = $badgeid;
|
91 |
$endorsement->badgeid = $badgeid;
|