See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
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 * Export badges to the backpack site. 19 * 20 * @package core_badges 21 * @copyright 2020 Tung Thai 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 * @author Tung Thai <Tung.ThaiDuc@nashtechglobal.com> 24 */ 25 require_once(__DIR__ . '/../config.php'); 26 require_once($CFG->libdir . '/badgeslib.php'); 27 28 if (badges_open_badges_backpack_api() != OPEN_BADGES_V2P1) { 29 throw new coding_exception('backpacks only support Open Badges V2.1'); 30 } 31 $hash = optional_param('hash', null, PARAM_RAW); 32 33 $PAGE->set_pagelayout('admin'); 34 $url = new moodle_url('/badges/backpack-export.php'); 35 36 require_login(); 37 if (empty($CFG->badges_allowexternalbackpack) || empty($CFG->enablebadges)) { 38 redirect($CFG->wwwroot); 39 } 40 $backpack = badges_get_site_backpack($CFG->badges_site_backpack); 41 $userbadges = badges_get_user_badges($USER->id); 42 $context = context_user::instance($USER->id); 43 44 $PAGE->set_context($context); 45 $PAGE->set_url($url); 46 $title = get_string('badges', 'badges'); 47 $PAGE->set_title($title); 48 $PAGE->set_heading(fullname($USER)); 49 $PAGE->set_pagelayout('standard'); 50 51 $redirecturl = new moodle_url('/badges/mybadges.php'); 52 if ($hash) { 53 $backpack = badges_get_site_backpack($CFG->badges_site_backpack); 54 $api = new core_badges\backpack_api2p1($backpack); 55 $notify = $api->put_assertions($hash); 56 if (!empty($notify['status']) && $notify['status'] == \core\output\notification::NOTIFY_SUCCESS) { 57 redirect($redirecturl, $notify['message'], null, \core\output\notification::NOTIFY_SUCCESS); 58 } else if (!empty($notify['status']) && $notify['status'] == \core\output\notification::NOTIFY_ERROR) { 59 redirect($redirecturl, $notify['message'], null, \core\output\notification::NOTIFY_ERROR); 60 } 61 } 62 redirect($redirecturl);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body