Permalink
Browse files

Merge remote-tracking branch 'moodle.org/master' into MDL-35073-openb…

…adges
  • Loading branch information...
2 parents 8270425 + 692d247 commit 73f2abd2341d5bce419024c8428d93622565e47e @ybozhko ybozhko committed Feb 13, 2014
Showing with 2,520 additions and 754 deletions.
  1. +8 −3 auth/ldap/auth.php
  2. +34 −1 auth/tests/behat/behat_auth.php
  3. +7 −1 auth/tests/behat/login.feature
  4. +1 −1 backup/import.php
  5. +1 −1 backup/util/ui/renderer.php
  6. +7 −3 badges/mybadges.php
  7. +0 −5 badges/view.php
  8. +5 −2 calendar/renderer.php
  9. +6 −2 course/lib.php
  10. +1 −1 course/rest.php
  11. +54 −0 course/tests/behat/activities_visibility_icons.feature
  12. +18 −32 course/tests/behat/behat_course.php
  13. +2 −0 course/tests/behat/course_controls.feature
  14. +4 −0 course/tests/behat/section_visibility.feature
  15. +10 −1 course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-debug.js
  16. +2 −2 course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-min.js
  17. +10 −1 course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop.js
  18. +30 −19 course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes-debug.js
  19. +2 −2 course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes-min.js
  20. +30 −19 course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes.js
  21. +10 −1 course/yui/src/dragdrop/js/resource.js
  22. +30 −19 course/yui/src/toolboxes/js/resource.js
  23. +1 −0 enrol/manual/externallib.php
  24. +64 −20 enrol/manual/tests/externallib_test.php
  25. +2 −0 install/lang/dz/error.php
  26. +1 −1 install/lang/nl/error.php
  27. +1 −0 lang/en/badges.php
  28. +5 −0 lang/en/moodle.php
  29. +2 −1 lib/db/services.php
  30. +1 −24 lib/db/upgrade.php
  31. +14 −0 lib/form/yui/build/moodle-form-shortforms/moodle-form-shortforms-debug.js
  32. +1 −1 lib/form/yui/build/moodle-form-shortforms/moodle-form-shortforms-min.js
  33. +14 −0 lib/form/yui/build/moodle-form-shortforms/moodle-form-shortforms.js
  34. +14 −0 lib/form/yui/src/shortforms/js/shortforms.js
  35. +1 −3 lib/formslib.php
  36. +1 −1 lib/grade/grade_item.php
  37. +3 −0 lib/outputcomponents.php
  38. +21 −4 lib/tablelib.php
  39. +14 −0 lib/tests/tablelib_test.php
  40. +51 −0 lib/tests/upgradelib_test.php
  41. +32 −1 lib/upgradelib.php
  42. +41 −11 lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-debug.js
  43. +2 −2 lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-min.js
  44. +41 −11 lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop.js
  45. +0 −1 lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js
  46. +1 −1 lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-min.js
  47. +0 −1 lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js
  48. +41 −11 lib/yui/src/dragdrop/js/dragdrop.js
  49. +0 −1 lib/yui/src/notification/js/confirm.js
  50. +87 −0 mod/assign/classes/event/submission_created.php
  51. +27 −42 mod/assign/classes/event/submission_updated.php
  52. +2 −1 mod/assign/lang/en/assign.php
  53. +0 −8 mod/assign/locallib.php
  54. +93 −0 mod/assign/submission/file/classes/event/submission_created.php
  55. +93 −0 mod/assign/submission/file/classes/event/submission_updated.php
  56. +35 −2 mod/assign/submission/file/locallib.php
  57. +119 −32 mod/assign/submission/file/tests/events_test.php
  58. +93 −0 mod/assign/submission/onlinetext/classes/event/submission_created.php
  59. +93 −0 mod/assign/submission/onlinetext/classes/event/submission_updated.php
  60. +35 −3 mod/assign/submission/onlinetext/locallib.php
  61. +99 −22 mod/assign/submission/onlinetext/tests/events_test.php
  62. +171 −0 mod/assign/tests/event_test.php
  63. +48 −0 mod/assign/tests/fixtures/event_mod_assign_fixtures.php
  64. +3 −2 mod/assign/upgrade.txt
  65. +0 −4 mod/feedback/complete.php
  66. +0 −4 mod/feedback/complete_guest.php
  67. +23 −7 mod/feedback/item/multichoice/lib.php
  68. +4 −5 mod/feedback/item/multichoicerated/lib.php
  69. +12 −6 mod/feedback/styles.css
  70. +3 −1 mod/quiz/locallib.php
  71. +55 −121 mod/quiz/report/statistics/report.php
  72. +7 −2 mod/quiz/report/statistics/statistics_table.php
  73. +19 −6 mod/quiz/report/statistics/tests/statistics_test.php
  74. +10 −14 mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php
  75. +2 −2 mod/quiz/styles.css
  76. +1 −1 question/behaviour/behaviourbase.php
  77. +1 −1 question/behaviour/rendererbase.php
  78. +445 −0 question/classes/statistics/questions/all_calculated_for_qubaid_condition.php
  79. +49 −2 question/classes/statistics/questions/calculated.php
  80. +13 −0 question/classes/statistics/questions/calculated_for_subquestion.php
  81. +103 −198 question/classes/statistics/questions/calculator.php
  82. +21 −0 question/engine/questionattempt.php
  83. +3 −3 question/engine/upgrade/upgradelib.php
  84. +1 −0 question/type/essay/db/upgradelib.php
  85. +6 −6 question/type/essay/tests/upgradelibnewqe_test.php
  86. +7 −1 theme/afterburner/style/afterburner_dock.css
  87. +4 −4 theme/anomaly/style/general.css
  88. +4 −4 theme/base/style/core.css
  89. +6 −0 theme/base/style/dock.css
  90. +16 −0 theme/bootstrapbase/less/moodle/blocks.less
  91. +8 −1 theme/bootstrapbase/less/moodle/dock.less
  92. +2 −2 theme/bootstrapbase/less/moodle/modules.less
  93. +8 −1 theme/bootstrapbase/less/moodle/undo.less
  94. +1 −1 theme/bootstrapbase/style/moodle.css
  95. +3 −3 theme/boxxie/style/core.css
  96. +2 −2 theme/canvas/style/core.css
  97. +8 −8 theme/formal_white/style/formal_white.css
  98. +1 −1 theme/formfactor/style/mods.css
  99. +1 −1 theme/magazine/style/core.css
  100. +6 −6 theme/standard/style/admin.css
  101. +5 −5 theme/standard/style/core.css
  102. +2 −2 theme/standard/style/grade.css
  103. +2 −2 theme/standard/style/modules.css
  104. +2 −2 theme/standard/style/question.css
  105. +13 −0 theme/upgrade.txt
  106. +2 −2 version.php
