$managefeeds = new moodle_url('/blocks/rss_client/managefeeds.php', $urlparams);
$PAGE->set_url('/blocks/rss_client/editfeed.php', $urlparams);
-$PAGE->set_pagelayout('base');
+$PAGE->set_pagelayout('standard');
if ($rssid) {
$isadding = false;
$PAGE->set_title($strtitle);
$PAGE->set_heading($strtitle);
- $settingsurl = new moodle_url('/admin/settings.php?section=blocksettingrss_client');
$PAGE->navbar->add(get_string('blocks'));
- $PAGE->navbar->add(get_string('pluginname', 'block_rss_client'), $settingsurl);
- $PAGE->navbar->add(get_string('managefeeds', 'block_rss_client'));
+ $PAGE->navbar->add(get_string('pluginname', 'block_rss_client'));
+ $PAGE->navbar->add(get_string('managefeeds', 'block_rss_client'), $managefeeds );
$PAGE->navbar->add($strtitle);
echo $OUTPUT->header();
$PAGE->set_title($strmanage);
$PAGE->set_heading($strmanage);
-$settingsurl = new moodle_url('/admin/settings.php?section=blocksettingrss_client');
$managefeeds = new moodle_url('/blocks/rss_client/managefeeds.php', $urlparams);
$PAGE->navbar->add(get_string('blocks'));
-$PAGE->navbar->add(get_string('pluginname', 'block_rss_client'), $settingsurl);
+$PAGE->navbar->add(get_string('pluginname', 'block_rss_client'));
$PAGE->navbar->add(get_string('managefeeds', 'block_rss_client'), $managefeeds);
echo $OUTPUT->header();
$PAGE->set_title($strviewfeed);
$PAGE->set_heading($strviewfeed);
-$settingsurl = new moodle_url('/admin/settings.php?section=blocksettingrss_client');
$managefeeds = new moodle_url('/blocks/rss_client/managefeeds.php', $urlparams);
$PAGE->navbar->add(get_string('blocks'));
-$PAGE->navbar->add(get_string('pluginname', 'block_rss_client'), $settingsurl);
-$PAGE->navbar->add(get_string('managefeeds', 'block_rss_client'));
+$PAGE->navbar->add(get_string('pluginname', 'block_rss_client'));
+$PAGE->navbar->add(get_string('managefeeds', 'block_rss_client'), $managefeeds);
$PAGE->navbar->add($strviewfeed);
echo $OUTPUT->header();
// NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
$gettypesfunc = $modname.'_get_types';
if (function_exists($gettypesfunc)) {
- if ($types = $gettypesfunc()) {
+ $types = $gettypesfunc();
+ if (is_array($types) && count($types) > 0) {
$group = new stdClass();
$group->name = $modname;
$group->icon = $OUTPUT->pix_icon('icon', '', $modname, array('class' => 'icon'));
$module->archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
$modlist[$course->id][$modname] = $module;
}
- $return[$modname] = $modlist[$course->id][$modname];
+ if (isset($modlist[$course->id][$modname])) {
+ $return[$modname] = $modlist[$course->id][$modname];
+ } else {
+ debugging("Invalid module metadata configuration for {$modname}");
+ }
}
return $return;
$this->resetAfterTest(true);
+ // Enable course completion.
+ set_config('enablecompletion', 1);
+
// Set the required capabilities by the external function
$contextid = context_system::instance()->id;
$roleid = $this->assignUserCapability('moodle/course:create', $contextid);
$this->assertEquals($dbcourse->theme, $course2['forcetheme']);
}
- if (completion_info::is_enabled_for_site()) {
- $this->assertEquals($dbcourse->enablecompletion, $course2['enabledcompletion']);
- $this->assertEquals($dbcourse->completionstartonenrol, $course2['completionstartonenrol']);
- } else {
- $this->assertEquals($dbcourse->enablecompletion, 0);
- $this->assertEquals($dbcourse->completionstartonenrol, 0);
- }
+ $this->assertEquals($dbcourse->enablecompletion, $course2['enablecompletion']);
+ $this->assertEquals($dbcourse->completionstartonenrol, $course2['completionstartonenrol']);
} else if ($createdcourse['shortname'] == $course1['shortname']) {
$courseconfig = get_config('moodlecourse');
// Cancel the edit if we lose focus or the escape key is pressed
thisevent = editor.on('blur', cancel_edittitle);
listenevents.push(thisevent);
- thisevent = Y.one('document').on('keyup', function(e) {
- if (e.keyCode == 27) {
+ thisevent = Y.one('document').on('keydown', function(e) {
+ if (e.keyCode === 27) {
+ e.preventDefault();
cancel_edittitle(e);
}
});
Y.extend(ROLE, Y.Base, {
users : [],
roleAssignmentPanel : null,
- panelsubmitevent : null,
rolesLoadedEvent : null,
escCloseEvent : null,
initializer : function(config) {
this.rolesLoadedEvent = this.on('assignablerolesloaded', function(){
this.rolesLoadedEvent.detach();
var panel = this._getRoleAssignmentPanel();
- this.panelsubmitevent = panel.on('submit', this.addRoleCallback, this);
- panel.hide().display(user);
+ panel.hide();
+ panel.submitevent = panel.on('submit', this.addRoleCallback, this);
+ panel.display(user);
}, this);
this._loadAssignableRoles();
},
addRoleCallback : function(e, roleid, userid) {
- this.panelsubmitevent.detach();
var panel = this._getRoleAssignmentPanel();
+ panel.submitevent.detach();
+ panel.submitevent = null;
Y.io(M.cfg.wwwroot+'/enrol/ajax.php', {
method:'POST',
data:'id='+this.get(COURSEID)+'&action=assign&sesskey='+M.cfg.sesskey+'&roleid='+roleid+'&user='+userid,
Y.extend(ROLEPANEL, Y.Base, {
user : null,
roles : [],
+ submitevent : null,
initializer : function() {
var i, m = this.get(MANIPULATOR);
var element = Y.Node.create('<div class="enrolpanel roleassign"><div class="container"><div class="header"><h2>'+M.str.role.assignroles+'</h2><div class="close"></div></div><div class="content"></div></div></div>');
this.roles = [];
this.user = null;
this.get('elementNode').removeClass('visible');
+ if (this.submitevent) {
+ this.submitevent.detach();
+ this.submitevent = null;
+ }
this.displayed = false;
return this;
},
}
}
-}, '@VERSION@', {requires:['base','node','io-base','json-parse','test','moodle-enrol-notification']});
\ No newline at end of file
+}, '@VERSION@', {requires:['base','node','io-base','json-parse','test','moodle-enrol-notification']});
$string['technicalinforightsummary'] = 'Right answer summary: {$a}';
$string['technicalinfostate'] = 'Question state: {$a}';
$string['unknownbehaviour'] = 'Unknown behaviour: {$a}.';
+$string['unknownorunhandledtype'] = 'Unknown or unhandled question type: {$a}';
$string['unknownquestion'] = 'Unknown question: {$a}.';
$string['unknownquestioncatregory'] = 'Unknown question category: {$a}.';
$string['unknownquestiontype'] = 'Unknown question type: {$a}.';
$PAGE->requires->js_init_call('M.util.init_colour_picker', array($this->get_id(), $this->previewconfig));
$content = html_writer::start_tag('div', array('class'=>'form-colourpicker defaultsnext'));
$content .= html_writer::tag('div', $OUTPUT->pix_icon('i/loading', get_string('loading', 'admin'), 'moodle', array('class'=>'loadingicon')), array('class'=>'admin_colourpicker clearfix'));
- $content .= html_writer::empty_tag('input', array('type'=>'text','id'=>$this->get_id(), 'name'=>$this->get_full_name(), 'value'=>$this->get_setting(), 'size'=>'12'));
+ $content .= html_writer::empty_tag('input', array('type'=>'text','id'=>$this->get_id(), 'name'=>$this->get_full_name(), 'value'=>$data, 'size'=>'12'));
if (!empty($this->previewconfig)) {
$content .= html_writer::empty_tag('input', array('type'=>'button','id'=>$this->get_id().'_preview', 'value'=>get_string('preview'), 'class'=>'admin_colourpicker_preview'));
}
});
this.overlay.render(Y.one(document.body));
- footerbtn.on('click', this.overlay.hide, this.overlay);
+ footerbtn.on('click', this.close, this);
var boundingBox = this.overlay.get("boundingBox");
},
display_callback : function(content) {
- content = '<div role="alert">' + content + '</div>';
- this.overlay.set('bodyContent', content);
+ var contentnode, heading;
+ contentnode = Y.Node.create('<div role="alert">' + content + '</div>');
+ this.overlay.set('bodyContent', contentnode);
+ heading = contentnode.one('h1');
+ if (heading) {
+ heading.set('tabIndex', 0);
+ heading.focus();
+ }
},
hideContent : function() {
if (!empty($CFG->messaging)) {
$messageargs = null;
- if ($USER->id!=$user->id) {
- $messageargs = array('id'=>$user->id);
+ if ($USER->id != $user->id) {
+ $messageargs = array('user1' => $user->id);
}
$url = new moodle_url('/message/index.php',$messageargs);
$usernode->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
if (!isset($CFG->phpunit_dataroot)) {
phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, 'Missing $CFG->phpunit_dataroot in config.php, can not run tests!');
}
-// Ensure we access to phpunit_dataroot realpath always.
-$CFG->phpunit_dataroot = realpath($CFG->phpunit_dataroot);
-if (isset($CFG->dataroot) and $CFG->phpunit_dataroot === $CFG->dataroot) {
- phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, '$CFG->dataroot and $CFG->phpunit_dataroot must not be identical, can not run tests!');
-}
+// Create test dir if does not exists yet.
if (!file_exists($CFG->phpunit_dataroot)) {
mkdir($CFG->phpunit_dataroot, $CFG->directorypermissions);
}
phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, '$CFG->phpunit_dataroot directory can not be created, can not run tests!');
}
+// Ensure we access to phpunit_dataroot realpath always.
+$CFG->phpunit_dataroot = realpath($CFG->phpunit_dataroot);
+
+if (isset($CFG->dataroot) and $CFG->phpunit_dataroot === $CFG->dataroot) {
+ phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, '$CFG->dataroot and $CFG->phpunit_dataroot must not be identical, can not run tests!');
+}
+
if (!is_writable($CFG->phpunit_dataroot)) {
// try to fix permissions if possible
if (function_exists('posix_getuid')) {
this.listenevents.push(thisevent);
// Grab global keyup events and handle them
- thisevent = Y.one('document').on('keyup', this.handle_key_press, this);
+ thisevent = Y.one('document').on('keydown', this.handle_key_press, this);
this.listenevents.push(thisevent);
// Add references to various elements we adjust
//if they have numerous contacts or are viewing course participants we might need to page through them
$page = optional_param('page', 0, PARAM_INT);
-$url = new moodle_url('/message/index.php');
+$url = new moodle_url('/message/index.php', array('user1' => $user1id));
if ($user2id !== 0) {
$url->param('user2', $user2id);
-}
-if ($user2id !== 0) {
//Switch view back to contacts if:
//1) theyve searched and selected a user
//2) they've viewed recent messages or notifications and clicked through to a user
- if ($viewing == MESSAGE_VIEW_SEARCH || $viewing == MESSAGE_VIEW_SEARCH || $viewing == MESSAGE_VIEW_RECENT_NOTIFICATIONS) {
+ if ($viewing == MESSAGE_VIEW_SEARCH || $viewing == MESSAGE_VIEW_RECENT_NOTIFICATIONS) {
$viewing = MESSAGE_VIEW_CONTACTS;
}
}
-$url->param('viewing', $viewing);
+
+if ($viewing != MESSAGE_VIEW_UNREAD_MESSAGES) {
+ $url->param('viewing', $viewing);
+}
$PAGE->set_url($url);
$PAGE->navigation->extend_for_user($USER);
$PAGE->set_pagelayout('course');
+$navigationurl = new moodle_url('/message/index.php', array('user1' => $user1id));
+navigation_node::override_active_url($navigationurl);
+
// Disable message notification popups while the user is viewing their messages
$PAGE->set_popup_notification_allowed(false);
-$context = get_context_instance(CONTEXT_SYSTEM);
+//$context = get_context_instance(CONTEXT_SYSTEM);
$user1 = null;
$currentuser = true;
-$showcontactactionlinks = true;
+$showactionlinks = true;
if ($user1id != $USER->id) {
$user1 = $DB->get_record('user', array('id' => $user1id));
if (!$user1) {
print_error('invaliduserid');
}
$currentuser = false;//if we're looking at someone else's messages we need to lock/remove some UI elements
- $showcontactactionlinks = false;
+ $showactionlinks = false;
} else {
$user1 = $USER;
}
}
unset($user2id);
+$systemcontext = context_system::instance();
+
// Is the user involved in the conversation?
// Do they have the ability to read other user's conversations?
-if (!message_current_user_is_involved($user1, $user2) && !has_capability('moodle/site:readallmessages', $context)) {
+if (!message_current_user_is_involved($user1, $user2) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
print_error('accessdenied','admin');
}
+$PAGE->set_context(context_user::instance($user1->id));
+$PAGE->set_pagelayout('course');
+$PAGE->navigation->extend_for_user($user1);
+
/// Process any contact maintenance requests there may be
if ($addcontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'add contact', 'index.php?user1='.$addcontact.'&user2='.$USER->id, $addcontact);
//was a message sent? Do NOT allow someone looking at someone else's messages to send them.
$messageerror = null;
-if ($currentuser && !empty($user2) && has_capability('moodle/site:sendmessage', $context)) {
+if ($currentuser && !empty($user2) && has_capability('moodle/site:sendmessage', $systemcontext)) {
// Check that the user is not blocking us!!
if ($contact = $DB->get_record('message_contacts', array('userid' => $user2->id, 'contactid' => $user1->id))) {
- if ($contact->blocked and !has_capability('moodle/site:readallmessages', $context)) {
+ if ($contact->blocked and !has_capability('moodle/site:readallmessages', $systemcontext)) {
$messageerror = get_string('userisblockingyou', 'message');
}
}
}
$countunreadtotal = message_count_unread_messages($user1);
-if ($countunreadtotal == 0 && $viewing == MESSAGE_VIEW_UNREAD_MESSAGES && empty($user2)) {
- //default to showing the search
+if ($currentuser && $countunreadtotal == 0 && $viewing == MESSAGE_VIEW_UNREAD_MESSAGES && empty($user2)) {
+ // If the user has no unread messages, show the search box.
+ // We don't do this when a user is viewing another user's messages as search doesn't
+ // handle user A searching user B's messages properly.
$viewing = MESSAGE_VIEW_SEARCH;
}
list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts($user1, $user2);
-message_print_contact_selector($countunreadtotal, $viewing, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showcontactactionlinks, $page);
+message_print_contact_selector($countunreadtotal, $viewing, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showactionlinks, $page);
echo html_writer::start_tag('div', array('class' => 'messagearea mdl-align'));
if (!empty($user2)) {
$messagehistorylink .= html_writer::end_tag('div');
- message_print_message_history($user1, $user2, $search, $displaycount, $messagehistorylink, $viewingnewmessages);
+ message_print_message_history($user1, $user2, $search, $displaycount, $messagehistorylink, $viewingnewmessages, $showactionlinks);
echo html_writer::end_tag('div');
//send message form
- if ($currentuser && has_capability('moodle/site:sendmessage', $context)) {
+ if ($currentuser && has_capability('moodle/site:sendmessage', $systemcontext)) {
echo html_writer::start_tag('div', array('class' => 'mdl-align messagesend'));
if (!empty($messageerror)) {
echo html_writer::tag('span', $messageerror, array('id' => 'messagewarning'));
} else if ($viewing == MESSAGE_VIEW_SEARCH) {
message_print_search($advancedsearch, $user1);
} else if ($viewing == MESSAGE_VIEW_RECENT_CONVERSATIONS) {
- message_print_recent_conversations($user1);
+ message_print_recent_conversations($user1, false, $showactionlinks);
} else if ($viewing == MESSAGE_VIEW_RECENT_NOTIFICATIONS) {
message_print_recent_notifications($user1);
}
* @param array $onlinecontacts an array of $user1's online contacts
* @param array $offlinecontacts an array of $user1's offline contacts
* @param array $strangers an array of users who have messaged $user1 who aren't contacts
- * @param bool $showcontactactionlinks show action links (add/remove contact etc) next to the users in the contact selector
+ * @param bool $showactionlinks show action links (add/remove contact etc)
* @param int $page if there are so many users listed that they have to be split into pages what page are we viewing
* @return void
*/
-function message_print_contact_selector($countunreadtotal, $viewing, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showcontactactionlinks, $page=0) {
+function message_print_contact_selector($countunreadtotal, $viewing, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showactionlinks, $page=0) {
global $PAGE;
echo html_writer::start_tag('div', array('class' => 'contactselector mdl-align'));
$strunreadmessages = get_string('unreadmessages','message', $countunreadtotal);
}
- message_print_usergroup_selector($viewing, $courses, $coursecontexts, $countunreadtotal, count($blockedusers), $strunreadmessages);
+ message_print_usergroup_selector($viewing, $courses, $coursecontexts, $countunreadtotal, count($blockedusers), $strunreadmessages, $user1);
if ($viewing == MESSAGE_VIEW_UNREAD_MESSAGES) {
- message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $PAGE->url, 1, $showcontactactionlinks,$strunreadmessages, $user2);
+ message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $PAGE->url, 1, $showactionlinks,$strunreadmessages, $user2);
} else if ($viewing == MESSAGE_VIEW_CONTACTS || $viewing == MESSAGE_VIEW_SEARCH || $viewing == MESSAGE_VIEW_RECENT_CONVERSATIONS || $viewing == MESSAGE_VIEW_RECENT_NOTIFICATIONS) {
- message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $PAGE->url, 0, $showcontactactionlinks, $strunreadmessages, $user2);
+ message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $PAGE->url, 0, $showactionlinks, $strunreadmessages, $user2);
} else if ($viewing == MESSAGE_VIEW_BLOCKED) {
- message_print_blocked_users($blockedusers, $PAGE->url, $showcontactactionlinks, null, $user2);
+ message_print_blocked_users($blockedusers, $PAGE->url, $showactionlinks, null, $user2);
} else if (substr($viewing, 0, 7) == MESSAGE_VIEW_COURSE) {
$courseidtoshow = intval(substr($viewing, 7));
&& array_key_exists($courseidtoshow, $coursecontexts)
&& has_capability('moodle/course:viewparticipants', $coursecontexts[$courseidtoshow])) {
- message_print_participants($coursecontexts[$courseidtoshow], $courseidtoshow, $PAGE->url, $showcontactactionlinks, null, $page, $user2);
+ message_print_participants($coursecontexts[$courseidtoshow], $courseidtoshow, $PAGE->url, $showactionlinks, null, $page, $user2);
} else {
//shouldn't get here. User trying to access a course they're not in perhaps.
add_to_log(SITEID, 'message', 'view', 'index.php', $viewing);
}
}
- echo html_writer::start_tag('form', array('action' => 'index.php','method' => 'GET'));
- echo html_writer::start_tag('fieldset');
- $managebuttonclass = 'visible';
- if ($viewing == MESSAGE_VIEW_SEARCH) {
- $managebuttonclass = 'hiddenelement';
+ // Only show the search button if we're viewing our own messages.
+ // Search isn't currently able to deal with user A wanting to search user B's messages.
+ if ($showactionlinks) {
+ echo html_writer::start_tag('form', array('action' => 'index.php','method' => 'GET'));
+ echo html_writer::start_tag('fieldset');
+ $managebuttonclass = 'visible';
+ if ($viewing == MESSAGE_VIEW_SEARCH) {
+ $managebuttonclass = 'hiddenelement';
+ }
+ $strmanagecontacts = get_string('search','message');
+ echo html_writer::empty_tag('input', array('type' => 'hidden','name' => 'viewing','value' => MESSAGE_VIEW_SEARCH));
+ echo html_writer::empty_tag('input', array('type' => 'submit','value' => $strmanagecontacts,'class' => $managebuttonclass));
+ echo html_writer::end_tag('fieldset');
+ echo html_writer::end_tag('form');
}
- $strmanagecontacts = get_string('search','message');
- echo html_writer::empty_tag('input', array('type' => 'hidden','name' => 'viewing','value' => MESSAGE_VIEW_SEARCH));
- echo html_writer::empty_tag('input', array('type' => 'submit','value' => $strmanagecontacts,'class' => $managebuttonclass));
- echo html_writer::end_tag('fieldset');
- echo html_writer::end_tag('form');
echo html_writer::end_tag('div');
}
}
if($countonlinecontacts) {
- /// print out list of online contacts
+ // Print out list of online contacts.
if (empty($titletodisplay)) {
message_print_heading(get_string('onlinecontacts', 'message', $countonlinecontacts));
}
if ($countofflinecontacts) {
- /// print out list of offline contacts
+ // Print out list of offline contacts.
if (empty($titletodisplay)) {
message_print_heading(get_string('offlinecontacts', 'message', $countofflinecontacts));
}
- /// print out list of incoming contacts
+ // Print out list of incoming contacts.
if ($countstrangers) {
message_print_heading(get_string('incomingcontacts', 'message', $countstrangers));
* @param array $coursecontexts array of course contexts. Keyed on course id.
* @param int $countunreadtotal how many unread messages does the user have?
* @param int $countblocked how many users has the current user blocked?
+ * @param stdClass $user1 The user whose messages we are viewing.
* @param string $strunreadmessages a preconstructed message about the number of unread messages the user has
* @return void
*/
-function message_print_usergroup_selector($viewing, $courses, $coursecontexts, $countunreadtotal, $countblocked, $strunreadmessages) {
+function message_print_usergroup_selector($viewing, $courses, $coursecontexts, $countunreadtotal, $countblocked, $strunreadmessages, $user1 = null) {
$options = array();
if ($countunreadtotal>0) { //if there are unread messages
echo html_writer::start_tag('form', array('id' => 'usergroupform','method' => 'get','action' => ''));
echo html_writer::start_tag('fieldset');
+ if ( !empty($user1) && !empty($user1->id) ) {
+ echo html_writer::empty_tag('input', array('type' => 'hidden','name' => 'user1','value' => $user1->id));
+ }
echo html_writer::label(get_string('messagenavigation', 'message'), 'viewing');
echo html_writer::select($options, 'viewing', $viewing, false, array('id' => 'viewing','onchange' => 'this.form.submit()'));
echo html_writer::end_tag('fieldset');
* @param stdClass $user the current user
* @param bool $showicontext flag indicating whether or not to show text next to the action icons
*/
-function message_print_recent_conversations($user=null, $showicontext=false) {
+function message_print_recent_conversations($user1 = null, $showicontext = false, $showactionlinks = true) {
global $USER;
echo html_writer::start_tag('p', array('class' => 'heading'));
echo get_string('mostrecentconversations', 'message');
echo html_writer::end_tag('p');
- if (empty($user)) {
- $user = $USER;
+ if (empty($user1)) {
+ $user1 = $USER;
}
- $conversations = message_get_recent_conversations($user);
+ $conversations = message_get_recent_conversations($user1);
// Attach context url information to create the "View this conversation" type links
foreach($conversations as $conversation) {
- $conversation->contexturl = new moodle_url("/message/index.php?user2={$conversation->id}");
+ $conversation->contexturl = new moodle_url("/message/index.php?user1={$user1->id}&user2={$conversation->id}");
$conversation->contexturlname = get_string('thisconversation', 'message');
}
$showotheruser = true;
- message_print_recent_messages_table($conversations, $user, $showotheruser, $showicontext);
+ message_print_recent_messages_table($conversations, $user1, $showotheruser, $showicontext, false, $showactionlinks);
}
/**
* @param bool $showicontext show text next to the action icons?
* @return void
*/
-function message_print_recent_messages_table($messages, $user=null, $showotheruser=true, $showicontext=false) {
+function message_print_recent_messages_table($messages, $user = null, $showotheruser = true, $showicontext = false, $forcetexttohtml = false, $showactionlinks = true) {
global $OUTPUT;
static $dateformat;
echo html_writer::start_tag('div', array('class' => 'singlemessage'));
if ($showotheruser) {
- if ( $message->contactlistid ) {
- if ($message->blocked == 0) { /// not blocked
- $strcontact = message_contact_link($message->id, 'remove', true, null, $showicontext);
- $strblock = message_contact_link($message->id, 'block', true, null, $showicontext);
- } else { // blocked
+ $strcontact = $strblock = $strhistory = null;
+
+ if ($showactionlinks) {
+ if ( $message->contactlistid ) {
+ if ($message->blocked == 0) { // The other user isn't blocked.
+ $strcontact = message_contact_link($message->id, 'remove', true, null, $showicontext);
+ $strblock = message_contact_link($message->id, 'block', true, null, $showicontext);
+ } else { // The other user is blocked.
+ $strcontact = message_contact_link($message->id, 'add', true, null, $showicontext);
+ $strblock = message_contact_link($message->id, 'unblock', true, null, $showicontext);
+ }
+ } else {
$strcontact = message_contact_link($message->id, 'add', true, null, $showicontext);
- $strblock = message_contact_link($message->id, 'unblock', true, null, $showicontext);
+ $strblock = message_contact_link($message->id, 'block', true, null, $showicontext);
}
- } else {
- $strcontact = message_contact_link($message->id, 'add', true, null, $showicontext);
- $strblock = message_contact_link($message->id, 'block', true, null, $showicontext);
- }
- //should we show just the icon or icon and text?
- $histicontext = 'icon';
- if ($showicontext) {
- $histicontext = 'both';
+ //should we show just the icon or icon and text?
+ $histicontext = 'icon';
+ if ($showicontext) {
+ $histicontext = 'both';
+ }
+ $strhistory = message_history_link($user->id, $message->id, true, '', '', $histicontext);
}
- $strhistory = message_history_link($user->id, $message->id, true, '', '', $histicontext);
-
echo html_writer::start_tag('span', array('class' => 'otheruser'));
echo html_writer::start_tag('span', array('class' => 'pix'));
echo html_writer::start_tag('span', array('class' => 'contact'));
- $link = new moodle_url("/message/index.php?id=$message->id");
+ $link = new moodle_url("/message/index.php?user1={$user->id}&user2=$message->id");
$action = null;
echo $OUTPUT->action_link($link, fullname($message), $action, array('title' => get_string('sendmessageto', 'message', fullname($message))));
echo html_writer::end_tag('span');//end contact
- echo $strcontact.$strblock.$strhistory;
+ if ($showactionlinks) {
+ echo $strcontact.$strblock.$strhistory;
+ }
echo html_writer::end_tag('span');//end otheruser
}
$messagetoprint = null;
}
if (($contact = $DB->get_record('message_contacts', array('userid' => $USER->id, 'contactid' => $contactid))) !== false) {
- /// record already exists - we may be changing blocking status
+ // A record already exists. We may be changing blocking status.
if ($contact->blocked !== $blocked) {
- /// change to blocking status
+ // Blocking status has been changed.
$contact->blocked = $blocked;
return $DB->update_record('message_contacts', $contact);
} else {
- /// no changes to blocking status
+ // No change to blocking status.
return true;
}
} else {
- /// new contact record
+ // New contact record.
$contact = new stdClass();
$contact->userid = $USER->id;
$contact->contactid = $contactid;
$personsearchstring = $frm->combinedsearch;
}
- /// search for person
+ // Search for person.
if ($personsearch) {
if (optional_param('mycourses', 0, PARAM_BOOL)) {
$users = array();
foreach ($users as $user) {
if ( $user->contactlistid ) {
- if ($user->blocked == 0) { /// not blocked
+ if ($user->blocked == 0) { // User is not blocked.
$strcontact = message_contact_link($user->id, 'remove', true, null, $showicontext);
$strblock = message_contact_link($user->id, 'block', true, null, $showicontext);
} else { // blocked
$strblock = message_contact_link($user->id, 'block', true, null, $showicontext);
}
- //should we show just the icon or icon and text?
+ // Should we show just the icon or icon and text?
$histicontext = 'icon';
if ($showicontext) {
$histicontext = 'both';
if (($messages = message_search($keywords, $fromme, $tome, $courseid)) !== false) {
- /// get a list of contacts
+ // Get a list of contacts.
if (($contacts = $DB->get_records('message_contacts', array('userid' => $USER->id), '', 'contactid, blocked') ) === false) {
$contacts = array();
}
- /// print heading with number of results
+ // Print heading with number of results.
echo html_writer::start_tag('p', array('class' => 'heading searchresultcount'));
$countresults = count($messages);
if ($countresults == MESSAGE_SEARCH_MAX_RESULTS) {
}
echo html_writer::end_tag('p');
- /// print table headings
+ // Print table headings.
echo html_writer::start_tag('table', array('class' => 'messagesearchresults', 'cellspacing' => '0'));
$headertdstart = html_writer::start_tag('td', array('class' => 'messagesearchresultscol'));
$strcontext = get_string('context', 'message');
foreach ($messages as $message) {
- /// ignore messages to and from blocked users unless $frm->includeblocked is set
+ // Ignore messages to and from blocked users unless $frm->includeblocked is set.
if (!optional_param('includeblocked', 0, PARAM_BOOL) and (
( isset($contacts[$message->useridfrom]) and ($contacts[$message->useridfrom]->blocked == 1)) or
( isset($contacts[$message->useridto] ) and ($contacts[$message->useridto]->blocked == 1))
continue;
}
- /// load up user to record
+ // Load user-to record.
if ($message->useridto !== $USER->id) {
$userto = $DB->get_record('user', array('id' => $message->useridto));
$tocontact = (array_key_exists($message->useridto, $contacts) and
$toblocked = false;
}
- /// load up user from record
+ // Load user-from record.
if ($message->useridfrom !== $USER->id) {
$userfrom = $DB->get_record('user', array('id' => $message->useridfrom));
$fromcontact = (array_key_exists($message->useridfrom, $contacts) and
$fromblocked = false;
}
- /// find date string for this message
+ // Find date string for this message.
$date = usergetdate($message->timecreated);
$datestring = $date['year'].$date['mon'].$date['mday'];
- /// print out message row
+ // Print out message row.
echo html_writer::start_tag('tr', array('valign' => 'top'));
echo html_writer::start_tag('td', array('class' => 'contact'));
echo message_get_fragment($message->smallmessage, $keywords);
echo html_writer::start_tag('div', array('class' => 'link'));
- //If the user clicks the context link display message sender on the left
- //EXCEPT if the current user is in the conversation. Current user == always on the left
+ // If the user clicks the context link display message sender on the left.
+ // EXCEPT if the current user is in the conversation. Current user == always on the left.
$leftsideuserid = $rightsideuserid = null;
if ($currentuser->id == $message->useridto) {
$leftsideuserid = $message->useridto;
}
/**
- * search a user's messages
+ * Search a user's messages
+ *
+ * Returns a list of posts found using an array of search terms
+ * eg word +word -word
*
* @param array $searchterms an array of search terms (strings)
* @param bool $fromme include messages from the user?
* @return mixed An array of messages or false if no matching messages were found
*/
function message_search($searchterms, $fromme=true, $tome=true, $courseid='none', $userid=0) {
-/// Returns a list of posts found using an array of search terms
-/// eg word +word -word
-///
global $CFG, $USER, $DB;
// If user is searching all messages check they are allowed to before doing anything else
print_error('accessdenied','admin');
}
- /// If no userid sent then assume current user
+ // If no userid sent then assume current user.
if ($userid == 0) $userid = $USER->id;
- /// Some differences in SQL syntax
+ // Some differences in SQL syntax.
if ($DB->sql_regex_supported()) {
$REGEXP = $DB->sql_regex(true);
$NOTREGEXP = $DB->sql_regex(false);
$params = array();
$i = 0;
- //preprocess search terms to check whether we have at least 1 eligible search term
- //if we do we can drop words around it like 'a'
+ // Preprocess search terms to check whether we have at least 1 eligible search term.
+ // If we do we can drop words around it like 'a'.
$dropshortwords = false;
foreach ($searchterms as $searchterm) {
if (strlen($searchterm) >= 2) {
foreach ($searchterms as $searchterm) {
$i++;
- $NOT = false; /// Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle
+ $NOT = false; // Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle.
if ($dropshortwords && strlen($searchterm) < 2) {
continue;
}
- /// Under Oracle and MSSQL, trim the + and - operators and perform
- /// simpler LIKE search
+ // Under Oracle and MSSQL, trim the + and - operators and perform simpler LIKE search.
if (!$DB->sql_regex_supported()) {
if (substr($searchterm, 0, 1) == '-') {
$NOT = true;
$searchcond = implode(" AND ", $searchcond);
}
- /// There are several possibilities
- /// 1. courseid = SITEID : The admin is searching messages by all users
- /// 2. courseid = ?? : A teacher is searching messages by users in
- /// one of their courses - currently disabled
- /// 3. courseid = none : User is searching their own messages;
- /// a. Messages from user
- /// b. Messages to user
- /// c. Messages to and from user
+ // There are several possibilities
+ // 1. courseid = SITEID : The admin is searching messages by all users
+ // 2. courseid = ?? : A teacher is searching messages by users in
+ // one of their courses - currently disabled
+ // 3. courseid = none : User is searching their own messages;
+ // a. Messages from user
+ // b. Messages to user
+ // c. Messages to and from user
- if ($courseid == SITEID) { /// admin is searching all messages
+ if ($courseid == SITEID) { // Admin is searching all messages.
$m_read = $DB->get_records_sql("SELECT m.id, m.useridto, m.useridfrom, m.smallmessage, m.fullmessage, m.timecreated
FROM {message_read} m
WHERE $searchcond", $params, 0, MESSAGE_SEARCH_MAX_RESULTS);
WHERE $searchcond", $params, 0, MESSAGE_SEARCH_MAX_RESULTS);
} else if ($courseid !== 'none') {
- /// This has not been implemented due to security concerns
+ // This has not been implemented due to security concerns.
$m_read = array();
$m_unread = array();
* @param string $messagehistorylink the html for the message history link or false
* @param bool $viewingnewmessages are we currently viewing new messages?
*/
-function message_print_message_history($user1,$user2,$search='',$messagelimit=0, $messagehistorylink=false, $viewingnewmessages=false) {
+function message_print_message_history($user1, $user2 ,$search = '', $messagelimit = 0, $messagehistorylink = false, $viewingnewmessages = false, $showactionlinks = true) {
global $CFG, $OUTPUT;
echo $OUTPUT->box_start('center');
echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID));
echo html_writer::tag('div', fullname($user2), array('class' => 'heading'));
- if (isset($user2->iscontact) && isset($user2->isblocked)) {
- $incontactlist = $user2->iscontact;
- $isblocked = $user2->isblocked;
+ if ($showactionlinks && isset($user2->iscontact) && isset($user2->isblocked)) {
$script = null;
$text = true;
$icon = false;
- $strcontact = message_get_contact_add_remove_link($incontactlist, $isblocked, $user2, $script, $text, $icon);
- $strblock = message_get_contact_block_link($incontactlist, $isblocked, $user2, $script, $text, $icon);
+ $strcontact = message_get_contact_add_remove_link($user2->iscontact, $user2->isblocked, $user2, $script, $text, $icon);
+ $strblock = message_get_contact_block_link($user2->iscontact, $user2->isblocked, $user2, $script, $text, $icon);
$useractionlinks = $strcontact.' |'.$strblock;
echo html_writer::tag('div', $useractionlinks, array('class' => 'useractionlinks'));
$linkclass = 'messageselecteduser';
}
- /// are there any unread messages for this contact?
+ // Are there any unread messages for this contact?
if ($contact->messagecount > 0 ){
$fullnamelink = '<strong>'.$fullnamelink.' ('.$contact->messagecount.')</strong>';
}
if (!has_capability('mod/assign:grade', $context)) {
if (!has_capability('mod/assign:submit', $context)) {
throw new comment_exception('nopermissiontocomment');
- } else if ($assignment->get_instance()->teamsubmission) {
- $group = $assignment->get_submission_group($USER->id);
- $groupid = 0;
- if ($group) {
- $groupid = $group->id;
- }
- if ($groupid != $submission->groupid) {
- throw new comment_exception('nopermissiontocomment');
- }
} else if ($submission->userid != $USER->id) {
throw new comment_exception('nopermissiontocomment');
}
if (!has_capability('mod/assign:grade', $context)) {
if (!has_capability('mod/assign:submit', $context)) {
return array('post' => false, 'view' => false);
- } else if ($assignment->get_instance()->teamsubmission) {
- $group = $assignment->get_submission_group($USER->id);
- $groupid = 0;
- if ($group) {
- $groupid = $group->id;
- }
- if ($groupid != $submission->groupid) {
- return array('post' => false, 'view' => false);
- }
} else if ($submission->userid != $USER->id) {
return array('post' => false, 'view' => false);
}
$tmpactivity->sectionnum= $cm->sectionnum;
$tmpactivity->timestamp = $feedbackitem->timemodified;
+ $tmpactivity->content = new stdClass();
$tmpactivity->content->feedbackid = $feedbackitem->id;
$tmpactivity->content->feedbackuserid = $feedbackitem->userid;
- //TODO: add all necessary user fields, this is not enough for user_picture
- $tmpactivity->user->userid = $feedbackitem->userid;
+ $userfields = explode(',', user_picture::fields());
+ $tmpactivity->user = new stdClass();
+ foreach ($userfields as $userfield) {
+ if ($userfield == 'id') {
+ $tmpactivity->user->{$userfield} = $feedbackitem->userid; // aliased in SQL above
+ } else {
+ if (!empty($feedbackitem->{$userfield})) {
+ $tmpactivity->user->{$userfield} = $feedbackitem->{$userfield};
+ } else {
+ $tmpactivity->user->{$userfield} = null;
+ }
+ }
+ }
$tmpactivity->user->fullname = fullname($feedbackitem, $viewfullnames);
- $tmpactivity->user->picture = $feedbackitem->picture;
$activities[$index++] = $tmpactivity;
}
echo '</div>';
echo '<div class="user">';
- echo "<a href=\"$CFG->wwwroot/user/view.php?id={$activity->user->userid}&course=$courseid\">"
+ echo "<a href=\"$CFG->wwwroot/user/view.php?id={$activity->user->id}&course=$courseid\">"
."{$activity->user->fullname}</a> - ".userdate($activity->timestamp);
echo '</div>';
*/
function forum_get_course_forum($courseid, $type) {
// How to set up special 1-per-course forums
- global $CFG, $DB, $OUTPUT;
+ global $CFG, $DB, $OUTPUT, $USER;
if ($forums = $DB->get_records_select("forum", "course = ? AND type = ?", array($courseid, $type), "id ASC")) {
// There should always only be ONE, but with the right combination of
$forum = new stdClass();
$forum->course = $courseid;
$forum->type = "$type";
+ if (!empty($USER->htmleditor)) {
+ $forum->introformat = $USER->htmleditor;
+ }
switch ($forum->type) {
case "news":
$forum->name = get_string("namenews", "forum");
}
- function readquestion($lines) {
+ protected function readquestion($lines) {
/// Given an array of lines known to define a question in
/// this format, this function converts it into a question
/// object suitable for processing and insertion into Moodle.
echo '<div class="questionbankwindow ' . $bankclass . 'block">';
echo '<div class="header"><div class="title"><h2>';
echo get_string('questionbankcontents', 'quiz') .
- ' <a href="' . $thispageurl->out(true, array('qbanktool' => '1')) .
- '" id="showbankcmd">[' . get_string('show').
- ']</a>
- <a href="' . $thispageurl->out(true, array('qbanktool' => '0')) .
- '" id="hidebankcmd">[' . get_string('hide').
- ']</a>';
+ ' [<a href="' . $thispageurl->out(true, array('qbanktool' => '1')) .
+ '" id="showbankcmd">' . get_string('show').
+ '</a><a href="' . $thispageurl->out(true, array('qbanktool' => '0')) .
+ '" id="hidebankcmd">' . get_string('hide').
+ '</a>]';
echo '</h2></div></div><div class="content">';
echo '<span id="questionbank"></span>';
http://docs.moodle.org/dev/Quiz_UI_redesign/usability_testing_of_August_2008/Issues#Question_bank_.2F_question_adding_controls_visibility
it must be ensured that the question
bank window's title is prominent enough*/
-#page-mod-quiz-edit .questionbankwindow div.header {background-color:#009;color:#fff;background-image:none;padding-top:0.2em;font-weight:bold;}
-#page-mod-quiz-edit .questionbankwindow div.header a{text-decoration:underline;color:#FFF;}
+#page-mod-quiz-edit .questionbankwindow.block div.header {background-color:#009;background-image:none;padding-top:0.2em;font-weight:bold;border:0 none;}
+#page-mod-quiz-edit .questionbankwindow.block div.header div.title h2 {color:#FFF;text-align: center;}
#page-mod-quiz-edit .collapsed .container{display: none;}
+
+#page-mod-quiz-edit .questionbankwindow a#showbankcmd,
+#page-mod-quiz-edit .questionbankwindow a#hidebankcmd {color: #FFF;text-decoration:underline;}
+#page-mod-quiz-edit .questionbankwindow a#showbankcmd:hover,
+#page-mod-quiz-edit .questionbankwindow a#hidebankcmd:hover {color:#009;background-color:#fff;text-decoration:none;}
#page-mod-quiz-edit .questionbankwindow #showbankcmd{display:none;}
#page-mod-quiz-edit .collapsed #showbankcmd{display:inline;}
#page-mod-quiz-edit .questionbankwindow #hidebankcmd{display:inline;}
$result = scorm_get_toc($USER, $scorm, $cm->id, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, true);
$sco = $result->sco;
+if ($scorm->lastattemptlock == 1 && $result->attemptleft == 0) {
+ echo $OUTPUT->header();
+ echo $OUTPUT->notification(get_string('exceededmaxattempts', 'scorm'));
+ echo $OUTPUT->footer();
+ exit;
+}
if (($mode == 'browse') && ($scorm->hidebrowse == 1)) {
$mode = 'normal';
'popupoptions' => $scorm->options), true);
$PAGE->requires->js('/mod/scorm/request.js', true);
$PAGE->requires->js('/lib/cookies.js', true);
-$PAGE->requires->css('/mod/scorm/styles.css');
echo $OUTPUT->header();
// NEW IMS TOC
$this->process_essay($question, $questions);
break;
default:
- $this->error(get_string('unknownorunhandledtype', 'qformat_blackboard_six', $question->qtype));
+ $this->error(get_string('unknownorunhandledtype', 'question', $question->qtype));
break;
}
}
}
public function readquestion($qrec) {
+ global $OUTPUT;
$type = trim($qrec['@']['type']);
$question = $this->defaultquestion();
break;
break;
default:
- print("<p>Question type ".$type." import not supported for ".$question->questiontext."<p>");
+ echo $OUTPUT->notification(get_string('unknownorunhandledtype', 'question', $type));
$question = null;
}
}
protected function readquestion($lines) {
+ global $OUTPUT;
+
$text = implode(' ', $lines);
$text = str_replace(array('\t','\n','\r'), array('','',''), $text);
}
} else {
- echo "<p>I don't understand this question type (type = <strong>$type</strong>).</p>\n";
+ echo $OUTPUT->notification(get_string('unknownorunhandledtype', 'question', $type));
}
$question = $this->defaultquestion();
$answerstart = strpos($text, "{");
if ($answerstart === false) {
- if ($this->displayerrors) {
- echo "<p>$text<p>Could not find a {";
- }
+ $this->error(get_string('beginanswernotfound', 'qformat_missingword'), $text);
return false;
}
$answerfinish = strpos($text, "}");
if ($answerfinish === false) {
- if ($this->displayerrors) {
- echo "<p>$text<p>Could not find a }";
- }
+ $this->error(get_string('endanswernotfound', 'qformat_missingword'), $text);
return false;
}
$answerlength = $answerfinish - $answerstart;
$answertext = substr($text, $answerstart + 1, $answerlength - 1);
- /// Save the new question text
+ // Save the new question text.
$question->questiontext = substr_replace($text, "_____", $answerstart, $answerlength+1);
$question->name = $this->create_default_question_name($question->questiontext, get_string('questionname', 'question'));
-
/// Parse the answers
$answertext = str_replace("=", "~=", $answertext);
$answers = explode("~", $answertext);
$countanswers = count($answers);
switch ($countanswers) {
- case 0: // invalid question
- if ($this->displayerrors) {
- echo "<p>No answers found in $answertext";
- }
+ case 0: // Invalid question.
+ $this->error(get_string('noanswerfound', 'qformat_missingword'), $answertext);
return false;
case 1:
}
$question->answer[] = $answer;
$question->fraction[] = 1;
- $question->feedback[] = "";
+ $question->feedback[] = array('text' => '', 'format' => FORMAT_HTML);
return $question;
default:
$question->qtype = MULTICHOICE;
+ $question = $this->add_blank_combined_feedback($question);
+ $question->single = 1; // Only one answer allowed.
+
foreach ($answers as $key => $answer) {
$answer = trim($answer);
# $question->fraction[$key] = 0;
$question->fraction[$key] = $answeight;
}
- $question->answer[$key] = $answer;
- $question->feedback[$key] = $comment;
+ $question->answer[$key] = array('text' => $answer, 'format' => FORMAT_HTML);
+ $question->feedback[$key] = array('text' => $comment, 'format' => FORMAT_HTML);
}
return $question;
$string['pluginname'] = 'Missing word format';
$string['pluginname_help'] = 'Missing word format enables questions to be imported via text file.';
$string['pluginname_link'] = 'Missing word format';
+$string['beginanswernotfound'] = 'Could not find a required "{" character in imported file content.';
+$string['endanswernotfound'] = 'Could not find a required "}" character in imported file content.';
+$string['noanswerfound'] = 'No answers found in question';
--- /dev/null
+As soon as we begin to explore our body parts as infants
+we become students of {=anatomy and physiology ~reflexology
+~science ~experiment}, and in a sense we remain students for life.
--- /dev/null
+You can use the missing word format to import questions
+into both Moodle's Question bank and {=Lesson} activity.
--- /dev/null
+This is {=the best answer#comment on the best answer ~75%a good
+answer#comment on the good answer ~a wrong one#comment on the bad answer}
case DESCRIPTION:
break;
case MULTIANSWER:
- $expout .= "<!-- CLOZE type is not supported -->\n";
- break;
default:
- echo $OUTPUT->notification("No handler for qtype $question->qtype for GIFT export" );
+ $expout .= "<!-- export of $question->qtype type is not supported -->\n";
}
// close off div
$expout .= "</div>\n\n\n";