Permalink
Browse files

A couple bugfixes related to instructor defined tools

  • Loading branch information...
scriby committed Sep 19, 2011
1 parent 6831c7c commit 606ab1a13e8f19ba3a748f8be49ef97202f41995
Showing with 16 additions and 7 deletions.
  1. +3 −2 mod/lti/locallib.php
  2. +13 −5 mod/lti/mod_form.js
View
@@ -74,7 +74,7 @@ function lti_view($instance, $makeobject=false) {
global $PAGE, $CFG;
if(empty($instance->typeid)){
- $tool = lti_get_tool_by_url_match($instance->toolurl);
+ $tool = lti_get_tool_by_url_match($instance->toolurl, $instance->course);
if($tool){
$typeid = $tool->id;
} else {
@@ -401,9 +401,10 @@ function lti_get_types_for_add_instance(){
WHERE
coursevisible = 1
AND (course = :siteid OR course = :courseid)
+ AND state = :active
QUERY;
- $admintypes = $DB->get_records_sql($query, array('siteid' => $SITE->id, 'courseid' => $COURSE->id));
+ $admintypes = $DB->get_records_sql($query, array('siteid' => $SITE->id, 'courseid' => $COURSE->id, 'active' => LTI_TOOL_STATE_CONFIGURED));
$types = array();
$types[0] = (object)array('name' => get_string('automatic', 'lti'), 'course' => $SITE->id);
View
@@ -19,6 +19,8 @@
var typeSelector = Y.one('#id_typeid');
typeSelector.on('change', function(e){
+ self.updateAutomaticToolMatch();
+
self.toggleEditButtons();
});
@@ -47,6 +49,7 @@
updateAutomaticToolMatch: function(){
var toolurl = Y.one('#id_toolurl');
+ var typeSelector = Y.one('#id_typeid');
var automatchToolDisplay = Y.one('#lti_automatch_tool');
if(!automatchToolDisplay){
@@ -59,7 +62,7 @@
var url = toolurl.get('value');
- if(!url){
+ if(!url || typeSelector.get('value') > 0){
automatchToolDisplay.setStyle('display', 'none');
return;
}
@@ -121,16 +124,21 @@
.set('id', 'course_tool_group')
.set('label', M.str.lti.course_tool_types);
- typeSelector.all('option[globalTool=1]').remove().each(function(node){
+ var globalOptions = typeSelector.all('option[globalTool=1]').remove().each(function(node){
globalGroup.append(node);
});
- typeSelector.all('option[courseTool=1]').remove().each(function(node){
+ var courseOptions = typeSelector.all('option[courseTool=1]').remove().each(function(node){
courseGroup.append(node);
});
- typeSelector.append(globalGroup);
- typeSelector.append(courseGroup);
+ if(globalOptions.size() > 0){
+ typeSelector.append(globalGroup);
+ }
+
+ if(courseOptions.size() > 0){
+ typeSelector.append(courseGroup);
+ }
}
},

0 comments on commit 606ab1a

Please sign in to comment.