mirror of
https://github.com/moodle/moodle.git
synced 2025-08-10 03:16:42 +02:00
Merge branch 'wip-MDL-51636-master' of https://github.com/marinaglancy/moodle
This commit is contained in:
commit
7c88aa7bec
7 changed files with 70 additions and 61 deletions
|
@ -6,9 +6,9 @@ Feature: Block tags displaying tag cloud
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given the following "users" exist:
|
Given the following "users" exist:
|
||||||
| username | firstname | lastname | email |
|
| username | firstname | lastname | email | interests |
|
||||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
| teacher1 | Teacher | 1 | teacher1@example.com | Dogs, Cats |
|
||||||
| student1 | Student | 1 | student1@example.com |
|
| student1 | Student | 1 | student1@example.com | |
|
||||||
And the following "courses" exist:
|
And the following "courses" exist:
|
||||||
| fullname | shortname |
|
| fullname | shortname |
|
||||||
| Course 1 | c1 |
|
| Course 1 | c1 |
|
||||||
|
@ -19,13 +19,6 @@ Feature: Block tags displaying tag cloud
|
||||||
| user | course | role |
|
| user | course | role |
|
||||||
| teacher1 | c1 | editingteacher |
|
| teacher1 | c1 | editingteacher |
|
||||||
| student1 | c1 | student |
|
| student1 | c1 | student |
|
||||||
And I log in as "teacher1"
|
|
||||||
And I follow "Preferences" in the user menu
|
|
||||||
And I follow "Edit profile"
|
|
||||||
And I expand all fieldsets
|
|
||||||
And I set the field "Enter tags separated by commas" to "Dogs, Cats"
|
|
||||||
And I press "Update profile"
|
|
||||||
And I log out
|
|
||||||
|
|
||||||
Scenario: Add Tags block on a front page
|
Scenario: Add Tags block on a front page
|
||||||
When I log in as "admin"
|
When I log in as "admin"
|
||||||
|
|
|
@ -272,7 +272,17 @@ EOD;
|
||||||
context_user::instance($userid);
|
context_user::instance($userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
|
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
|
||||||
|
|
||||||
|
if (!$record['deleted'] && isset($record['interests'])) {
|
||||||
|
require_once($CFG->dirroot . '/user/editlib.php');
|
||||||
|
if (!is_array($record['interests'])) {
|
||||||
|
$record['interests'] = preg_split('/\s*,\s*/', trim($record['interests']), -1, PREG_SPLIT_NO_EMPTY);
|
||||||
|
}
|
||||||
|
useredit_update_interests($user, $record['interests']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -405,6 +415,10 @@ EOD;
|
||||||
$record['category'] = $DB->get_field_select('course_categories', "MIN(id)", "parent=0");
|
$record['category'] = $DB->get_field_select('course_categories', "MIN(id)", "parent=0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($record['tags']) && !is_array($record['tags'])) {
|
||||||
|
$record['tags'] = preg_split('/\s*,\s*/', trim($record['tags']), -1, PREG_SPLIT_NO_EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
$course = create_course((object)$record);
|
$course = create_course((object)$record);
|
||||||
context_course::instance($course->id);
|
context_course::instance($course->id);
|
||||||
if (!empty($options['createsections'])) {
|
if (!empty($options['createsections'])) {
|
||||||
|
|
|
@ -55,6 +55,7 @@ class core_test_generator_testcase extends advanced_testcase {
|
||||||
|
|
||||||
public function test_create_user() {
|
public function test_create_user() {
|
||||||
global $DB, $CFG;
|
global $DB, $CFG;
|
||||||
|
require_once($CFG->dirroot.'/user/lib.php');
|
||||||
|
|
||||||
$this->resetAfterTest(true);
|
$this->resetAfterTest(true);
|
||||||
$generator = $this->getDataGenerator();
|
$generator = $this->getDataGenerator();
|
||||||
|
@ -124,6 +125,11 @@ class core_test_generator_testcase extends advanced_testcase {
|
||||||
$this->assertSame('', $user->idnumber);
|
$this->assertSame('', $user->idnumber);
|
||||||
$this->assertSame(md5($record['username']), $user->email);
|
$this->assertSame(md5($record['username']), $user->email);
|
||||||
$this->assertFalse(context_user::instance($user->id, IGNORE_MISSING));
|
$this->assertFalse(context_user::instance($user->id, IGNORE_MISSING));
|
||||||
|
|
||||||
|
// Test generating user with interests.
|
||||||
|
$user = $generator->create_user(array('interests' => 'Cats, Dogs'));
|
||||||
|
$userdetails = user_get_user_details($user);
|
||||||
|
$this->assertSame('Cats, Dogs', $userdetails['interests']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_create() {
|
public function test_create() {
|
||||||
|
@ -167,6 +173,9 @@ class core_test_generator_testcase extends advanced_testcase {
|
||||||
$section = $generator->create_course_section(array('course'=>$course->id, 'section'=>3));
|
$section = $generator->create_course_section(array('course'=>$course->id, 'section'=>3));
|
||||||
$this->assertEquals($course->id, $section->course);
|
$this->assertEquals($course->id, $section->course);
|
||||||
|
|
||||||
|
$course = $generator->create_course(array('tags' => 'Cat, Dog'));
|
||||||
|
$this->assertEquals('Cat, Dog', tag_get_tags_csv('course', $course->id, TAG_RETURN_TEXT));
|
||||||
|
|
||||||
$scale = $generator->create_scale();
|
$scale = $generator->create_scale();
|
||||||
$this->assertNotEmpty($scale);
|
$this->assertNotEmpty($scale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,24 +6,15 @@ Feature: Manager is able to delete tags
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given the following "users" exist:
|
Given the following "users" exist:
|
||||||
| username | firstname | lastname | email |
|
| username | firstname | lastname | email | interests |
|
||||||
| manager1 | Manager | 1 | manager1@example.com |
|
| manager1 | Manager | 1 | manager1@example.com | |
|
||||||
| user1 | User | 1 | user1@example.com |
|
| user1 | User | 1 | user1@example.com | Cat,Dog,Turtle |
|
||||||
And the following "system role assigns" exist:
|
And the following "system role assigns" exist:
|
||||||
| user | course | role |
|
| user | course | role |
|
||||||
| manager1 | Acceptance test site | manager |
|
| manager1 | Acceptance test site | manager |
|
||||||
And the following "tags" exist:
|
And the following "tags" exist:
|
||||||
| name | tagtype |
|
| name | tagtype |
|
||||||
| Neverusedtag | official |
|
| Neverusedtag | official |
|
||||||
And I log in as "user1"
|
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
|
||||||
And I follow "Add a new entry"
|
|
||||||
And I set the following fields to these values:
|
|
||||||
| Entry title | Blog post header |
|
|
||||||
| Blog entry body | Blog post content |
|
|
||||||
| Other tags (enter tags separated by commas) | Cat,Dog,Turtle |
|
|
||||||
And I press "Save changes"
|
|
||||||
And I log out
|
|
||||||
|
|
||||||
Scenario: Deleting a tag with javascript disabled
|
Scenario: Deleting a tag with javascript disabled
|
||||||
When I log in as "manager1"
|
When I log in as "manager1"
|
||||||
|
@ -31,7 +22,8 @@ Feature: Manager is able to delete tags
|
||||||
And I click on "Delete" "link" in the "Dog" "table_row"
|
And I click on "Delete" "link" in the "Dog" "table_row"
|
||||||
And I should see "Tag(s) deleted"
|
And I should see "Tag(s) deleted"
|
||||||
Then I should not see "Dog"
|
Then I should not see "Dog"
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
And I navigate to "Participants" node in "Site pages"
|
||||||
|
And I follow "User 1"
|
||||||
And I should see "Cat"
|
And I should see "Cat"
|
||||||
And I should not see "Dog"
|
And I should not see "Dog"
|
||||||
And I log out
|
And I log out
|
||||||
|
@ -46,7 +38,8 @@ Feature: Manager is able to delete tags
|
||||||
Then I should see "Tag(s) deleted"
|
Then I should see "Tag(s) deleted"
|
||||||
And I should not see "Dog"
|
And I should not see "Dog"
|
||||||
And I should not see "Neverusedtag"
|
And I should not see "Neverusedtag"
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
And I navigate to "Participants" node in "Site pages"
|
||||||
|
And I follow "User 1"
|
||||||
And I should see "Cat"
|
And I should see "Cat"
|
||||||
And I should not see "Dog"
|
And I should not see "Dog"
|
||||||
And I log out
|
And I log out
|
||||||
|
@ -67,7 +60,8 @@ Feature: Manager is able to delete tags
|
||||||
And I should not see "Dog"
|
And I should not see "Dog"
|
||||||
And I follow "Manage tags"
|
And I follow "Manage tags"
|
||||||
And I should not see "Dog"
|
And I should not see "Dog"
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
And I navigate to "Participants" node in "Site pages"
|
||||||
|
And I follow "User 1"
|
||||||
And I should see "Cat"
|
And I should see "Cat"
|
||||||
And I should not see "Dog"
|
And I should not see "Dog"
|
||||||
And I log out
|
And I log out
|
||||||
|
@ -99,7 +93,8 @@ Feature: Manager is able to delete tags
|
||||||
And I follow "Manage tags"
|
And I follow "Manage tags"
|
||||||
And I should not see "Dog"
|
And I should not see "Dog"
|
||||||
And I should not see "Neverusedtag"
|
And I should not see "Neverusedtag"
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
And I navigate to "Participants" node in "Site pages"
|
||||||
|
And I follow "User 1"
|
||||||
And I should see "Cat"
|
And I should see "Cat"
|
||||||
And I should not see "Dog"
|
And I should not see "Dog"
|
||||||
And I log out
|
And I log out
|
||||||
|
|
|
@ -6,10 +6,10 @@ Feature: Users can edit tags to add description or rename
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given the following "users" exist:
|
Given the following "users" exist:
|
||||||
| username | firstname | lastname | email |
|
| username | firstname | lastname | email | interests |
|
||||||
| manager1 | Manager | 1 | manager1@example.com |
|
| manager1 | Manager | 1 | manager1@example.com | |
|
||||||
| user1 | User | 1 | user1@example.com |
|
| user1 | User | 1 | user1@example.com | Cat,Dog,Turtle |
|
||||||
| editor1 | Editor | 1 | editor1@example.com |
|
| editor1 | Editor | 1 | editor1@example.com | |
|
||||||
Given the following "roles" exist:
|
Given the following "roles" exist:
|
||||||
| name | shortname |
|
| name | shortname |
|
||||||
| Tag editor | tageditor |
|
| Tag editor | tageditor |
|
||||||
|
@ -20,24 +20,18 @@ Feature: Users can edit tags to add description or rename
|
||||||
And the following "tags" exist:
|
And the following "tags" exist:
|
||||||
| name | tagtype |
|
| name | tagtype |
|
||||||
| Neverusedtag | official |
|
| Neverusedtag | official |
|
||||||
And I log in as "user1"
|
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
|
||||||
And I follow "Add a new entry"
|
|
||||||
And I set the following fields to these values:
|
|
||||||
| Entry title | Blog post header |
|
|
||||||
| Blog entry body | Blog post content |
|
|
||||||
| Other tags (enter tags separated by commas) | Cat,Dog,Turtle |
|
|
||||||
And I press "Save changes"
|
|
||||||
And I log out
|
|
||||||
|
|
||||||
Scenario: User with tag editing capability can change tag description
|
Scenario: User with tag editing capability can change tag description
|
||||||
Given I log in as "admin"
|
Given I log in as "admin"
|
||||||
And I set the following system permissions of "Tag editor" role:
|
And I set the following system permissions of "Tag editor" role:
|
||||||
| capability | permission |
|
| capability | permission |
|
||||||
| moodle/tag:edit | Allow |
|
| moodle/tag:edit | Allow |
|
||||||
|
| moodle/site:viewparticipants | Allow |
|
||||||
|
| moodle/user:viewdetails | Allow |
|
||||||
And I log out
|
And I log out
|
||||||
When I log in as "editor1"
|
When I log in as "editor1"
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
And I navigate to "Participants" node in "Site pages"
|
||||||
|
And I follow "User 1"
|
||||||
And I follow "Cat"
|
And I follow "Cat"
|
||||||
And I follow "Edit this tag"
|
And I follow "Edit this tag"
|
||||||
And I should not see "Tag name"
|
And I should not see "Tag name"
|
||||||
|
@ -53,7 +47,8 @@ Feature: Users can edit tags to add description or rename
|
||||||
|
|
||||||
Scenario: Manager can change tag description, related tags and rename the tag from tag view page
|
Scenario: Manager can change tag description, related tags and rename the tag from tag view page
|
||||||
When I log in as "manager1"
|
When I log in as "manager1"
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
And I navigate to "Participants" node in "Site pages"
|
||||||
|
And I follow "User 1"
|
||||||
And I follow "Cat"
|
And I follow "Cat"
|
||||||
And I follow "Edit this tag"
|
And I follow "Edit this tag"
|
||||||
And I set the following fields to these values:
|
And I set the following fields to these values:
|
||||||
|
@ -77,7 +72,8 @@ Feature: Users can edit tags to add description or rename
|
||||||
|
|
||||||
Scenario: Renaming the tag from tag view page
|
Scenario: Renaming the tag from tag view page
|
||||||
When I log in as "manager1"
|
When I log in as "manager1"
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
And I navigate to "Participants" node in "Site pages"
|
||||||
|
And I follow "User 1"
|
||||||
And I follow "Cat"
|
And I follow "Cat"
|
||||||
And I follow "Edit this tag"
|
And I follow "Edit this tag"
|
||||||
And I set the following fields to these values:
|
And I set the following fields to these values:
|
||||||
|
|
|
@ -6,40 +6,40 @@ Feature: Users can flag tags and manager can reset flags
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given the following "users" exist:
|
Given the following "users" exist:
|
||||||
| username | firstname | lastname | email |
|
| username | firstname | lastname | email | interests |
|
||||||
| manager1 | Manager | 1 | manager1@example.com |
|
| manager1 | Manager | 1 | manager1@example.com | |
|
||||||
| user1 | User | 1 | user1@example.com |
|
| user1 | User | 1 | user1@example.com | Nicetag, Badtag, Sweartag |
|
||||||
| user2 | User | 2 | user2@example.com |
|
| user2 | User | 2 | user2@example.com | |
|
||||||
| user3 | User | 3 | user3@example.com |
|
| user3 | User | 3 | user3@example.com | |
|
||||||
And the following "system role assigns" exist:
|
And the following "system role assigns" exist:
|
||||||
| user | course | role |
|
| user | course | role |
|
||||||
| manager1 | Acceptance test site | manager |
|
| manager1 | Acceptance test site | manager |
|
||||||
And the following "tags" exist:
|
And the following "tags" exist:
|
||||||
| name | tagtype |
|
| name | tagtype |
|
||||||
| Neverusedtag | official |
|
| Neverusedtag | official |
|
||||||
And I log in as "user1"
|
And I log in as "admin"
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
And I set the following system permissions of "Authenticated user" role:
|
||||||
And I follow "Add a new entry"
|
| capability | permission |
|
||||||
And I set the following fields to these values:
|
| moodle/site:viewparticipants | Allow |
|
||||||
| Entry title | Blog post from teacher |
|
| moodle/user:viewdetails | Allow |
|
||||||
| Blog entry body | Teacher blog post content |
|
|
||||||
| Other tags (enter tags separated by commas) | Nicetag, Badtag, Sweartag |
|
|
||||||
And I press "Save changes"
|
|
||||||
And I log out
|
And I log out
|
||||||
And I log in as "user2"
|
And I log in as "user2"
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
And I navigate to "Participants" node in "Site pages"
|
||||||
|
And I follow "User 1"
|
||||||
And I follow "Badtag"
|
And I follow "Badtag"
|
||||||
And I follow "Flag as inappropriate"
|
And I follow "Flag as inappropriate"
|
||||||
And I should see "The person responsible will be notified"
|
And I should see "The person responsible will be notified"
|
||||||
And I follow "Continue"
|
And I follow "Continue"
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
And I navigate to "Participants" node in "Site pages"
|
||||||
|
And I follow "User 1"
|
||||||
And I follow "Sweartag"
|
And I follow "Sweartag"
|
||||||
And I follow "Flag as inappropriate"
|
And I follow "Flag as inappropriate"
|
||||||
And I should see "The person responsible will be notified"
|
And I should see "The person responsible will be notified"
|
||||||
And I follow "Continue"
|
And I follow "Continue"
|
||||||
And I log out
|
And I log out
|
||||||
And I log in as "user3"
|
And I log in as "user3"
|
||||||
And I navigate to "Site blogs" node in "Site pages"
|
And I navigate to "Participants" node in "Site pages"
|
||||||
|
And I follow "User 1"
|
||||||
And I follow "Sweartag"
|
And I follow "Sweartag"
|
||||||
And I follow "Flag as inappropriate"
|
And I follow "Flag as inappropriate"
|
||||||
And I should see "The person responsible will be notified"
|
And I should see "The person responsible will be notified"
|
||||||
|
|
|
@ -264,6 +264,8 @@ function useredit_update_trackforums($user, $usernew) {
|
||||||
* @param array $interests
|
* @param array $interests
|
||||||
*/
|
*/
|
||||||
function useredit_update_interests($user, $interests) {
|
function useredit_update_interests($user, $interests) {
|
||||||
|
global $CFG;
|
||||||
|
require_once($CFG->dirroot . '/tag/lib.php');
|
||||||
tag_set('user', $user->id, $interests, 'core', context_user::instance($user->id)->id);
|
tag_set('user', $user->id, $interests, 'core', context_user::instance($user->id)->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue