Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 12... Línea 12...
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/>.
Línea 16... Línea -...
16
 
-
 
17
/**
-
 
18
 * Badge assertion library.
-
 
19
 *
-
 
20
 * @package    core
-
 
21
 * @subpackage badges
-
 
22
 * @copyright  2012 onwards Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
-
 
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
24
 * @author     Yuliya Bozhko <yuliya.bozhko@totaralms.com>
-
 
25
 */
-
 
26
 
16
 
Línea 27... Línea 17...
27
defined('MOODLE_INTERNAL') || die();
17
defined('MOODLE_INTERNAL') || die();
-
 
18
 
28
 
19
/**
29
/**
20
 * Open Badges Assertions specification 2.0
30
 * Open Badges Assertions specification 1.0 {@link https://github.com/mozilla/openbadges-backpack/wiki/Assertions}
21
 * {@link https://www.imsglobal.org/sites/default/files/Badges/OBv2p0Final/index.html#Assertion}
31
 *
22
 *
32
 * Badge asserion is defined by three parts:
23
 * Badge assertion is defined by three parts:
33
 * - Badge Assertion (information regarding a specific badge that was awarded to a badge earner)
24
 * - Badge Assertion (information regarding a specific badge that was awarded to a badge earner)
34
 * - Badge Class (general information about a badge and what it is intended to represent)
25
 * - Badge Class (general information about a badge and what it is intended to represent)
35
 * - Issuer Class (general information of an issuing organisation)
26
 * - Issuer Class (general information of an issuing organisation)
36
 */
27
 */
Línea 37... Línea 28...
37
require_once($CFG->libdir . '/badgeslib.php');
28
require_once($CFG->libdir . '/badgeslib.php');
38
require_once($CFG->dirroot . '/badges/renderer.php');
29
require_once($CFG->dirroot . '/badges/renderer.php');
39
 
30
 
-
 
31
/**
-
 
32
 * Class that represents badge assertion.
-
 
33
 *
-
 
34
 * @package    core_badges
40
/**
35
 * @copyright  2012 onwards Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
41
 * Class that represents badge assertion.
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
42
 *
37
 * @author     Yuliya Bozhko <yuliya.bozhko@totaralms.com>
43
 */
38
 */
Línea 203... Línea 198...
203
 
198
 
204
            $params = ['id' => $this->get_badge_id()];
199
            $params = ['id' => $this->get_badge_id()];
205
            $badgeurl = new moodle_url('/badges/badgeclass.php', $params);
200
            $badgeurl = new moodle_url('/badges/badgeclass.php', $params);
206
            $class['criteria'] = $badgeurl->out(false); // Currently badge URL.
201
            $class['criteria'] = $badgeurl->out(false); // Currently badge URL.
207
            if ($issued) {
202
            if ($issued) {
208
                $params = ['id' => $this->get_badge_id(), 'obversion' => $this->_obversion];
203
                $params = ['id' => $this->get_badge_id()];
209
                $issuerurl = new moodle_url('/badges/issuer_json.php', $params);
204
                $issuerurl = new moodle_url('/badges/issuer_json.php', $params);
210
                $class['issuer'] = $issuerurl->out(false);
205
                $class['issuer'] = $issuerurl->out(false);
211
            }
206
            }
212
            $tags = $this->get_tags();
207
            $tags = $this->get_tags();
Línea 225... Línea 220...
225
     * Get badge issuer information.
220
     * Get badge issuer information.
226
     *
221
     *
227
     * @return array Issuer information.
222
     * @return array Issuer information.
228
     */
223
     */
229
    public function get_issuer() {
224
    public function get_issuer() {
230
        global $CFG;
-
 
231
        $issuer = array();
-
 
232
        if ($this->_data) {
-
 
233
            // Required.
-
 
234
            if ($this->_obversion == OPEN_BADGES_V1) {
-
 
235
                $issuer['name'] = $this->_data->issuername;
-
 
236
                $issuer['url'] = $this->_data->issuerurl;
-
 
237
                // Optional.
-
 
238
                if (!empty($this->_data->issuercontact)) {
-
 
239
                    $issuer['email'] = $this->_data->issuercontact;
-
 
240
                } else {
-
 
241
                    $issuer['email'] = $CFG->badges_defaultissuercontact;
-
 
242
                }
-
 
243
            } else {
-
 
244
                $badge = new badge($this->get_badge_id());
225
        $badge = new badge($this->get_badge_id());
245
                $issuer = $badge->get_badge_issuer();
226
        $issuer = $badge->get_badge_issuer();
246
            }
-
 
247
        }
227
 
248
        $this->embed_data_badge_version2($issuer, OPEN_BADGES_V2_TYPE_ISSUER);
228
        $this->embed_data_badge_version2($issuer, OPEN_BADGES_V2_TYPE_ISSUER);
249
        return $issuer;
229
        return $issuer;
250
    }
230
    }
Línea 251... Línea 231...
251
 
231
 
Línea 375... Línea 355...
375
                $json['issuer'] = $this->get_issuer();
355
                $json['issuer'] = $this->get_issuer();
376
                $json['@language'] = $this->_data->language;
356
                $json['@language'] = $this->_data->language;
377
                if (!empty($relatedbadges = $this->get_related_badges($badge))) {
357
                if (!empty($relatedbadges = $this->get_related_badges($badge))) {
378
                    $json['related'] = $relatedbadges;
358
                    $json['related'] = $relatedbadges;
379
                }
359
                }
380
                if ($endorsement = $this->get_endorsement()) {
-
 
381
                    $endorsementurl = new moodle_url('/badges/endorsement_json.php', array('id' => $this->_data->id));
-
 
382
                    $json['endorsement'] = $endorsementurl->out(false);
-
 
383
                }
-
 
384
                if ($alignments = $this->get_alignments()) {
360
                if ($alignments = $this->get_alignments()) {
385
                    $json['alignments'] = $alignments;
361
                    $json['alignments'] = $alignments;
386
                }
362
                }
387
                if ($this->_data->imageauthorname ||
-
 
388
                        $this->_data->imageauthoremail ||
-
 
389
                        $this->_data->imageauthorurl ||
-
 
390
                        $this->_data->imagecaption) {
363
                if ($this->_data->imagecaption) {
391
                    $storage = get_file_storage();
364
                    $storage = get_file_storage();
392
                    $imagefile = $storage->get_file($context->id, 'badges', 'badgeimage', $this->_data->id, '/', 'f3.png');
365
                    $imagefile = $storage->get_file($context->id, 'badges', 'badgeimage', $this->_data->id, '/', 'f3.png');
393
                    if ($imagefile) {
366
                    if ($imagefile) {
394
                        $imagedata = base64_encode($imagefile->get_content());
367
                        $imagedata = base64_encode($imagefile->get_content());
395
                    } else {
368
                    } else {