mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-40223 SCORM: pass limit into function instead of hardcoding to allow cross-db
This commit is contained in:
parent
27c58e5583
commit
eef4c4c175
@ -197,9 +197,11 @@ class restore_scorm_activity_structure_step extends restore_activity_structure_s
|
||||
$scorm->launch = $this->get_mappingid('scorm_sco', $scorm->launch, '');
|
||||
if (empty($scorm->launch)) {
|
||||
// This scorm has an invalid launch param - we need to calculate it and get the first launchable sco.
|
||||
$sqlselect = 'scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true). ' ORDER BY sortorder LIMIT 1';
|
||||
$sco = $DB->get_record_select('scorm_scoes', $sqlselect, array($scorm->id));
|
||||
if (!empty($sco)) {
|
||||
$sqlselect = 'scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true);
|
||||
// We use get_records here as we need to pass a limit in the query that works cross db.
|
||||
$scoes = $DB->get_records_select('scorm_scoes', $sqlselect, array($scormid), 'sortorder', 'id', 0, 1);
|
||||
if (!empty($scoes)) {
|
||||
$sco = reset($scoes); // We only care about the first record - the above query only returns one.
|
||||
$scorm->launch = $sco->id;
|
||||
}
|
||||
}
|
||||
|
@ -185,9 +185,12 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
$scorms = $DB->get_recordset_sql($sql);
|
||||
foreach ($scorms as $scorm) {
|
||||
// Find the first launchable sco for this SCORM.
|
||||
$sqlselect = 'scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true). ' ORDER BY sortorder LIMIT 1';
|
||||
$sco = $DB->get_record_select('scorm_scoes', $sqlselect, array($scorm->id));
|
||||
if (!empty($sco)) {
|
||||
// This scorm has an invalid launch param - we need to calculate it and get the first launchable sco.
|
||||
$sqlselect = 'scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true);
|
||||
// We use get_records here as we need to pass a limit in the query that works cross db.
|
||||
$scoes = $DB->get_records_select('scorm_scoes', $sqlselect, array($scorm->id), 'sortorder', 'id', 0, 1);
|
||||
if (!empty($scoes)) {
|
||||
$sco = reset($scoes); // We only care about the first record - the above query only returns one.
|
||||
$scorm->launch = $sco->id;
|
||||
$DB->update_record('scorm', $scorm);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user