print_error('cannotmovetonotexist', 'forum', $return);
}
+ if ($forumto->type == 'single') {
+ print_error('cannotmovetosingleforum', 'forum', $return);
+ }
+
if (!$cmto = get_coursemodule_from_instance('forum', $forumto->id, $course->id)) {
print_error('cannotmovetonotfound', 'forum', $return);
}
if (isset($modinfo->instances['forum'])) {
$forummenu = array();
$sections = get_all_sections($course->id);
+ // Check forum types and eliminate simple discussions.
+ $forumcheck = $DB->get_records('forum', array('course' => $course->id),'', 'id, type');
foreach ($modinfo->instances['forum'] as $forumcm) {
if (!$forumcm->uservisible || !has_capability('mod/forum:startdiscussion',
get_context_instance(CONTEXT_MODULE,$forumcm->id))) {
continue;
}
-
$section = $forumcm->sectionnum;
$sectionname = get_section_name($course, $sections[$section]);
if (empty($forummenu[$section])) {
$forummenu[$section] = array($sectionname => array());
}
- if ($forumcm->instance != $forum->id) {
+ $forumidcompare = $forumcm->instance != $forum->id;
+ $forumtypecheck = $forumcheck[$forumcm->instance]->type !== 'single';
+ if ($forumidcompare and $forumtypecheck) {
$url = "/mod/forum/discuss.php?d=$discussion->id&move=$forumcm->instance&sesskey=".sesskey();
$forummenu[$section][$sectionname][$url] = format_string($forumcm->name);
}
$string['cannotmovenotvisible'] = 'Forum not visible';
$string['cannotmovetonotexist'] = 'You can\'t move to that forum - it doesn\'t exist!';
$string['cannotmovetonotfound'] = 'Target forum not found in this course.';
+$string['cannotmovetosingleforum'] = 'Cannot move discussion to a simple single discussion forum';
$string['cannotpurgecachedrss'] = 'Could not purge the cached RSS feeds for the source and/or destination forum(s) - check your file permissionsforums';
$string['cannotremovesubscriber'] = 'Could not remove subscriber with id {$a} from this forum!';
$string['cannotreply'] = 'You cannot reply to this post';
$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
$nostudents = true;
$groupstudents = array();
}
- $allowedlist = join(',', array_keys($groupstudents));
+ $allowedlist = array_keys($groupstudents);
}
if ( !$nostudents ) {
header("Pragma: public");
echo implode("\t", $headers)." \n";
}
-
+ $params = array();
+ list($usql, $params) = $DB->get_in_or_equal($allowedlist, SQL_PARAMS_NAMED);
// 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, ' .
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;
}
$countsql .= 'COUNT(DISTINCT('.$DB->sql_concat('u.id', '\'#\'', 'st.attempt').')) AS nbattempts, ';
$countsql .= 'COUNT(DISTINCT(u.id)) AS nbusers ';
$countsql .= $from.$where;
- $params = array();
if (!$download) {
$sort = $table->get_sql_sort();
}
if (!empty($countsql)) {
- $count = $DB->get_record_sql($countsql);
+ $count = $DB->get_record_sql($countsql, $params);
$totalinitials = $count->nbresults;
if ($twhere) {
$countsql .= ' AND '.$twhere;