MDL-60187 mod_lti: Do not create a grade item when grades are disabled.
If the privacy option "Accept grades from the tool" is disabled, the module should not appear in the gradebook when edited inline or when recover grades is running during enrolment.
This commit is contained in:
committed by
Mark Nelson
parent
4275ea4a43
commit
4d5a33e424
@@ -103,5 +103,56 @@ function xmldb_lti_upgrade($oldversion) {
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2017111301) {
|
||||
|
||||
// A bug in the LTI plugin incorrectly inserted a grade item for
|
||||
// LTI instances which were set to not allow grading.
|
||||
// The change finds any LTI which does not have grading enabled,
|
||||
// and updates any grades to delete them.
|
||||
|
||||
$ltis = $DB->get_recordset_sql("
|
||||
SELECT
|
||||
l.id,
|
||||
l.course,
|
||||
l.instructorchoiceacceptgrades,
|
||||
t.enabledcapability,
|
||||
t.toolproxyid,
|
||||
tc.value AS acceptgrades
|
||||
FROM {lti} l
|
||||
INNER JOIN {grade_items} gt
|
||||
ON l.id = gt.iteminstance
|
||||
LEFT JOIN {lti_types} t
|
||||
ON t.id = l.typeid
|
||||
LEFT JOIN {lti_types_config} tc
|
||||
ON tc.typeid = t.id AND tc.name = 'acceptgrades'
|
||||
WHERE gt.itemmodule = 'lti'
|
||||
AND gt.itemtype = 'mod'
|
||||
");
|
||||
|
||||
foreach ($ltis as $lti) {
|
||||
$acceptgrades = true;
|
||||
if (empty($lti->toolproxyid)) {
|
||||
$typeacceptgrades = isset($lti->acceptgrades) ? $lti->acceptgrades : 2;
|
||||
if (!($typeacceptgrades == 1 ||
|
||||
($typeacceptgrades == 2 && $lti->instructorchoiceacceptgrades == 1))) {
|
||||
$acceptgrades = false;
|
||||
}
|
||||
} else {
|
||||
$enabledcapabilities = explode("\n", $lti->enabledcapability);
|
||||
$acceptgrades = in_array('Result.autocreate', $enabledcapabilities);
|
||||
}
|
||||
|
||||
if (!$acceptgrades) {
|
||||
grade_update('mod/lti', $lti->course, 'mod', 'lti', $lti->id, 0, null, array('deleted' => 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$ltis->close();
|
||||
|
||||
upgrade_mod_savepoint(true, 2017111301, 'lti');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@@ -489,6 +489,11 @@ function lti_get_lti_types_from_proxy_id($toolproxyid) {
|
||||
function lti_grade_item_update($basiclti, $grades = null) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/servicelib.php');
|
||||
|
||||
if (!lti_accepts_grades($basiclti)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$params = array('itemname' => $basiclti->name, 'idnumber' => $basiclti->cmidnumber);
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$plugin->version = 2017111300; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2017111301; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2017110800; // Requires this Moodle version.
|
||||
$plugin->component = 'mod_lti'; // Full name of the plugin (used for diagnostics).
|
||||
$plugin->cron = 0;
|
||||
|
||||
Reference in New Issue
Block a user