View
@@ -1182,6 +1182,7 @@ function user_update($olduser, $newuser) {
return false;
}
+ $success = true;
$user_info_result = ldap_read($ldapconnection, $user_dn, '(objectClass=*)', $search_attribs);
if ($user_info_result) {
$user_entry = ldap_get_entries_moodle($ldapconnection, $user_info_result);
@@ -1236,8 +1237,10 @@ function user_update($olduser, $newuser) {
if ($nuvalue !== $ldapvalue) {
// This might fail due to schema validation
if (@ldap_modify($ldapconnection, $user_dn, array($ldapkey => $nuvalue))) {
+ $changed = true;
continue;
} else {
+ $success = false;
error_log($this->errorlogtag.get_string ('updateremfail', 'auth_ldap',
array('errno'=>ldap_errno($ldapconnection),
'errstring'=>ldap_err2str(ldap_errno($ldapconnection)),
@@ -1256,6 +1259,7 @@ function user_update($olduser, $newuser) {
$changed = true;
continue;
} else {
+ $success = false;
error_log($this->errorlogtag.get_string ('updateremfail', 'auth_ldap',
array('errno'=>ldap_errno($ldapconnection),
'errstring'=>ldap_err2str(ldap_errno($ldapconnection)),
@@ -1273,6 +1277,7 @@ function user_update($olduser, $newuser) {
$changed = true;
continue;
} else {
+ $success = false;
error_log($this->errorlogtag.get_string ('updateremfail', 'auth_ldap',
array('errno'=>ldap_errno($ldapconnection),
'errstring'=>ldap_err2str(ldap_errno($ldapconnection)),
@@ -1286,6 +1291,7 @@ function user_update($olduser, $newuser) {
}
if ($ambiguous and !$changed) {
+ $success = false;
error_log($this->errorlogtag.get_string ('updateremfailamb', 'auth_ldap',
array('key'=>$key,
'ouvalue'=>$ouvalue,
@@ -1295,12 +1301,11 @@ function user_update($olduser, $newuser) {
}
} else {
error_log($this->errorlogtag.get_string ('usernotfound', 'auth_ldap'));
- $this->ldap_close();
- return false;
+ $success = false;
}
$this->ldap_close();
- return true;
+ return $success;
}
@@ -48,12 +48,45 @@ class behat_auth extends behat_base {
*/
public function i_log_in_as($username) {
- return array(new Given('I am on homepage'),
+ // Running this step using the API rather than a chained step because
+ // we need to see if the 'Log in' link is available or we need to click
+ // the dropdown to expand the navigation bar before.
+ $this->getSession()->visit($this->locate_path('/'));
+
+ // Generic steps (we will prefix them later expanding the navigation dropdown if necessary).
+ $steps = array(
new Given('I follow "' . get_string('login') . '"'),
new Given('I fill in "' . get_string('username') . '" with "' . $this->escape($username) . '"'),
new Given('I fill in "' . get_string('password') . '" with "'. $this->escape($username) . '"'),
new Given('I press "' . get_string('login') . '"')
);
+
+ // If Javascript is disabled we have enough with these steps.
+ if (!$this->running_javascript()) {
+ return $steps;
+ }
+
+ // Wait for the homepage to be ready.
+ $this->getSession()->wait(self::TIMEOUT * 1000, self::PAGE_READY_JS);
+
+ // Checking if we need to click the navbar button to show the navigation menu, it
+ // is hidden by default when using clean theme and a medium or small size screen size.
+
+ // The DOM and the JS should be all ready and loaded. Running without spinning
+ // as this is a widely used step and we can not spend time here trying to see
+ // a DOM node that is not always there (at the moment clean is not even the
+ // default theme...).
+ $navbuttonjs = "return (
+ Y.one('.btn-navbar') &&
+ Y.one('.btn-navbar').getComputedStyle('display') !== 'none'
+ )";
+
+ // Adding an extra click we need to show the 'Log in' link.
+ if ($this->getSession()->getDriver()->evaluateScript($navbuttonjs)) {
+ array_unshift($steps, new Given('I click on ".btn-navbar" "css_element"'));
+ }
+
+ return $steps;
}
/**
@@ -4,8 +4,14 @@ Feature: Authentication
As a user
I need to log into the system
- Scenario: Log in with the predefined admin user
+ Scenario: Log in with the predefined admin user with Javascript disabled
Given I log in as "admin"
+ Then I should see "You are logged in as Admin User"
+
+ @javascript
+ Scenario: Log in with the predefined admin user with Javascript enabled
+ Given I log in as "admin"
+ Then I should see "You are logged in as Admin User"
Scenario: Log in as an existing admin user filling the form
Given the following "users" exists:
View
@@ -176,7 +176,7 @@
// Display a notification and a continue button
if ($warnings) {
echo $OUTPUT->box_start();
- echo $OUTPUT->notification(get_string('warning'), 'notifywarning');
+ echo $OUTPUT->notification(get_string('warning'), 'notifyproblem');
echo html_writer::start_tag('ul', array('class'=>'list'));
foreach ($warnings as $warning) {
echo html_writer::tag('li', $warning);
@@ -410,7 +410,7 @@ public function precheck_notices($results) {
}
if (array_key_exists('warnings', $results)) {
foreach ($results['warnings'] as $warning) {
- $output .= $this->output->notification($warning, 'notifywarning notifyproblem');
+ $output .= $this->output->notification($warning, 'notifyproblem');
}
}
return $output.html_writer::end_tag('div');
View
@@ -42,7 +42,14 @@
print_error('badgesdisabled', 'badges');
}
+$url = new moodle_url('/badges/mybadges.php');
+$PAGE->set_url($url);
+
if (isguestuser()) {
+ $PAGE->set_context(context_system::instance());
+ echo $OUTPUT->header();
+ echo $OUTPUT->box(get_string('error:guestuseraccess', 'badges'), 'notifyproblem');
+ echo $OUTPUT->footer();
die();
}
@@ -80,9 +87,6 @@
$context = context_user::instance($USER->id);
require_capability('moodle/badges:manageownbadges', $context);
-$url = new moodle_url('/badges/mybadges.php');
-
-$PAGE->set_url($url);
$PAGE->set_context($context);
$title = get_string('mybadges', 'badges');
View
@@ -73,11 +73,6 @@
$PAGE->set_context(context_course::instance($course->id));
$PAGE->set_pagelayout('course');
$PAGE->set_heading($title);
-
- // Fix course navigation.
- $PAGE->navbar->ignore_active();
- $PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id' => $course->id)));
- $PAGE->navbar->add(get_string('coursebadges', 'badges'));
}
$PAGE->set_title($title);
@@ -642,7 +642,8 @@ public function show_upcoming_events(calendar_information $calendar, $futuredays
/**
* Displays a course filter selector
*
- * @param array $getvars
+ * @param moodle_url $returnurl The URL that the user should be taken too upon selecting a course.
+ * @param string $label The label to use for the course select.
* @return string
*/
protected function course_filter_selector(moodle_url $returnurl, $label=null) {
@@ -672,7 +673,9 @@ protected function course_filter_selector(moodle_url $returnurl, $label=null) {
} else {
$selected = '';
}
- $select = new single_select(new moodle_url(CALENDAR_URL.'set.php', array('return' => base64_encode($returnurl->out(false)), 'var' => 'setcourse', 'sesskey'=>sesskey())), 'id', $courseoptions, $selected, null);
+ $courseurl = new moodle_url($returnurl);
+ $courseurl->remove_params('course');
+ $select = new single_select($courseurl, 'course', $courseoptions, $selected, null);
$select->class = 'cal_courses_flt';
if ($label !== null) {
$select->set_label($label);
View
@@ -3238,11 +3238,15 @@ function include_course_ajax($course, $usedmodules = array(), $enabledmodules =
'clicktochangeinbrackets',
'markthistopic',
'markedthistopic',
- 'move',
'movesection',
+ 'movecoursemodule',
+ 'movecoursesection',
'movecontent',
'tocontent',
- 'emptydragdropregion'
+ 'emptydragdropregion',
+ 'afterresource',
+ 'aftersection',
+ 'totopofsection',
), 'moodle');
// Include section-specific strings for formats which support sections.
View
@@ -146,7 +146,7 @@
}
$isvisible = moveto_module($cm, $section, $beforemod);
- echo json_encode(array('visible' => $isvisible));
+ echo json_encode(array('visible' => (bool) $isvisible));
break;
case 'gettitle':
require_capability('moodle/course:manageactivities', $modcontext);
@@ -39,3 +39,57 @@ Feature: Toggle activities visibility from the course page
And I log in as "student1"
And I follow "Course 1"
And "Test forum name" activity should be hidden
+
+ @javascript
+ Scenario: Activities can be shown and hidden inside a hidden section
+ Given the following "users" exists:
+ | username | firstname | lastname | email |
+ | teacher1 | Teacher | 1 | teacher1@asd.com |
+ And the following "courses" exists:
+ | fullname | shortname | format | numsections |
+ | Course 1 | C1 | topics | 2 |
+ And the following "course enrolments" exists:
+ | user | course | role |
+ | teacher1 | C1 | editingteacher |
+ And I log in as "teacher1"
+ And I follow "Course 1"
+ And I turn editing mode on
+ And I add a "Forum" to section "2" and I fill the form with:
+ | Forum name | Test forum name |
+ | Description | Test forum description |
+ | Visible | Show |
+ When I hide section "2"
+ Then "Test forum name" activity should be hidden
+ And I open "Test forum name" actions menu
+ And I click on "Show" "link" in the "Test forum name" activity
+ And "Test forum name" activity should be visible
+ And I open "Test forum name" actions menu
+ And I click on "Hide" "link" in the "Test forum name" activity
+ And "Test forum name" activity should be hidden
+
+ @javascript
+ Scenario: Activities can be shown and hidden inside an orphaned section
+ Given the following "users" exists:
+ | username | firstname | lastname | email |
+ | teacher1 | Teacher | 1 | teacher1@asd.com |
+ And the following "courses" exists:
+ | fullname | shortname | format | numsections |
+ | Course 1 | C1 | topics | 2 |
+ And the following "course enrolments" exists:
+ | user | course | role |
+ | teacher1 | C1 | editingteacher |
+ And I log in as "teacher1"
+ And I follow "Course 1"
+ And I turn editing mode on
+ And I add a "Forum" to section "2" and I fill the form with:
+ | Forum name | Test forum name |
+ | Description | Test forum description |
+ | Visible | Show |
+ When I click on ".reduce-sections" "css_element"
+ Then "Test forum name" activity should be visible
+ And I open "Test forum name" actions menu
+ And I click on "Hide" "link" in the "Test forum name" activity
+ And "Test forum name" activity should be hidden
+ And I open "Test forum name" actions menu
+ And I click on "Show" "link" in the "Test forum name" activity
+ And "Test forum name" activity should be visible
@@ -351,6 +351,23 @@ public function section_should_be_hidden($sectionnumber) {
// Section should be hidden.
$exception = new ExpectationException('The section is not hidden', $this->getSession());
$this->find('xpath', $sectionxpath . "[contains(concat(' ', normalize-space(@class), ' '), ' hidden ')]", $exception);
+ }
+
+ /**
+ * Checks that all actiities in the specified section are hidden. You need to be in the course page. It can be used being logged as a student and as a teacher on editing mode.
+ *
+ * @Then /^all activities in section "(?P<section_number>\d+)" should be hidden$/
+ * @throws ExpectationException
+ * @throws ElementNotFoundException Thrown by behat_base::find
+ * @param int $sectionnumber
+ */
+ public function section_activities_should_be_hidden($sectionnumber) {
+ $sectionxpath = $this->section_exists($sectionnumber);
+
+ // Preventive in case there is any action in progress.
+ // Adding it here because we are interacting (click) with
+ // the elements, not necessary when we just find().
+ $this->i_wait_until_section_is_available($sectionnumber);
// The checking are different depending on user permissions.
if ($this->is_course_editor()) {
@@ -362,50 +379,19 @@ public function section_should_be_hidden($sectionnumber) {
if ($activities = $this->get_section_activities($sectionxpath)) {
$dimmedexception = new ExpectationException('There are activities that are not dimmed', $this->getSession());
- $visibilityexception = new ExpectationException('There are activities which visibility icons are clickable', $this->getSession());
foreach ($activities as $activity) {
-
// Dimmed.
$this->find('xpath', "//div[contains(concat(' ', normalize-space(@class), ' '), ' activityinstance ')]" .
"/a[contains(concat(' ', normalize-space(@class), ' '), ' dimmed ')]", $dimmedexception, $activity);
-
- // Non-JS browsers can not click on img elements.
- if ($this->running_javascript()) {
-
- // Expanding the actions menu if it is not shown.
- $classes = array_flip(explode(' ', $activity->getAttribute('class')));
- if (empty($classes['action-menu-shown'])) {
- $actionsmenu = $this->find('css', "a[role='menuitem']", false, $activity);
- $actionsmenu->click();
- }
-
- // To check that the visibility is not clickable we check the funcionality rather than the applied style.
- $visibilityiconnode = $this->find('css', 'a.editing_show img', false, $activity);
- $visibilityiconnode->click();
- }
-
- // We ensure that we still see the show icon.
- $visibilityiconnode = $this->find('css', 'a.editing_show img', $visibilityexception, $activity);
-
- // It is there only when running JS scenarios.
- if ($this->running_javascript()) {
-
- // Collapse the actions menu if it is displayed.
- $classes = array_flip(explode(' ', $activity->getAttribute('class')));
- if (!empty($classes['action-menu-shown'])) {
- $actionsmenu = $this->find('css', "a[role='menuitem']", false, $activity);
- $actionsmenu->click();
- }
- }
}
}
-
} else {
// There shouldn't be activities.
if ($this->get_section_activities($sectionxpath)) {
throw new ExpectationException('There are activities in the section and they should be hidden', $this->getSession());
}
}
+
}
/**
@@ -77,6 +77,7 @@ Feature: Course activity controls works as expected
And I hide section "1"
And "#section-2" "css_element" <should_see_other_sections> exists
And section "1" should be hidden
+ And all activities in section "1" should be hidden
And I show section "1"
And "#section-2" "css_element" <should_see_other_sections> exists
And section "1" should be visible
@@ -151,6 +152,7 @@ Feature: Course activity controls works as expected
And I hide section "1"
And "#section-2" "css_element" <should_see_other_sections> exists
And section "1" should be hidden
+ And all activities in section "1" should be hidden
And I show section "1"
And "#section-2" "css_element" <should_see_other_sections> exists
And section "1" should be visible
@@ -59,11 +59,15 @@ Feature: Show/hide course sections
And section "3" should be hidden
And I reload the page
And section "1" should be hidden
+ And all activities in section "1" should be hidden
And section "2" should be visible
And section "3" should be hidden
+ And all activities in section "1" should be hidden
And I log out
And I log in as "student1"
And I follow "Course 1"
And section "1" should be hidden
+ And all activities in section "1" should be hidden
And section "2" should be visible
And section "3" should be hidden
+ And all activities in section "1" should be hidden
Oops, something went wrong.

0 comments on commit 73f2abd

Please sign in to comment.