--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file keeps track of upgrades to the guest enrolment plugin
+ *
+ * @package enrol
+ * @subpackage guest
+ * @copyright 2011 Petr Skoda {@link http://skodak.org
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+function xmldb_enrol_guest_upgrade($oldversion) {
+ global $CFG, $DB, $OUTPUT;
+
+ $dbman = $DB->get_manager();
+
+ if ($oldversion < 2011112901) {
+ // convert all null passwords to empty strings
+ $DB->set_field('enrol', 'password', '', array('enrol'=>'guest', 'password'=>null));
+
+ upgrade_plugin_savepoint(true, 2011112901, 'enrol', 'guest');
+ }
+
+ return true;
+}
+
+
}
}
+ /**
+ * Add new instance of enrol plugin.
+ * @param object $course
+ * @param array instance fields
+ * @return int id of new instance, null if can not be created
+ */
+ public function add_instance($course, array $fields = NULL) {
+ $fields = (array)$fields;
+
+ if (!isset($fields['password'])) {
+ $fields['password'] = '';
+ }
+
+ return parent::add_instance($course, $fields);
+ }
+
/**
* Add new instance of enrol plugin with default settings.
* @param object $course
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version = 2011112901; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011112900; // Requires this Moodle version
$plugin->component = 'enrol_guest'; // Full name of the plugin (used for diagnostics)
$courseid = $DB->insert_record('course', $course);
+ // Setup default enrolment plugins
+ $course->id = $courseid;
+ enrol_course_updated(true, $course, null);
+
// Setup the blocks
$course = $DB->get_record('course', array('id' => $courseid));
blocks_add_default_course_blocks($course);
if ($user_selector) {
$renderer = $PAGE->get_renderer('gradereport_user');
- echo $renderer->graded_users_selector('user', $course, $userid, $currentgroup, false);
+ echo $renderer->graded_users_selector('user', $course, $userid, $currentgroup, true);
}
while ($userdata = $gui->next_user()) {
// Redirect logged-in users to My Moodle overview if required
if (optional_param('setdefaulthome', false, PARAM_BOOL)) {
set_user_preference('user_home_page_preference', HOMEPAGE_SITE);
- } else if ($CFG->defaulthomepage == HOMEPAGE_MY && (optional_param('redirect', true, PARAM_BOOL) || !$hassiteconfig)) {
+ } else if ($CFG->defaulthomepage == HOMEPAGE_MY && optional_param('redirect', 1, PARAM_BOOL) === 1) {
redirect($CFG->wwwroot .'/my/');
} else if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_USER) {
$PAGE->settingsnav->get('usercurrentsettings')->add(get_string('makethismyhome'), new moodle_url('/', array('setdefaulthome'=>true)), navigation_node::TYPE_SETTING);
$sections = $this->load_course_sections($course, $coursenode);
break;
}
+ } else {
+ // We need to check if the user is viewing a front page module.
+ // If so then there is potentially more content to load yet for that
+ // module.
+ if ($this->page->context->contextlevel == CONTEXT_MODULE) {
+ $activitynode = $this->rootnodes['site']->get($this->page->cm->id, navigation_node::TYPE_ACTIVITY);
+ if ($activitynode) {
+ $this->load_activity($this->page->cm, $this->page->course, $activitynode);
+ }
+ }
}
$limit = 20;
$repeateloptions['limit']['default'] = 0;
$repeateloptions['limit']['disabledif'] = array('limitanswers', 'eq', 0);
$repeateloptions['limit']['rule'] = 'numeric';
- $mform->setType('limit', PARAM_INT);
$repeateloptions['option']['helpbutton'] = array('choiceoptions', 'choice');
$mform->setType('option', PARAM_CLEANHTML);
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';
// Ensure the attempt exists, and belongs to this quiz. If not skip.
continue;
}
- if ($allowed && !array_key_exists($attempt->userid, $allowed)) {
+ if ($allowed && !in_array($attempt->userid, $allowed)) {
// Ensure the attempt belongs to a student included in the report. If not skip.
continue;
}
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
}
}
+ // find out current groups mode
+ $currentgroup = groups_get_activity_group($cm, true);
// detailed report
$mform = new mod_scorm_report_settings($PAGE->url, compact('currentgroup'));
$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;
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
}
}
+ // find out current groups mode
+ $currentgroup = groups_get_activity_group($cm, true);
// detailed report
$mform = new mod_scorm_report_interactions_settings($PAGE->url, compact('currentgroup'));
$nostudents = true;
$groupstudents = array();
}
- $allowedlist = ($groupstudents);
+ $allowedlist = array_keys($groupstudents);
}
if ( !$nostudents ) {
// Now check if asked download of data
} else {
$error = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
$error .= '<EXCEPTION class="'.get_class($ex).'">'."\n";
- $error .= '<MESSAGE>'.htmlentities($ex->getMessage(), ENT_COMPAT, 'UTF-8').'</MESSAGE>'."\n";
+ $error .= '<MESSAGE>'.htmlspecialchars($ex->getMessage(), ENT_COMPAT, 'UTF-8').'</MESSAGE>'."\n";
if (debugging() and isset($ex->debuginfo)) {
- $error .= '<DEBUGINFO>'.htmlentities($ex->debuginfo, ENT_COMPAT, 'UTF-8').'</DEBUGINFO>'."\n";
+ $error .= '<DEBUGINFO>'.htmlspecialchars($ex->debuginfo, ENT_COMPAT, 'UTF-8').'</DEBUGINFO>'."\n";
}
$error .= '</EXCEPTION>'."\n";
}
if (is_null($returns)) {
return '<VALUE null="null"/>'."\n";
} else {
- return '<VALUE>'.htmlentities($returns, ENT_COMPAT, 'UTF-8').'</VALUE>'."\n";
+ return '<VALUE>'.htmlspecialchars($returns, ENT_COMPAT, 'UTF-8').'</VALUE>'."\n";
}
} else if ($desc instanceof external_multiple_structure) {