2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * IMS Enterprise enrol plugin implementation.
20 * @package enrol_imsenterprise
21 * @copyright 2010 Eugene Venter
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
29 * Class for dealing with role mappings in IMS Enterprise.
31 * @copyright 2010 Eugene Venter
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34 class imsenterprise_roles
{
35 /** @var imscode => ims role name. Role name mapping. */
41 public function __construct() {
42 $this->imsroles
= array(
45 '03' => 'Content Developer',
49 '07' => 'Administrator',
50 '08' => 'TeachingAssistant',
52 // PLEASE NOTE: It may seem odd that "Content Developer" has a space in it
53 // but "TeachingAssistant" doesn't. That's what the spec says though!!!
57 * Returns the mapped roles
59 * @return array of IMS roles indexed by IMS code.
61 public function get_imsroles() {
62 return $this->imsroles
;
66 * This function is only used when first setting up the plugin, to
67 * decide which role assignments to recommend by default.
68 * For example, IMS role '01' is 'Learner', so may map to 'student' in Moodle.
70 * @param string $imscode
72 public function determine_default_rolemapping($imscode) {
78 $shortname = 'student';
82 $shortname = 'teacher';
86 $shortname = 'editingteacher';
93 return 0; // Zero for no match.
95 return (string)$DB->get_field('role', 'id', array('shortname' => $shortname));
103 * Mapping between Moodle course attributes and IMS enterprise group description tags
105 * @package enrol_imsenterprise
106 * @copyright 2011 Aaron C Spike
107 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
109 class imsenterprise_courses
{
110 /** @var array IMS group description names */
112 /** @var array moodle course field names */
113 private $courseattrs;
118 public function __construct() {
119 $this->imsnames
= array(
123 'coursecode' => 'coursecode');
124 $this->courseattrs
= array('shortname', 'fullname', 'summary');
128 * Returns the assignable values for the course attribute
129 * @param string $courseattr The course attribute (shortname, fullname...)
130 * @return array Array of assignable values
132 public function get_imsnames($courseattr) {
134 $values = $this->imsnames
;
135 if ($courseattr == 'summary') {
136 $values = array_merge(array('ignore' => get_string('emptyattribute', 'enrol_imsenterprise')), $values);
145 public function get_courseattrs() {
146 return $this->courseattrs
;
150 * This function is only used when first setting up the plugin, to
151 * decide which name assignments to recommend by default.
153 * @param string $courseattr
156 public function determine_default_coursemapping($courseattr) {
157 switch($courseattr) {
162 $imsname = 'coursecode';