[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.
This commit is contained in:
Adrian Fish 2014-02-14 15:52:09 +00:00
parent 692d247a3a
commit ea5d05151b
3 changed files with 13 additions and 0 deletions

View File

@ -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 File

@ -170,6 +170,8 @@
self.toolTypeCache[selectedToolType] = toolInfo;
}
Y.one('#id_urlmatchedtypeid').set('value', toolInfo.toolid);
continuation(toolInfo);
}
});

View File

@ -119,6 +119,9 @@ class mod_lti_mod_form extends moodleform_mod {
$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');