continue;
}
try {
- $id = user_create_user($user, false); // It is truly a new user.
+ $id = user_create_user($user, false, false); // It is truly a new user.
$trace->output(get_string('auth_dbinsertuser', 'auth_db', array('name'=>$user->username, 'id'=>$id)), 1);
} catch (moodle_exception $e) {
$trace->output(get_string('auth_dbinsertusererror', 'auth_db', $user->username), 1);
// Make sure user context is present.
context_user::instance($id);
+
+ \core\event\user_created::create_from_userid($id)->trigger();
}
unset($add_users);
}
$table->add_field('email', XMLDB_TYPE_CHAR, '255', null, null, null);
$table->add_field('firstname', XMLDB_TYPE_CHAR, '255', null, null, null);
$table->add_field('lastname', XMLDB_TYPE_CHAR, '255', null, null, null);
+ $table->add_field('animal', XMLDB_TYPE_CHAR, '255', null, null, null);
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
set_config('field_updateremote_email', '0', 'auth_db');
set_config('field_lock_email', 'unlocked', 'auth_db');
+ // Create a user profile field and add mapping to it.
+ $DB->insert_record('user_info_field', ['shortname' => 'pet', 'name' => 'Pet', 'required' => 0,
+ 'visible' => 1, 'locked' => 0, 'categoryid' => 1, 'datatype' => 'text']);
+
+ set_config('field_map_profile_field_pet', 'animal', 'auth_db');
+ set_config('field_updatelocal_profile_field_pet', 'oncreate', 'auth_db');
+ set_config('field_updateremote_profile_field_pet', '0', 'auth_db');
+ set_config('field_lock_profile_field_pet', 'unlocked', 'auth_db');
+
// Init the rest of settings.
set_config('passtype', 'plaintext', 'auth_db');
set_config('changepasswordurl', '', 'auth_db');
public function test_plugin() {
global $DB, $CFG;
+ require_once($CFG->dirroot . '/user/profile/lib.php');
$this->resetAfterTest(true);
// Test bulk user account creation.
- $user2 = (object)array('name'=>'u2', 'pass'=>'heslo', 'email'=>'u2@example.com');
+ $user2 = (object)['name' => 'u2', 'pass' => 'heslo', 'email' => 'u2@example.com', 'animal' => 'cat'];
$user2->id = $DB->insert_record('auth_db_users', $user2);
$user3 = (object)array('name'=>'admin', 'pass'=>'heslo', 'email'=>'admin@example.com'); // Should be skipped.
$this->assertCount(2, $DB->get_records('user'));
$trace = new null_progress_trace();
+
+ // Sync users and make sure that two events user_created werer triggered.
+ $sink = $this->redirectEvents();
$auth->sync_users($trace, false);
+ $events = $sink->get_events();
+ $sink->close();
+ $this->assertCount(2, $events);
+ $this->assertTrue($events[0] instanceof \core\event\user_created);
+ $this->assertTrue($events[1] instanceof \core\event\user_created);
+ // Assert the two users were created.
$this->assertEquals(4, $DB->count_records('user'));
$u1 = $DB->get_record('user', array('username'=>$user1->name, 'auth'=>'db'));
$this->assertSame($user1->email, $u1->email);
+ $this->assertEmpty(profile_user_record($u1->id)->pet);
$u2 = $DB->get_record('user', array('username'=>$user2->name, 'auth'=>'db'));
$this->assertSame($user2->email, $u2->email);
+ $this->assertSame($user2->animal, profile_user_record($u2->id)->pet);
$admin = $DB->get_record('user', array('username'=>'admin', 'auth'=>'manual'));
$this->assertNotEmpty($admin);
$user2b = clone($user2);
$user2b->email = 'u2b@example.com';
+ $user2b->animal = 'dog';
$DB->update_record('auth_db_users', $user2b);
$auth->sync_users($trace, false);
$this->assertEquals(4, $DB->count_records('user'));
$u2 = $DB->get_record('user', array('username'=>$user2->name));
$this->assertSame($user2->email, $u2->email);
+ $this->assertSame($user2->animal, profile_user_record($u2->id)->pet);
$auth->sync_users($trace, true);
$this->assertEquals(4, $DB->count_records('user'));
set_config('field_updatelocal_email', 'onlogin', 'auth_db');
$auth->config->field_updatelocal_email = 'onlogin';
+ set_config('field_updatelocal_profile_field_pet', 'onlogin', 'auth_db');
+ $auth->config->field_updatelocal_profile_field_pet = 'onlogin';
$auth->sync_users($trace, false);
$this->assertEquals(4, $DB->count_records('user'));
$this->assertEquals(4, $DB->count_records('user'));
$u2 = $DB->get_record('user', array('username'=>$user2->name));
$this->assertSame($user2b->email, $u2->email);
+ $this->assertSame($user2b->animal, profile_user_record($u2->id)->pet);
// Test sync deletes and suspends.
* @return {Promise}
*/
IconSystemFontawesome.prototype.init = function() {
+ var currTheme = M.cfg.theme;
+
if (staticMap) {
return $.when(this);
}
- var map = LocalStorage.get('core/iconmap-fontawesome');
+ var map = LocalStorage.get('core_iconsystem/theme/' + currTheme + '/core/iconmap-fontawesome');
if (map) {
map = JSON.parse(map);
}
$.each(map, function(index, value) {
staticMap[value.component + '/' + value.pix] = value.to;
});
- LocalStorage.set('core/iconmap-fontawesome', JSON.stringify(staticMap));
+ LocalStorage.set('core_iconsystem/theme/' + currTheme + '/core/iconmap-fontawesome', JSON.stringify(staticMap));
return this;
}.bind(this));
};
list($identifier, $component) = $string;
$label = get_string($identifier, $component);
+ $group[] = $mform->createElement('html', html_writer::start_div('review_option_item'));
+ $el = $mform->createElement('checkbox', $field . $whenname, '', $label);
if ($withhelp) {
- $label .= ' ' . $OUTPUT->help_icon($identifier, $component);
+ $el->_helpbutton = $OUTPUT->render(new help_icon($identifier, $component));
}
-
- $group[] = $mform->createElement('checkbox', $field . $whenname, '', $label);
+ $group[] = $el;
+ $group[] = $mform->createElement('html', html_writer::end_div());
}
$mform->addGroup($group, $whenname . 'optionsgrp',
get_string('review' . $whenname, 'quiz'), null, false);
Then I should see "question 21 name" in the "categoryquestions" "table"
And I should see "question 22 name" in the "categoryquestions" "table"
And I should not see "question 01 name" in the "categoryquestions" "table"
+ And I click on "Show all 22" "link" in the ".pagingbottom" "css_element"
+ And I should see "question 01 name" in the "categoryquestions" "table"
+ And I should see "question 22 name" in the "categoryquestions" "table"
Scenario: Questions are added in the right place with multiple sections
Given the following "questions" exist:
if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) {
if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) {
$url = new \moodle_url('edit.php', array_merge($pageurl->params(),
- array('qperpage' => MAXIMUM_QUESTIONS_PER_PAGE)));
+ array('qpage' => 0, 'qperpage' => MAXIMUM_QUESTIONS_PER_PAGE)));
if ($totalnumber > MAXIMUM_QUESTIONS_PER_PAGE) {
$showall = '<a href="'.$url.'">'.get_string('showperpage', 'moodle', MAXIMUM_QUESTIONS_PER_PAGE).'</a>';
} else {
* @param {jQuery} drag the item being moved.
*/
DragDropOntoImageQuestion.prototype.dragMove = function(pageX, pageY, drag) {
- var thisQ = this;
+ var thisQ = this,
+ highlighted = false;
this.getRoot().find('.dropzone.group' + this.getGroup(drag)).each(function(i, dropNode) {
var drop = $(dropNode);
- if (thisQ.isPointInDrop(pageX, pageY, drop)) {
+ if (thisQ.isPointInDrop(pageX, pageY, drop) && !highlighted) {
+ highlighted = true;
drop.addClass('valid-drag-over-drop');
} else {
drop.removeClass('valid-drag-over-drop');
});
this.getRoot().find('.draghome.placed.group' + this.getGroup(drag)).not('.beingdragged').each(function(i, dropNode) {
var drop = $(dropNode);
- if (thisQ.isPointInDrop(pageX, pageY, drop)) {
+ if (thisQ.isPointInDrop(pageX, pageY, drop) && !highlighted && !thisQ.isDragSameAsDrop(drag, drop)) {
+ highlighted = true;
drop.addClass('valid-drag-over-drop');
} else {
drop.removeClass('valid-drag-over-drop');
var thisQ = this,
root = this.getRoot(),
placed = false;
+
+ // Looking for drag that was dropped on a dropzone.
root.find('.dropzone.group' + this.getGroup(drag)).each(function(i, dropNode) {
var drop = $(dropNode);
if (!thisQ.isPointInDrop(pageX, pageY, drop)) {
return false; // Stop the each() here.
});
- root.find('.draghome.placed.group' + this.getGroup(drag)).not('.beingdragged').each(function(i, placedNode) {
- var placedDrag = $(placedNode);
- if (!thisQ.isPointInDrop(pageX, pageY, placedDrag)) {
- // Not this placed drag.
- return true;
- }
+ if (!placed) {
+ // Looking for drag that was dropped on a placed drag.
+ root.find('.draghome.placed.group' + this.getGroup(drag)).not('.beingdragged').each(function(i, placedNode) {
+ var placedDrag = $(placedNode);
+ if (!thisQ.isPointInDrop(pageX, pageY, placedDrag) || thisQ.isDragSameAsDrop(drag, placedDrag)) {
+ // Not this placed drag.
+ return true;
+ }
- // Now put this drag into the drop.
- placedDrag.removeClass('valid-drag-over-drop');
- var currentPlace = thisQ.getClassnameNumericSuffix(placedDrag, 'inplace');
- var drop = thisQ.getDrop(drag, currentPlace);
- thisQ.sendDragToDrop(drag, drop);
- placed = true;
- return false; // Stop the each() here.
- });
+ // Now put this drag into the drop.
+ placedDrag.removeClass('valid-drag-over-drop');
+ var currentPlace = thisQ.getClassnameNumericSuffix(placedDrag, 'inplace');
+ var drop = thisQ.getDrop(drag, currentPlace);
+ thisQ.sendDragToDrop(drag, drop);
+ placed = true;
+ return false; // Stop the each() here.
+ });
+ }
if (!placed) {
this.sendDragHome(drag);
return zIndex;
};
+ /**
+ * Check that the drag is drop to it's clone.
+ *
+ * @param {jQuery} drag The drag.
+ * @param {jQuery} drop The drop.
+ * @returns {boolean}
+ */
+ DragDropOntoImageQuestion.prototype.isDragSameAsDrop = function(drag, drop) {
+ return this.getChoice(drag) === this.getChoice(drop) && this.getGroup(drag) === this.getGroup(drop);
+ };
+
/**
* Singleton object that handles all the DragDropOntoImageQuestions
* on the page, and deals with event dispatching.
* @param {jQuery} element Element to bind the event
*/
addEventHandlersToDrag: function(element) {
+ // Unbind all the mousedown and touchstart events to prevent double binding.
+ element.unbind('mousedown touchstart');
element.on('mousedown touchstart', questionManager.handleDragStart);
},
clear: left;
}
#page-mod-quiz-mod #id_reviewoptionshdr .form-check {
- width: 90%;
+ width: auto;
height: 22px;
justify-content: flex-start;
}
+#page-mod-quiz-mod #id_reviewoptionshdr .review_option_item {
+ width: 90%;
+ height: 22px;
+}
+
// Question navigation block.
.path-mod-quiz #mod_quiz_navblock {
.qnbutton {
clear: left; }
#page-mod-quiz-mod #id_reviewoptionshdr .form-check {
- width: 90%;
+ width: auto;
height: 22px;
justify-content: flex-start; }
+#page-mod-quiz-mod #id_reviewoptionshdr .review_option_item {
+ width: 90%;
+ height: 22px; }
+
.path-mod-quiz #mod_quiz_navblock .qnbutton {
text-decoration: none;
font-size: 14px;
clear: left; }
#page-mod-quiz-mod #id_reviewoptionshdr .form-check {
- width: 90%;
+ width: auto;
height: 22px;
justify-content: flex-start; }
+#page-mod-quiz-mod #id_reviewoptionshdr .review_option_item {
+ width: 90%;
+ height: 22px; }
+
.path-mod-quiz #mod_quiz_navblock .qnbutton {
text-decoration: none;
font-size: 14px;