Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-28277 removed IN from sql statments

  • Loading branch information...
commit 7def307d1acab03730116c12e0d0f9ea49487acd 1 parent 3b1e85a
@ankitagarwal ankitagarwal authored
Showing with 9 additions and 9 deletions.
  1. +9 −9 mod/scorm/report/interactions/report.php
View
18 mod/scorm/report/interactions/report.php
@@ -99,7 +99,7 @@ function display($scorm, $cm, $course, $download) {
$nostudents = true;
$allowedlist = '';
} else {
- $allowedlist = join(',', array_keys($students));
+ $allowedlist = array_keys($students);
}
} else {
// all users who can attempt scoes and who are in the currently selected group
@@ -108,9 +108,8 @@ function display($scorm, $cm, $course, $download) {
$nostudents = true;
$groupstudents = array();
}
- $allowedlist = join(',', array_keys($groupstudents));
+ $allowedlist = ($groupstudents);
}
-
if ( !$nostudents ) {
// Now check if asked download of data
if ($download) {
@@ -153,6 +152,8 @@ function display($scorm, $cm, $course, $download) {
} else {
$scoes = null;
}
+ $params = array();
+ list($usql, $params) = $DB->get_in_or_equal($allowedlist);
// Construct the SQL
$select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, ';
$select .= 'st.scormid AS scormid, st.attempt AS attempt, ' .
@@ -164,15 +165,15 @@ function display($scorm, $cm, $course, $download) {
switch ($attemptsmode) {
case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH:
// Show only students with attempts
- $where = ' WHERE u.id IN (' .$allowedlist. ') AND st.userid IS NOT NULL';
+ $where = ' WHERE u.id ' .$usql. ' AND st.userid IS NOT NULL';
break;
case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO:
// Show only students without attempts
- $where = ' WHERE u.id IN (' .$allowedlist. ') AND st.userid IS NULL';
+ $where = ' WHERE u.id ' .$usql. ' AND st.userid IS NULL';
break;
case SCORM_REPORT_ATTEMPTS_ALL_STUDENTS:
// Show all students with or without attempts
- $where = ' WHERE u.id IN (' .$allowedlist. ') AND (st.userid IS NOT NULL OR st.userid IS NULL)';
+ $where = ' WHERE u.id ' .$usql. ' AND (st.userid IS NOT NULL OR st.userid IS NULL)';
break;
}
@@ -180,7 +181,7 @@ function display($scorm, $cm, $course, $download) {
$countsql .= 'COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'st.attempt').')) AS nbattempts, ';
$countsql .= 'COUNT(DISTINCT(u.id)) AS nbusers ';
$countsql .= $from.$where;
- $attempts = $DB->get_records_sql($select.$from.$where, null);
+ $attempts = $DB->get_records_sql($select.$from.$where, $params);
$questioncount=get_scorm_question_count($scoes,$attempts);
for($id=0;$id<$questioncount;$id++) {
if ($displayoptions['qtext']) {
@@ -318,7 +319,6 @@ function display($scorm, $cm, $course, $download) {
header("Pragma: public");
echo implode("\t", $headers)." \n";
}
- $params = array();
if (!$download) {
$sort = $table->get_sql_sort();
@@ -341,7 +341,7 @@ function display($scorm, $cm, $course, $download) {
}
if (!empty($countsql)) {
- $count = $DB->get_record_sql($countsql);
+ $count = $DB->get_record_sql($countsql,$params);
$totalinitials = $count->nbresults;
if ($twhere) {
$countsql .= ' AND '.$twhere;
Please sign in to comment.
Something went wrong with that request. Please try again.