| 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 |
* List alignments, skills, or standards are targeted by a BadgeClass.
|
18 |
* List alignments, skills, or standards are targeted by a BadgeClass.
|
| 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\alignment;
|
| - |
|
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/alignment_form.php');
|
- |
|
| Línea 28... |
Línea 31... |
| 28 |
|
31 |
|
| 29 |
$badgeid = required_param('id', PARAM_INT);
|
32 |
$badgeid = required_param('id', PARAM_INT);
|
| 30 |
$alignmentid = optional_param('alignmentid', 0, PARAM_INT);
|
33 |
$alignmentid = optional_param('alignmentid', 0, PARAM_INT);
|
| 31 |
$action = optional_param('action', '', PARAM_TEXT);
|
34 |
$action = optional_param('action', '', PARAM_TEXT);
|
| Línea 35... |
Línea 38... |
| 35 |
if (empty($CFG->enablebadges)) {
|
38 |
if (empty($CFG->enablebadges)) {
|
| 36 |
throw new \moodle_exception('badgesdisabled', 'badges');
|
39 |
throw new \moodle_exception('badgesdisabled', 'badges');
|
| 37 |
}
|
40 |
}
|
| 38 |
$badge = new badge($badgeid);
|
41 |
$badge = new badge($badgeid);
|
| 39 |
$context = $badge->get_context();
|
42 |
$context = $badge->get_context();
|
| - |
|
43 |
$title = [get_string('alignment', 'badges'), $badge->name];
|
| 40 |
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type));
|
44 |
$navurl = new moodle_url('/badges/index.php', ['type' => $badge->type]);
|
| 41 |
require_capability('moodle/badges:configuredetails', $context);
|
45 |
require_capability('moodle/badges:configuredetails', $context);
|
| Línea 42... |
Línea 46... |
| 42 |
|
46 |
|
| 43 |
if ($badge->type == BADGE_TYPE_COURSE) {
|
47 |
if ($badge->type == BADGE_TYPE_COURSE) {
|
| 44 |
if (empty($CFG->badges_allowcoursebadges)) {
|
48 |
if (empty($CFG->badges_allowcoursebadges)) {
|
| 45 |
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
49 |
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
| 46 |
}
|
50 |
}
|
| 47 |
require_login($badge->courseid);
|
51 |
require_login($badge->courseid);
|
| 48 |
$course = get_course($badge->courseid);
|
52 |
$course = get_course($badge->courseid);
|
| - |
|
53 |
$heading = format_string($course->fullname, true, ['context' => $context]);
|
| 49 |
$heading = format_string($course->fullname, true, ['context' => $context]);
|
54 |
$title[] = $heading;
|
| 50 |
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid));
|
55 |
$navurl = new moodle_url('/badges/index.php', ['type' => $badge->type, 'id' => $badge->courseid]);
|
| 51 |
$PAGE->set_pagelayout('standard');
|
56 |
$PAGE->set_pagelayout('standard');
|
| 52 |
navigation_node::override_active_url($navurl);
|
57 |
navigation_node::override_active_url($navurl);
|
| 53 |
} else {
|
58 |
} else {
|
| 54 |
$PAGE->set_pagelayout('admin');
|
59 |
$PAGE->set_pagelayout('admin');
|
| 55 |
$heading = get_string('administrationsite');
|
60 |
$heading = get_string('administrationsite');
|
| 56 |
navigation_node::override_active_url($navurl, true);
|
61 |
navigation_node::override_active_url($navurl, true);
|
| Línea 57... |
Línea 62... |
| 57 |
}
|
62 |
}
|
| 58 |
|
63 |
|
| 59 |
$currenturl = new moodle_url('/badges/alignment.php', array('id' => $badge->id));
|
64 |
$currenturl = new moodle_url('/badges/alignment.php', ['id' => $badge->id]);
|
| 60 |
$PAGE->set_context($context);
|
65 |
$PAGE->set_context($context);
|
| 61 |
$PAGE->set_url($currenturl);
|
66 |
$PAGE->set_url($currenturl);
|
| 62 |
$PAGE->set_heading($heading);
|
67 |
$PAGE->set_heading($heading);
|
| Línea 63... |
Línea 68... |
| 63 |
$PAGE->set_title($badge->name);
|
68 |
$PAGE->set_title(implode(\moodle_page::TITLE_SEPARATOR, $title));
|
| 64 |
$PAGE->navbar->add($badge->name);
|
69 |
$PAGE->navbar->add($badge->name);
|
| 65 |
|
70 |
|
| 66 |
$output = $PAGE->get_renderer('core', 'badges');
|
71 |
$output = $PAGE->get_renderer('core', 'badges');
|
| 67 |
$msg = optional_param('msg', '', PARAM_TEXT);
|
72 |
$msg = optional_param('msg', '', PARAM_TEXT);
|
| 68 |
$emsg = optional_param('emsg', '', PARAM_TEXT);
|
73 |
$emsg = optional_param('emsg', '', PARAM_TEXT);
|
| 69 |
$url = new moodle_url('/badges/alignment.php', array('id' => $badge->id, 'action' => $action, 'alignmentid' => $alignmentid));
|
74 |
$url = new moodle_url('/badges/alignment.php', ['id' => $badge->id, 'action' => $action, 'alignmentid' => $alignmentid]);
|
| 70 |
$mform = new alignment_form($url, array('badge' => $badge, 'action' => $action, 'alignmentid' => $alignmentid));
|
75 |
$mform = new alignment($url, ['badge' => $badge, 'action' => $action, 'alignmentid' => $alignmentid]);
|
| 71 |
if ($mform->is_cancelled()) {
|
76 |
if ($mform->is_cancelled()) {
|
| 72 |
redirect($currenturl);
|
77 |
redirect($currenturl);
|
| Línea 96... |
Línea 101... |
| 96 |
|
101 |
|
| 97 |
if ($alignmentid || $action == 'add' || $action == 'edit') {
|
102 |
if ($alignmentid || $action == 'add' || $action == 'edit') {
|
| 98 |
$mform->display();
|
103 |
$mform->display();
|
| 99 |
} else if (empty($action)) {
|
104 |
} else if (empty($action)) {
|
| 100 |
if (!$badge->is_active() && !$badge->is_locked()) {
|
105 |
if (!$badge->is_active() && !$badge->is_locked()) {
|
| 101 |
$urlbutton = new moodle_url('/badges/alignment.php', array('id' => $badge->id, 'action' => 'add'));
|
106 |
$urlbutton = new moodle_url('/badges/alignment.php', ['id' => $badge->id, 'action' => 'add']);
|
| 102 |
echo $OUTPUT->box($OUTPUT->single_button($urlbutton, get_string('addalignment', 'badges')), 'clearfix mdl-align');
|
107 |
echo $OUTPUT->box($OUTPUT->single_button($urlbutton, get_string('addalignment', 'badges')), 'clearfix mdl-align');
|
| 103 |
}
|
108 |
}
|
| 104 |
$alignments = $badge->get_alignments();
|
109 |
$alignments = $badge->get_alignments();
|
| 105 |
if (count($alignments) > 0) {
|
110 |
if (count($alignments) > 0) {
|