diff --git a/db/install.xml b/db/install.xml
index 33cb3de..a51d395 100755
--- a/db/install.xml
+++ b/db/install.xml
@@ -40,7 +40,9 @@
-
+
+
+
diff --git a/db/upgrade.php b/db/upgrade.php
index a55fa0d..a1bd4d1 100755
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -104,5 +104,21 @@ function xmldb_local_ltiprovider_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2014080102, 'local', 'ltiprovider');
}
+ if ($oldversion < 2014080103) {
+
+ $table = new xmldb_table('local_ltiprovider');
+
+ $field = new xmldb_field('enrolinst', XMLDB_TYPE_INTEGER, 2, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 1, 'requirecompletion');
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+ $field = new xmldb_field('enrollearn', XMLDB_TYPE_INTEGER, 2, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 1, 'enrolinst');
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ upgrade_plugin_savepoint(true, 2014080103, 'local', 'ltiprovider');
+ }
+
return true;
}
diff --git a/edit_form.php b/edit_form.php
index 0200838..b7d9b9e 100644
--- a/edit_form.php
+++ b/edit_form.php
@@ -83,6 +83,15 @@ public function definition () {
$assignableroles = get_assignable_roles($context);
+ $mform->addElement('checkbox', 'enrolinst', null, get_string('enrolinst', 'local_ltiprovider'));
+ $mform->setDefault('enrolinst', 1);
+ $mform->addHelpButton('enrolinst', 'enrolinst', 'local_ltiprovider');
+ $mform->setAdvanced('enrolinst');
+ $mform->addElement('checkbox', 'enrollearn', null, get_string('enrollearn', 'local_ltiprovider'));
+ $mform->setDefault('enrollearn', 1);
+ $mform->addHelpButton('enrollearn', 'enrollearn', 'local_ltiprovider');
+ $mform->setAdvanced('enrollearn');
+
$mform->addElement('select', 'croleinst', get_string('courseroleinstructor', 'local_ltiprovider'), $assignableroles);
$mform->setDefault('croleinst', '3');
$mform->setAdvanced('croleinst');
diff --git a/lang/en/local_ltiprovider.php b/lang/en/local_ltiprovider.php
index f913753..930dc7e 100644
--- a/lang/en/local_ltiprovider.php
+++ b/lang/en/local_ltiprovider.php
@@ -114,3 +114,8 @@
$string['requirecompletion'] = 'Require course or activity completed before sending the grades';
$string['errorcompletionenabled'] = 'Completion should be enabled for the course or the activity';
+
+$string['enrolinst'] = 'Automatically enrol Instructors';
+$string['enrolinst_help'] = 'Uncheck this box to redirect instructors to the course page so they can select a self-enrolment option';
+$string['enrollearn'] = 'Automatically enrol Learners';
+$string['enrollearn_help'] = 'Uncheck this box to redirect learners to the course page so they can select a self-enrolment option';
diff --git a/lib.php b/lib.php
index 83fd791..24f6e0b 100644
--- a/lib.php
+++ b/lib.php
@@ -126,6 +126,12 @@ function local_ltiprovider_add_tool($tool) {
if (!isset($tool->forcenavigation)) {
$tool->forcenavigation = 0;
}
+ if (!isset($tool->enrolinst)) {
+ $tool->enrolinst = 0;
+ }
+ if (!isset($tool->enrollearn)) {
+ $tool->enrollearn = 0;
+ }
if (!isset($tool->hidepageheader)) {
$tool->hidepageheader = 0;
}
@@ -163,6 +169,12 @@ function local_ltiprovider_update_tool($tool) {
if (!isset($tool->forcenavigation)) {
$tool->forcenavigation = 0;
}
+ if (!isset($tool->enrolinst)) {
+ $tool->enrolinst = 0;
+ }
+ if (!isset($tool->enrollearn)) {
+ $tool->enrollearn = 0;
+ }
if (!isset($tool->hidepageheader)) {
$tool->hidepageheader = 0;
}
diff --git a/locallib.php b/locallib.php
index 96ca933..07bbba5 100644
--- a/locallib.php
+++ b/locallib.php
@@ -38,27 +38,27 @@
function local_ltiprovider_create_service_body($source, $grade) {
return '
-
-
- V1.0
- '.(time()).'
-
-
-
-
-
-
- '.$source.'
-
-
-
- en-us
- '.$grade.'
-
-
-
-
-
+
+
+ V1.0
+ '.(time()).'
+
+
+
+
+
+
+ '.$source.'
+
+
+
+ en-us
+ '.$grade.'
+
+
+
+
+
';
}
@@ -113,6 +113,10 @@ function local_ltiprovider_unenrol_user($tool, $user) {
function local_ltiprovider_enrol_user($tool, $user, $isinstructor, $return = false) {
global $DB;
+ if (($isinstructor && !$tool->enrolinst) || (!$isinstructor && !$tool->enrollearn)) {
+ return $return;
+ }
+
$course = $DB->get_record('course', array('id' => $tool->courseid), '*', MUST_EXIST);
$manual = enrol_get_plugin('manual');
@@ -342,6 +346,8 @@ function local_ltiprovider_create_tool($courseid, $contextid, $lticontext) {
$tool->timemodified = time();
$tool->timecreated = time();
$tool->lastsync = 0;
+ $tool->enrolinst = 1;
+ $tool->enrollearn = 1;
$tool->sendgrades = (!empty($lticontext->info['lis_outcome_service_url'])) ? 1 : 0;
$tool->syncmembers = (!empty($lticontext->info['ext_ims_lis_memberships_url'])) ? 1 : 0;
$tool->syncmode = (!empty($lticontext->info['ext_ims_lis_memberships_url'])) ? 1 : 0;
diff --git a/version.php b/version.php
index 20b092c..4bed54b 100644
--- a/version.php
+++ b/version.php
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2014080102;
+$plugin->version = 2014080103;
$plugin->requires = 2014051200; // Require Moodle version (2.7).
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '2.7.1';