From 1b13df8f655cb8abd9658ba14a02450afae41e95 Mon Sep 17 00:00:00 2001 From: Sam Chaffee Date: Tue, 20 May 2014 10:44:46 -0600 Subject: [PATCH 1/3] MDL-37168 mod_lti: Fix LTI activity quick edit title --- mod/lti/lib.php | 19 +++++++++++++++++++ mod/lti/servicelib.php | 1 + mod/lti/tests/generator/lib.php | 3 +++ 3 files changed, 23 insertions(+) diff --git a/mod/lti/lib.php b/mod/lti/lib.php index 5603817f49b..93260276177 100644 --- a/mod/lti/lib.php +++ b/mod/lti/lib.php @@ -102,6 +102,9 @@ function lti_add_instance($lti, $mform) { $lti->timecreated = time(); $lti->timemodified = $lti->timecreated; $lti->servicesalt = uniqid('', true); + if (!isset($lti->typeid)) { + $lti->typeid = null; + } lti_force_type_config_settings($lti, lti_get_type_config_by_instance($lti)); @@ -501,6 +504,22 @@ function lti_grade_item_update($basiclti, $grades = null) { return grade_update('mod/lti', $basiclti->course, 'mod', 'lti', $basiclti->id, 0, $grades, $params); } +/** + * Update activity grades + * + * @param stdClass $basiclti The LTI instance + * @param int $userid Specific user only, 0 means all. + * @param bool $nullifnone Not used + */ +function lti_update_grades($basiclti, $userid=0, $nullifnone=true) { + global $CFG; + require_once($CFG->dirroot.'/mod/lti/servicelib.php'); + // LTI doesn't have its own grade table so the only thing to do is update the grade item. + if (lti_accepts_grades($basiclti)) { + lti_grade_item_update($basiclti); + } +} + /** * Delete grade item for given basiclti * diff --git a/mod/lti/servicelib.php b/mod/lti/servicelib.php index b6d4e469601..88ebdb1c49a 100644 --- a/mod/lti/servicelib.php +++ b/mod/lti/servicelib.php @@ -26,6 +26,7 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->dirroot.'/mod/lti/OAuthBody.php'); +require_once($CFG->dirroot.'/mod/lti/locallib.php'); // TODO: Switch to core oauthlib once implemented - MDL-30149. use moodle\mod\lti as lti; diff --git a/mod/lti/tests/generator/lib.php b/mod/lti/tests/generator/lib.php index a8963284c04..aedcd4b700b 100644 --- a/mod/lti/tests/generator/lib.php +++ b/mod/lti/tests/generator/lib.php @@ -61,6 +61,9 @@ class mod_lti_generator extends testing_module_generator { if (!isset($record->instructorchoiceacceptgrades)) { $record->instructorchoiceacceptgrades = 1; } + if (!isset($record->typeid)) { + $record->typeid = null; + } return parent::create_instance($record, (array)$options); } } From e078aa135114827f62045bf638de037e1d646115 Mon Sep 17 00:00:00 2001 From: John Okely Date: Tue, 10 Jan 2017 12:09:02 +0800 Subject: [PATCH 2/3] MDL-37168 mod_lti: Add behat test to cover lti quick edit --- mod/lti/tests/behat/renametool.feature | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 mod/lti/tests/behat/renametool.feature diff --git a/mod/lti/tests/behat/renametool.feature b/mod/lti/tests/behat/renametool.feature new file mode 100644 index 00000000000..8e131b9e418 --- /dev/null +++ b/mod/lti/tests/behat/renametool.feature @@ -0,0 +1,34 @@ +@mod @mod_lti +Feature: Rename external tools via inline editing + In order to keep track of my activities + As a teacher + I need to be able to rename the LTI tool and have it's name change in the gradebook + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Terry1 | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + + @javascript + Scenario: Add a tool and inline edit + When I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I add a "External tool" to section "1" and I fill the form with: + | Activity name | Test tool activity 1 | + And I open "Test tool activity 1" actions menu + And I choose "Edit settings" in the open action menu + And I set the field "Tool URL" to local url "/mod/lti/tests/fixtures/ims_cartridge_basic_lti_link.xml" + And I press "Save and return to course" + And I click on "Edit title" "link" in the "li#section-1" "css_element" + And I set the field "New name for activity Test tool activity 1" to "Test tool activity renamed" + And I press key "13" in the field "New name for activity Test tool activity 1" + And I navigate to "Setup > Gradebook setup" in the course gradebook + Then I should not see "Test tool activity 1" + And I should see "Test tool activity renamed" From be52d0daced2b85d7fcb6d0df18bb1081da1c423 Mon Sep 17 00:00:00 2001 From: John Okely Date: Fri, 27 Jan 2017 14:59:33 +0800 Subject: [PATCH 3/3] MDL-37168 grade: Debugging if gradebook callbacks are not both present --- lib/gradelib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/gradelib.php b/lib/gradelib.php index 2417784bb9f..aa16239f80b 100644 --- a/lib/gradelib.php +++ b/lib/gradelib.php @@ -1379,9 +1379,10 @@ function grade_update_mod_grades($modinstance, $userid=0) { //new grading supported, force updating of grades $updateitemfunc($modinstance); $updategradesfunc($modinstance, $userid); - - } else { + } else if (function_exists($updategradesfunc) xor function_exists($updateitemfunc)) { // Module does not support grading? + debugging("You have declared one of $updateitemfunc and $updategradesfunc but not both. " . + "This will cause broken behaviour.", DEBUG_DEVELOPER); } return true;