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 52194ac commit 83543ffcb9c7aa1085db95083a02357ddc138716 @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
@@ -119,6 +119,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 83543ff

Please sign in to comment.