Details
-
Type:
Bug
-
Status: Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 3.4.3
-
Fix Version/s: None
-
Component/s: LTI provider
-
Labels:
-
Affected Branches:MOODLE_34_STABLE
Description
function lti_get_type_config in mod_lti/locallib.php requires to return unique IDs for the tuples
Proposed solution
Enclose the current query in another Select statement, where a unique ID is added as the first field in each tuple.
I attempted to make bold the additional code which encloses the current query, so you can see it is an addition to what is already providing
/**
- Returns configuration details for the tool
- @param int $typeid Basic LTI tool typeid
- @return array Tool Configuration
*/
function lti_get_type_config($typeid)
{ global $DB;
$query = "SELECT (@id := @id +1) id, name, value
FROM (select @id :=0 id) id, ( SELECT name, value FROM {lti_types_config}
WHERE typeid = :typeid1
UNION ALL
SELECT 'toolurl' AS name, baseurl AS value
FROM {lti_types} WHERE id = :typeid2
UNION ALL
SELECT 'icon' AS name, icon AS value
FROM {lti_types}WHERE id = :typeid3
UNION ALL
SELECT 'secureicon' AS name, secureicon AS value
FROM {lti_types} WHERE id = :typeid4
) dta";
$typeconfig = array();
$configs = $DB->get_records_sql($query,
array('typeid1' => $typeid, 'typeid2' => $typeid, 'typeid3' => $typeid, 'typeid4' => $typeid));
if (!empty($configs))Unknown macro: { foreach ($configs as $config) { $typeconfig[$config->name] = $config->value; } }
return $typeconfig;
}