plagiarism_plugin_turnitin::get_links doesn't cache the check if Turnitin is enabled in the coursemodule
danmarsden opened this issue · 2 comments
get_links should be checking to see if Turnitin is enabled in this activity before running through all the various things/queries - this is particularly important when a teacher wants to display large numbers of assignments in the same page - eg a page is showing 1000 users, with multiple files this causes the page to run unnecessarily slow while it does various turnitin related things with the files.
I'm guessing something like the following should be added near the top of get_links.
static $useturnitin = null;
if (is_null($useturnitin) && !empty($linkarray['cmid']) ) {
$useturnitin = $DB->get_record('plagiarism_turnitin_config',
['cm' => $linkarray['cmid'], 'name' => 'use_turnitin']);
if (empty($useturnitin)) {
$useturnitin = false;
}
}
if ($useturnitin === false) {
return '';
}
now that I trace that further I can see there is a check that occurs later on via the get_settings call, but it isn't being cached in the static var - I've sent through a PR to fix that up.
We've hit this with quiz. Turnitin does a load of quiz processing even though it's not enabled for quiz. This significantly slows down the display of results page (literally 20+ minutes vs seconds). It rather implies that Turnitin is horribly inefficient with quiz but it definitely shouldn't be doing this when it's not enabled for quiz.