Skip to content

Commit

Permalink
[MDL-44170] Added form field for url matched type.
Browse files Browse the repository at this point in the history
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
adrianfish committed Feb 14, 2014
1 parent 692d247 commit ea5d051
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mod/lti/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions mod/lti/mod_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@
self.toolTypeCache[selectedToolType] = toolInfo;
}

Y.one('#id_urlmatchedtypeid').set('value', toolInfo.toolid);

continuation(toolInfo);
}
});
Expand Down
3 changes: 3 additions & 0 deletions mod/lti/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit ea5d051

Please sign in to comment.