mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-29070 enrol_imsenterprise: more code cleanups
Including: * fix whitespace * coding style fixes: * Declare method visibility * Don't have variable names with underscores * Comments without . * if/for loop spacing * Unused variables * Split long lines * Removed outdates files * moodlecheck warnings * code checker warnings
This commit is contained in:
parent
1ee378bbdc
commit
295e4fa8f4
@ -1,63 +0,0 @@
|
||||
|
||||
IMS Enterprise 1.1 file enrolment module for Moodle
|
||||
(also reported to work with v1.01 and v1.0 data)
|
||||
|
||||
(c) 2005-2006 Dan Stowell
|
||||
Released under the Gnu Public Licence (GPL)
|
||||
|
||||
INSTALLATION
|
||||
|
||||
Please see INSTALL.txt.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This enrolment script will repeatedly read an XML file from a
|
||||
specified location. The XML file should conform to the IMS Enterprise
|
||||
1.1 specification, containing <person>, <group>, and <membership>
|
||||
elements to specify which students/teachers should be added/removed
|
||||
from the course. User accounts and/or Moodle courses can be created
|
||||
by the script if they aren't yet registered (this is an option which
|
||||
can be turned on/off).
|
||||
|
||||
(The IMS 1.0 specification is significantly different from the 1.1
|
||||
spec. This code has been made flexible so it should in theory be
|
||||
able to handle IMS 1.0 as well, but I haven't directly tested it
|
||||
with v1.0 Enterprise data.
|
||||
The one restriction that may be important is that the plugin assumes
|
||||
that the <membership> elements come after the others. The 1.1 spec
|
||||
demands this, but the 1.0 spec does not make this restriction.)
|
||||
|
||||
|
||||
HOW USERS/COURSES ARE MATCHED AGAINST MOODLE'S DATABASE
|
||||
|
||||
IMS Enterprise data typically contains a "sourcedid" for each person
|
||||
or group (course) record, which represents the canonical identifier
|
||||
used by the source system. This is separate from the "userid" for a
|
||||
person, which is also present in the data and should represent the
|
||||
login userid which a person is intended to use in Moodle. (In some
|
||||
systems these may have the same value.)
|
||||
|
||||
This script uses the "sourcedid" as the lookup to determine if the
|
||||
user/course exists in the database, in both cases looking at the
|
||||
"idnumber" field. This "idnumber" is not typically displayed in
|
||||
Moodle. When creating a user, the "userid" field must not be blank,
|
||||
because it is stored as the user's Moodle login ID.
|
||||
|
||||
|
||||
TECHNICAL NOTE
|
||||
|
||||
The script uses an optimised pattern-matching (regex) method for
|
||||
processing the XML, rather than any built-in XML handling. This is for
|
||||
two reasons: firstly, because some systems produce very sloppy
|
||||
(even invalid) XML and we'd like to be able to process it anyway; and
|
||||
secondly, because PHP 4 and PHP 5 handle XML differently, and we'd
|
||||
like to be independent of that changeover.
|
||||
|
||||
|
||||
|
||||
FOR MORE INFO / HELP
|
||||
|
||||
Please visit the community forums at www.moodle.org and search to see
|
||||
if any relevant help has already been posted. If not, ask away!
|
||||
|
@ -1,39 +0,0 @@
|
||||
DEVELOPMENT PRIORITIES, IN ORDER OF PRIORITY:
|
||||
|
||||
|
||||
|
||||
TO DO:
|
||||
|
||||
- Handling of references to <group>s as <member>s
|
||||
|
||||
- Support for enrolling using multiple files? At present only one filename
|
||||
is supported. Some systems may wish/need to do multiple. This may be tricky
|
||||
since multiple filepaths may be too long for a single moodle config
|
||||
variable (255 chars max)
|
||||
|
||||
- Process group's "relationship"?
|
||||
|
||||
- Activate <photo> handling, dependent upon acceptance of
|
||||
modification to Moodle's gdlib.php
|
||||
|
||||
|
||||
|
||||
DONE:
|
||||
|
||||
v0.6:
|
||||
|
||||
- Reduce processing from two passes to one pass (dependent on <membership> tags
|
||||
coming after any person/group tags to which they refer)
|
||||
|
||||
- The log data should NOT contain any personal information! NO STUDENT NAMES
|
||||
|
||||
- Support for restricting according to <target>
|
||||
|
||||
- Support for recstatus attribute on group/person/role
|
||||
|
||||
- Processing of <timeframe> tag to add ability to specify start/end of enrolment
|
||||
|
||||
- Write conformance summary
|
||||
|
||||
|
||||
|
@ -24,6 +24,9 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Post installation procedure
|
||||
*/
|
||||
function xmldb_enrol_imsenterprise_install() {
|
||||
global $CFG, $DB;
|
||||
|
||||
|
@ -18,31 +18,31 @@
|
||||
* This file keeps track of upgrades to the imsenterprise enrolment plugin
|
||||
*
|
||||
* @package enrol_imsenterprise
|
||||
* @copyright 2011 Petr Skoda {@link http://skodak.org
|
||||
* @copyright 2011 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Performs upgrade of the database structure and data
|
||||
*
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool true
|
||||
*/
|
||||
function xmldb_enrol_imsenterprise_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,246 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Enterprise Conformance Summary for v1.1</title>
|
||||
<style type="text/css">
|
||||
dl {}
|
||||
dl dt { font-weight: bold; margin-top: 10px; font-size: 24pt; }
|
||||
dl dd {margin-left: 20px; padding-left: 0px;}
|
||||
dl dd dl dt {background: black; color: white; font-size: 12pt; }
|
||||
dl dd dl dd dl dt {background: white; color: black; }
|
||||
td.y {background-color: rgb(210, 255, 210);}
|
||||
td.n {background-color: rgb(255, 230, 230);}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Exported from Jreepad -->
|
||||
<dl>
|
||||
<dt><a name="Enterprise Conformance Summary for v1.1"></a>Enterprise Conformance Summary for v1.1</dt>
|
||||
<dd>
|
||||
<p>This table gives a summmary of the elements that may be found in an IMS Enterprise 1.1 data file,
|
||||
and Moodle's suppport for those elements via this enrolment plugin.</p>
|
||||
<table border='1' cellspacing='0' cellpadding='2'>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>Accept</td>
|
||||
<td>Notes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>properties</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>person</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> recstatus</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> sourcedid</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> userid</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> name</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> demographics</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> email</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> url</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> tel</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> adr</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> photo</td>
|
||||
<td>Y?</td>
|
||||
<td>This currently is possible but requires a small modification to one of Moodle's
|
||||
library files, so for a standard simple installation, the import of user photos is
|
||||
not supported.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> systemrole</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> institutionrole</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> datasource</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>group</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> recstatus</td>
|
||||
<td class="y">Y</td>
|
||||
<td>"Delete" command will hide rather than permanently delete a course.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> sourcedid</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> grouptype</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> description</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> org</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> timeframe</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> enrollcontrol</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> email</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> url</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> relationship</td>
|
||||
<td class="n">N</td>
|
||||
<td>This could be useful to implement in future, to specify also-known-as (i.e. course aliases)...</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> datasource</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>membership</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> sourcedid</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> member</td>
|
||||
<td class="y">Y</td>
|
||||
<td>NB: Can only enrol <person>s as members - not <group>s (idtype=2)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> sourcedid</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> role</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> recstatus</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> subrole</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> status</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> userid</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> datetime</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> timeframe</td>
|
||||
<td class="y">Y</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> imterimresult</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> finalresult</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> email</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> datasource</td>
|
||||
<td class="n">N</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table></dd>
|
||||
</dl>
|
||||
<p>Note: All the core data structures are supported.</p>
|
||||
</body>
|
||||
</html>
|
@ -1,11 +1,33 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Import IMS Enterprise file immediately.
|
||||
*
|
||||
* @package enrol_imsenterprise
|
||||
* @copyright 2006 Dan Stowell
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_login(0, false);
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
$site = get_site();
|
||||
|
||||
/// get language strings
|
||||
// Get language strings.
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
$PAGE->set_url('/enrol/imsenterprise/importnow.php');
|
||||
@ -14,7 +36,8 @@ $PAGE->set_heading(get_string('importimsfile', 'enrol_imsenterprise'));
|
||||
$PAGE->navbar->add(get_string('administrationsite'));
|
||||
$PAGE->navbar->add(get_string('plugins', 'admin'));
|
||||
$PAGE->navbar->add(get_string('enrolments', 'enrol'));
|
||||
$PAGE->navbar->add(get_string('pluginname', 'enrol_imsenterprise'), new moodle_url('/admin/settings.php', array('section'=>'enrolsettingsimsenterprise')));
|
||||
$PAGE->navbar->add(get_string('pluginname', 'enrol_imsenterprise'),
|
||||
new moodle_url('/admin/settings.php', array('section' => 'enrolsettingsimsenterprise')));
|
||||
$PAGE->navbar->add(get_string('importimsfile', 'enrol_imsenterprise'));
|
||||
$PAGE->navigation->clear_cache();
|
||||
|
||||
@ -22,17 +45,12 @@ echo $OUTPUT->header();
|
||||
|
||||
require_once('lib.php');
|
||||
|
||||
//echo "Creating the IMS Enterprise enroller object\n";
|
||||
$enrol = new enrol_imsenterprise_plugin();
|
||||
|
||||
?>
|
||||
<p>Launching the IMS Enterprise "cron" function. The import log will appear below (giving details of any
|
||||
problems that might require attention).</p>
|
||||
<pre style="margin:10px; padding: 2px; border: 1px solid black; background-color: white; color: black;"><?php
|
||||
//error_reporting(E_ALL);
|
||||
$enrol->cron();
|
||||
?></pre><?php
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
exit;
|
||||
?>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,34 +25,51 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Class for dealing with role mappings in IMS Enterprise.
|
||||
*
|
||||
* @copyright 2010 Eugene Venter
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class imsenterprise_roles {
|
||||
/** @var imscode => ims role name. Role name mapping. */
|
||||
private $imsroles;
|
||||
|
||||
function __construct() {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->imsroles = array(
|
||||
'01'=>'Learner',
|
||||
'02'=>'Instructor',
|
||||
'03'=>'Content Developer',
|
||||
'04'=>'Member',
|
||||
'05'=>'Manager',
|
||||
'06'=>'Mentor',
|
||||
'07'=>'Administrator',
|
||||
'08'=>'TeachingAssistant',
|
||||
'01' => 'Learner',
|
||||
'02' => 'Instructor',
|
||||
'03' => 'Content Developer',
|
||||
'04' => 'Member',
|
||||
'05' => 'Manager',
|
||||
'06' => 'Mentor',
|
||||
'07' => 'Administrator',
|
||||
'08' => 'TeachingAssistant',
|
||||
);
|
||||
// PLEASE NOTE: It may seem odd that "Content Developer" has a space in it
|
||||
// but "TeachingAssistant" doesn't. That's what the spec says though!!!
|
||||
}
|
||||
|
||||
function get_imsroles() {
|
||||
/**
|
||||
* Returns the mapped roles
|
||||
*
|
||||
* @return array of IMS roles indexed by IMS code.
|
||||
*/
|
||||
public function get_imsroles() {
|
||||
return $this->imsroles;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is only used when first setting up the plugin, to
|
||||
* decide which role assignments to recommend by default.
|
||||
* For example, IMS role '01' is 'Learner', so may map to 'student' in Moodle.
|
||||
*/
|
||||
function determine_default_rolemapping($imscode) {
|
||||
* This function is only used when first setting up the plugin, to
|
||||
* decide which role assignments to recommend by default.
|
||||
* For example, IMS role '01' is 'Learner', so may map to 'student' in Moodle.
|
||||
*
|
||||
* @param string $imscode
|
||||
*/
|
||||
public function determine_default_rolemapping($imscode) {
|
||||
global $DB;
|
||||
|
||||
switch($imscode) {
|
||||
@ -73,13 +90,13 @@ class imsenterprise_roles {
|
||||
$shortname = 'admin';
|
||||
break;
|
||||
default:
|
||||
return 0; // Zero for no match
|
||||
return 0; // Zero for no match.
|
||||
}
|
||||
return (string)$DB->get_field('role', 'id', array('shortname'=>$shortname));
|
||||
return (string)$DB->get_field('role', 'id', array('shortname' => $shortname));
|
||||
}
|
||||
|
||||
|
||||
} // class
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -90,14 +107,15 @@ class imsenterprise_roles {
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class imsenterprise_courses {
|
||||
|
||||
/** @var array IMS group description names */
|
||||
private $imsnames;
|
||||
/** @var array moodle course field names */
|
||||
private $courseattrs;
|
||||
|
||||
/**
|
||||
* Loads default
|
||||
*/
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
$this->imsnames = array(
|
||||
'short' => 'short',
|
||||
'long' => 'long',
|
||||
@ -111,7 +129,7 @@ class imsenterprise_courses {
|
||||
* @param string $courseattr The course attribute (shortname, fullname...)
|
||||
* @return array Array of assignable values
|
||||
*/
|
||||
function get_imsnames($courseattr) {
|
||||
public function get_imsnames($courseattr) {
|
||||
|
||||
$values = $this->imsnames;
|
||||
if ($courseattr == 'summary') {
|
||||
@ -124,7 +142,7 @@ class imsenterprise_courses {
|
||||
* courseattrs getter
|
||||
* @return array
|
||||
*/
|
||||
function get_courseattrs() {
|
||||
public function get_courseattrs() {
|
||||
return $this->courseattrs;
|
||||
}
|
||||
|
||||
@ -132,10 +150,10 @@ class imsenterprise_courses {
|
||||
* This function is only used when first setting up the plugin, to
|
||||
* decide which name assignments to recommend by default.
|
||||
*
|
||||
* @param string $coursename
|
||||
* @param string $courseattr
|
||||
* @return string
|
||||
*/
|
||||
function determine_default_coursemapping($courseattr) {
|
||||
public function determine_default_coursemapping($courseattr) {
|
||||
switch($courseattr) {
|
||||
case 'fullname':
|
||||
$imsname = 'short';
|
||||
@ -149,5 +167,4 @@ class imsenterprise_courses {
|
||||
|
||||
return $imsname;
|
||||
}
|
||||
|
||||
} // class
|
||||
}
|
||||
|
@ -27,31 +27,43 @@ defined('MOODLE_INTERNAL') || die();
|
||||
if ($ADMIN->fulltree) {
|
||||
require_once($CFG->dirroot.'/enrol/imsenterprise/locallib.php');
|
||||
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_settings', '', get_string('pluginname_desc', 'enrol_imsenterprise')));
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_settings', '',
|
||||
get_string('pluginname_desc', 'enrol_imsenterprise')));
|
||||
|
||||
//--- general settings -----------------------------------------------------------------------------------
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_basicsettings', get_string('basicsettings', 'enrol_imsenterprise'), ''));
|
||||
// General settings.
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_basicsettings',
|
||||
get_string('basicsettings', 'enrol_imsenterprise'), ''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('enrol_imsenterprise/imsfilelocation', get_string('location', 'enrol_imsenterprise'), '', ''));
|
||||
$settings->add(new admin_setting_configtext('enrol_imsenterprise/imsfilelocation',
|
||||
get_string('location', 'enrol_imsenterprise'), '', ''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('enrol_imsenterprise/logtolocation', get_string('logtolocation', 'enrol_imsenterprise'), '', ''));
|
||||
$settings->add(new admin_setting_configtext('enrol_imsenterprise/logtolocation',
|
||||
get_string('logtolocation', 'enrol_imsenterprise'), '', ''));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/mailadmins', get_string('mailadmins', 'enrol_imsenterprise'), '', 0));
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/mailadmins',
|
||||
get_string('mailadmins', 'enrol_imsenterprise'), '', 0));
|
||||
|
||||
//--- user data options ---------------------------------------------------------------------------------
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_usersettings', get_string('usersettings', 'enrol_imsenterprise'), ''));
|
||||
// User data options.
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_usersettings',
|
||||
get_string('usersettings', 'enrol_imsenterprise'), ''));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewusers', get_string('createnewusers', 'enrol_imsenterprise'), get_string('createnewusers_desc', 'enrol_imsenterprise'), 0));
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewusers',
|
||||
get_string('createnewusers', 'enrol_imsenterprise'), get_string('createnewusers_desc', 'enrol_imsenterprise'), 0));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imsdeleteusers', get_string('deleteusers', 'enrol_imsenterprise'), get_string('deleteusers_desc', 'enrol_imsenterprise'), 0));
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imsdeleteusers',
|
||||
get_string('deleteusers', 'enrol_imsenterprise'), get_string('deleteusers_desc', 'enrol_imsenterprise'), 0));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/fixcaseusernames', get_string('fixcaseusernames', 'enrol_imsenterprise'), '', 0));
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/fixcaseusernames',
|
||||
get_string('fixcaseusernames', 'enrol_imsenterprise'), '', 0));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/fixcasepersonalnames', get_string('fixcasepersonalnames', 'enrol_imsenterprise'), '', 0));
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/fixcasepersonalnames',
|
||||
get_string('fixcasepersonalnames', 'enrol_imsenterprise'), '', 0));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imssourcedidfallback', get_string('sourcedidfallback', 'enrol_imsenterprise'), get_string('sourcedidfallback_desc', 'enrol_imsenterprise'), 0));
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imssourcedidfallback',
|
||||
get_string('sourcedidfallback', 'enrol_imsenterprise'), get_string('sourcedidfallback_desc', 'enrol_imsenterprise'), 0));
|
||||
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_usersettings_roles', get_string('roles', 'enrol_imsenterprise'), get_string('imsrolesdescription', 'enrol_imsenterprise')));
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_usersettings_roles',
|
||||
get_string('roles', 'enrol_imsenterprise'), get_string('imsrolesdescription', 'enrol_imsenterprise')));
|
||||
|
||||
if (!during_initial_install()) {
|
||||
$coursecontext = context_course::instance(SITEID);
|
||||
@ -59,41 +71,55 @@ if ($ADMIN->fulltree) {
|
||||
$assignableroles = array('0' => get_string('ignore', 'enrol_imsenterprise')) + $assignableroles;
|
||||
$imsroles = new imsenterprise_roles();
|
||||
foreach ($imsroles->get_imsroles() as $imsrolenum => $imsrolename) {
|
||||
$settings->add(new admin_setting_configselect('enrol_imsenterprise/imsrolemap'.$imsrolenum, format_string('"'.$imsrolename.'" ('.$imsrolenum.')'), '', (int)$imsroles->determine_default_rolemapping($imsrolenum), $assignableroles));
|
||||
$settings->add(new admin_setting_configselect('enrol_imsenterprise/imsrolemap'.$imsrolenum,
|
||||
format_string('"'.$imsrolename.'" ('.$imsrolenum.')'), '',
|
||||
(int)$imsroles->determine_default_rolemapping($imsrolenum), $assignableroles));
|
||||
}
|
||||
}
|
||||
|
||||
//--- course data options -------------------------------------------------------------------------------
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_coursesettings', get_string('coursesettings', 'enrol_imsenterprise'), ''));
|
||||
// Course data options.
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_coursesettings',
|
||||
get_string('coursesettings', 'enrol_imsenterprise'), ''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('enrol_imsenterprise/truncatecoursecodes', get_string('truncatecoursecodes', 'enrol_imsenterprise'), get_string('truncatecoursecodes_desc', 'enrol_imsenterprise'), 0, PARAM_INT, 2));
|
||||
$settings->add(new admin_setting_configtext('enrol_imsenterprise/truncatecoursecodes',
|
||||
get_string('truncatecoursecodes', 'enrol_imsenterprise'), get_string('truncatecoursecodes_desc', 'enrol_imsenterprise'),
|
||||
0, PARAM_INT, 2));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewcourses', get_string('createnewcourses', 'enrol_imsenterprise'), get_string('createnewcourses_desc', 'enrol_imsenterprise'), 0));
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewcourses',
|
||||
get_string('createnewcourses', 'enrol_imsenterprise'), get_string('createnewcourses_desc', 'enrol_imsenterprise'), 0));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewcategories', get_string('createnewcategories', 'enrol_imsenterprise'), get_string('createnewcategories_desc', 'enrol_imsenterprise'), 0));
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewcategories',
|
||||
get_string('createnewcategories', 'enrol_imsenterprise'), get_string('createnewcategories_desc', 'enrol_imsenterprise'),
|
||||
0));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imsunenrol', get_string('allowunenrol', 'enrol_imsenterprise'), get_string('allowunenrol_desc', 'enrol_imsenterprise'), 0));
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imsunenrol',
|
||||
get_string('allowunenrol', 'enrol_imsenterprise'), get_string('allowunenrol_desc', 'enrol_imsenterprise'), 0));
|
||||
|
||||
if (!during_initial_install()) {
|
||||
$imscourses = new imsenterprise_courses();
|
||||
foreach ($imscourses->get_courseattrs() as $courseattr) {
|
||||
|
||||
// The assignable values of this course attribute
|
||||
// The assignable values of this course attribute.
|
||||
$assignablevalues = $imscourses->get_imsnames($courseattr);
|
||||
$name = get_string('setting' . $courseattr, 'enrol_imsenterprise');
|
||||
$description = get_string('setting' . $courseattr . 'description', 'enrol_imsenterprise');
|
||||
$defaultvalue = (string) $imscourses->determine_default_coursemapping($courseattr);
|
||||
$settings->add(new admin_setting_configselect('enrol_imsenterprise/imscoursemap' . $courseattr, $name, $description, $defaultvalue, $assignablevalues));
|
||||
$settings->add(new admin_setting_configselect('enrol_imsenterprise/imscoursemap' . $courseattr, $name,
|
||||
$description, $defaultvalue, $assignablevalues));
|
||||
}
|
||||
}
|
||||
|
||||
//--- miscellaneous -------------------------------------------------------------------------------------
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_miscsettings', get_string('miscsettings', 'enrol_imsenterprise'), ''));
|
||||
// Miscellaneous.
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_miscsettings',
|
||||
get_string('miscsettings', 'enrol_imsenterprise'), ''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('enrol_imsenterprise/imsrestricttarget', get_string('restricttarget', 'enrol_imsenterprise'), get_string('restricttarget_desc', 'enrol_imsenterprise'), ''));
|
||||
$settings->add(new admin_setting_configtext('enrol_imsenterprise/imsrestricttarget',
|
||||
get_string('restricttarget', 'enrol_imsenterprise'), get_string('restricttarget_desc', 'enrol_imsenterprise'), ''));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imscapitafix', get_string('usecapitafix', 'enrol_imsenterprise'), get_string('usecapitafix_desc', 'enrol_imsenterprise'), 0));
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imscapitafix',
|
||||
get_string('usecapitafix', 'enrol_imsenterprise'), get_string('usecapitafix_desc', 'enrol_imsenterprise'), 0));
|
||||
|
||||
$importnowstring = get_string('aftersaving...', 'enrol_imsenterprise').' <a href="../enrol/imsenterprise/importnow.php">'.get_string('doitnow', 'enrol_imsenterprise').'</a>';
|
||||
$importnowstring = get_string('aftersaving...', 'enrol_imsenterprise').' <a href="../enrol/imsenterprise/importnow.php">';
|
||||
$importnowstring .= get_string('doitnow', 'enrol_imsenterprise').'</a>';
|
||||
$settings->add(new admin_setting_heading('enrol_imsenterprise_doitnowmessage', '', $importnowstring));
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
* IMS Enterprise enrolment tests.
|
||||
*
|
||||
* @package enrol_imsenterprise
|
||||
* @category phpunit
|
||||
* @category test
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@ -33,14 +33,20 @@ require_once($CFG->dirroot . '/enrol/imsenterprise/lib.php');
|
||||
* IMS Enterprise test case
|
||||
*
|
||||
* @package enrol_imsenterprise
|
||||
* @category phpunit
|
||||
* @category test
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class enrol_imsenterprise_testcase extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* @var $imsplugin enrol_imsenterprise_plugin IMS plugin instance.
|
||||
*/
|
||||
protected $imsplugin;
|
||||
|
||||
/**
|
||||
* Setup required for all tests.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->resetAfterTest(true);
|
||||
$this->imsplugin = enrol_get_plugin('imsenterprise');
|
||||
@ -63,7 +69,6 @@ class enrol_imsenterprise_testcase extends advanced_testcase {
|
||||
$this->assertEquals($prevnusers, $DB->count_records('user'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Existing users are not created again
|
||||
*/
|
||||
@ -82,7 +87,6 @@ class enrol_imsenterprise_testcase extends advanced_testcase {
|
||||
$this->assertEquals($prevnusers, $DB->count_records('user'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add new users
|
||||
*/
|
||||
@ -104,7 +108,6 @@ class enrol_imsenterprise_testcase extends advanced_testcase {
|
||||
$this->assertEquals(($prevnusers + 1), $DB->count_records('user'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Existing courses are not created again
|
||||
*/
|
||||
@ -127,7 +130,6 @@ class enrol_imsenterprise_testcase extends advanced_testcase {
|
||||
$this->assertEquals($prevncourses, $DB->count_records('course'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add new courses
|
||||
*/
|
||||
@ -207,7 +209,6 @@ class enrol_imsenterprise_testcase extends advanced_testcase {
|
||||
$this->assertEquals($dbcourse->fullname, $course1->idnumber);
|
||||
$this->assertEquals($dbcourse->summary, $course1->idnumber);
|
||||
|
||||
|
||||
// Setting a mapping using all the description tags.
|
||||
$this->imsplugin->set_config('imscoursemapshortname', 'short');
|
||||
$this->imsplugin->set_config('imscoursemapfullname', 'long');
|
||||
@ -229,7 +230,6 @@ class enrol_imsenterprise_testcase extends advanced_testcase {
|
||||
$this->assertEquals($dbcourse->fullname, $course2->imslong);
|
||||
$this->assertEquals($dbcourse->summary, $course2->imsfull);
|
||||
|
||||
|
||||
// Setting a mapping where the specified description tags doesn't exist in the XML file (must delegate into idnumber).
|
||||
$this->imsplugin->set_config('imscoursemapshortname', 'short');
|
||||
$this->imsplugin->set_config('imscoursemapfullname', 'long');
|
||||
@ -251,7 +251,6 @@ class enrol_imsenterprise_testcase extends advanced_testcase {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the plugin configuration for testing
|
||||
*/
|
||||
@ -263,15 +262,13 @@ class enrol_imsenterprise_testcase extends advanced_testcase {
|
||||
$this->imsplugin->set_config('createnewcategories', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an IMS enterprise XML file and adds it's path to config settings
|
||||
* Creates an IMS enterprise XML file and adds it's path to config settings.
|
||||
*
|
||||
* @param array Array of users StdClass
|
||||
* @param array Array of courses StdClass
|
||||
* @param bool|array $users false or array of users StdClass
|
||||
* @param bool|array $courses false or of courses StdClass
|
||||
*/
|
||||
protected function set_xml_file($users = false, $courses = false) {
|
||||
global $DB;
|
||||
|
||||
$xmlcontent = '<enterprise>';
|
||||
|
||||
@ -328,7 +325,7 @@ class enrol_imsenterprise_testcase extends advanced_testcase {
|
||||
<full>'.$course->imsfull.'</full>';
|
||||
}
|
||||
|
||||
// orgunit tag value is used by moodle as category name.
|
||||
// The orgunit tag value is used by moodle as category name.
|
||||
$xmlcontent .= '
|
||||
</description>
|
||||
<org>
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2013050100; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_imsenterprise'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->version = 2013050100;
|
||||
$plugin->requires = 2013050100;
|
||||
$plugin->component = 'enrol_imsenterprise';
|
||||
$plugin->cron = 60;
|
||||
|
Loading…
x
Reference in New Issue
Block a user