Permalink
Browse files

[MDL-44170] Added form field for url matched type.

Added a new mod_form field called urlmatchedtypeid which is populated
by mod_form.js when a matched url is entered. On save, if typeid is 0
and urlmatchedtypeid is supplied, the type id is set to the url matched
id.
  • Loading branch information...
1 parent f6cc073 commit 3ca6a4571303be394df6060afee56b8f5adfa258 @adrianfish adrianfish committed with damyon Feb 14, 2014
Showing with 13 additions and 0 deletions.
  1. +8 −0 mod/lti/lib.php
  2. +2 −0 mod/lti/mod_form.js
  3. +3 −0 mod/lti/mod_form.php
View
@@ -96,6 +96,10 @@ function lti_add_instance($lti, $mform) {
$lti->timemodified = $lti->timecreated;
$lti->servicesalt = uniqid('', true);
+ if ($lti->typeid == 0 && isset($lti->urlmatchedtypeid)) {
+ $lti->typeid = $lti->urlmatchedtypeid;
+ }
+
if (!isset($lti->grade)) {
$lti->grade = 100; // TODO: Why is this harcoded here and default @ DB
}
@@ -146,6 +150,10 @@ function lti_update_instance($lti, $mform) {
lti_grade_item_delete($lti);
}
+ if ($lti->typeid == 0 && isset($lti->urlmatchedtypeid)) {
+ $lti->typeid = $lti->urlmatchedtypeid;
+ }
+
return $DB->update_record('lti', $lti);
}
View
@@ -170,6 +170,8 @@
self.toolTypeCache[selectedToolType] = toolInfo;
}
+ Y.one('#id_urlmatchedtypeid').set('value', toolInfo.toolid);
+
continuation(toolInfo);
}
});
View
@@ -114,6 +114,9 @@ public function definition() {
$mform->setAdvanced('securetoolurl');
$mform->addHelpButton('securetoolurl', 'secure_launch_url', 'lti');
+ $mform->addElement('hidden', 'urlmatchedtypeid', '', array( 'id' => 'id_urlmatchedtypeid' ));
+ $mform->setType('urlmatchedtypeid', PARAM_INT);
+
$launchoptions=array();
$launchoptions[LTI_LAUNCH_CONTAINER_DEFAULT] = get_string('default', 'lti');
$launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');

0 comments on commit 3ca6a45

Please sign in to comment.