mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 05:54:19 +02:00
Merge branch 'MDL-60187_master' of git://github.com/markn86/moodle
This commit is contained in:
commit
3e6dabadaa
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user