--prefix=STRING Table prefix for above database tables. Default is mdl_
--fullname=STRING The fullname of the site
--shortname=STRING The shortname of the site
+--summary=STRING The summary to be displayed on the front page
--adminuser=USERNAME Username for the moodle admin account. Default is admin
--adminpass=PASSWORD Password for the moodle admin account,
required in non-interactive mode.
chdir(dirname($_SERVER['argv'][0]));
// Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
-// This is a quick hack. Ideally we should ask the admin for a value. See MDL-22625 for more on this.
-if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
- @date_default_timezone_set(@date_default_timezone_get());
+if (!function_exists('date_default_timezone_set') or !function_exists('date_default_timezone_get')) {
+ fwrite(STDERR, "Timezone functions are not available.\n");
+ exit(1);
}
+date_default_timezone_set(@date_default_timezone_get());
// make sure PHP errors are displayed - helps with diagnosing of problems
@error_reporting(E_ALL);
'prefix' => 'mdl_',
'fullname' => '',
'shortname' => '',
+ 'summary' => '',
'adminuser' => 'admin',
'adminpass' => '',
'adminemail' => '',
$problem = false;
foreach ($DB->get_tables(false) as $table) {
$columns = $DB->get_columns($table, false);
- $size = $generator->guess_antolope_row_size($columns);
+ $size = $generator->guess_antelope_row_size($columns);
$format = $DB->get_row_format($table);
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
continue;
$fixtables = array();
foreach ($DB->get_tables(false) as $table) {
$columns = $DB->get_columns($table, false);
- $size = $generator->guess_antolope_row_size($columns);
+ $size = $generator->guess_antelope_row_size($columns);
$format = $DB->get_row_format($table);
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
continue;
foreach ($DB->get_tables(false) as $table) {
$columns = $DB->get_columns($table, false);
- $size = $generator->guess_antolope_row_size($columns);
+ $size = $generator->guess_antelope_row_size($columns);
$format = $DB->get_row_format($table);
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
continue;
<ON_CHECK message="slashargumentswarning" />
</FEEDBACK>
</CUSTOM_CHECK>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="unsupporteddbtablerowformat" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
</COMPATIBILITY_MATRIX>
// probably new installation - lets return to frontpage after this step
// remove settings that we want uninitialised
unset_config('registerauth');
+ unset_config('timezone'); // Force admin to select timezone!
redirect('upgradesettings.php?return=site');
}
foreach ($updates['core'] as $update) {
$updateinfo .= $this->moodle_available_update_info($update);
}
+ $updateinfo .= html_writer::tag('p', get_string('updateavailablerecommendation', 'core_admin'),
+ array('class' => 'updateavailablerecommendation'));
}
unset($updates['core']);
// If something has left in the $updates array now, it is updates for plugins.
}
}
+if (!empty($user) && ($user->id != $USER->id)) {
+ $PAGE->navigation->extend_for_user($user);
+ $PAGE->navbar->includesettingsbase = true;
+}
+
$PAGE->set_pagelayout('admin');
$PAGE->set_title($title);
$PAGE->set_url($url);
if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
+ $PAGE->navbar->includesettingsbase = true;
$PAGE->navigation->extend_for_user($user);
$PAGE->set_context(context_course::instance($course->id));
} else {
$PAGE->set_url($url);
if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
+ $PAGE->navbar->includesettingsbase = true;
$PAGE->navigation->extend_for_user($user);
- $PAGE->set_context(context_course::instance($course->id));
+ $PAGE->set_context(context_user::instance($user->id));
} else {
$PAGE->set_context($context);
}
'customusermenuitems',
new lang_string('customusermenuitems', 'admin'),
new lang_string('configcustomusermenuitems', 'admin'),
- 'messages,message|/message/index.php|message
-myfiles,moodle|/user/files.php|download
-mybadges,badges|/badges/mybadges.php|award',
+ 'mygrades,grades|/grade/report/mygrades.php|grades
+messages,message|/message/index.php|message
+mypreferences,moodle|/user/preferences.php|preferences',
PARAM_TEXT,
'50',
'10'
HOMEPAGE_MY => new lang_string('mymoodle', 'admin'),
HOMEPAGE_USER => new lang_string('userpreference', 'admin')
);
- $temp->add(new admin_setting_configselect('defaulthomepage', new lang_string('defaulthomepage', 'admin'), new lang_string('configdefaulthomepage', 'admin'), HOMEPAGE_SITE, $choices));
+ $temp->add(new admin_setting_configselect('defaulthomepage', new lang_string('defaulthomepage', 'admin'),
+ new lang_string('configdefaulthomepage', 'admin'), HOMEPAGE_MY, $choices));
$temp->add(new admin_setting_configcheckbox('allowguestmymoodle', new lang_string('allowguestmymoodle', 'admin'), new lang_string('configallowguestmymoodle', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('navshowfullcoursenames', new lang_string('navshowfullcoursenames', 'admin'), new lang_string('navshowfullcoursenames_help', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('navshowcategories', new lang_string('navshowcategories', 'admin'), new lang_string('confignavshowcategories', 'admin'), 1));
$temp->add(new admin_setting_special_gradepointmax());
$temp->add(new admin_setting_special_gradepointdefault());
+
+ $temp->add(new admin_setting_my_grades_report());
+
+ $temp->add(new admin_setting_configtext('gradereport_mygradeurl', new lang_string('externalurl', 'grades'),
+ new lang_string('externalurl_desc', 'grades'), ''));
}
$ADMIN->add('grades', $temp);
// "locations" settingpage
$temp = new admin_settingpage('locationsettings', new lang_string('locationsettings', 'admin'));
- $options = get_list_of_timezones();
- $options[99] = new lang_string('serverlocaltime');
- $temp->add(new admin_setting_configselect('timezone', new lang_string('timezone','admin'), new lang_string('configtimezone', 'admin'), 99, $options));
- $options[99] = new lang_string('timezonenotforced', 'admin');
- $temp->add(new admin_setting_configselect('forcetimezone', new lang_string('forcetimezone', 'admin'), new lang_string('helpforcetimezone', 'admin'), 99, $options));
+ $temp->add(new admin_setting_servertimezone());
+ $temp->add(new admin_setting_forcetimezone());
$temp->add(new admin_settings_country_select('country', new lang_string('country', 'admin'), new lang_string('configcountry', 'admin'), 0));
$temp->add(new admin_setting_configtext('defaultcity', new lang_string('defaultcity', 'admin'), new lang_string('defaultcity_help', 'admin'), ''));
// activity modules
$ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
+
+ $temp = new admin_settingpage('managemodulescommon', new lang_string('commonsettings', 'admin'));
+
+ $temp->add(new admin_setting_configcheckbox('requiremodintro',
+ get_string('requiremodintro', 'admin'), get_string('requiremodintro_desc', 'admin'), 0));
+ $ADMIN->add('modsettings', $temp);
+
$ADMIN->add('modsettings', new admin_page_managemods());
foreach (core_plugin_manager::instance()->get_plugins_of_type('mod') as $plugin) {
/** @var \core\plugininfo\mod $plugin */
array('description' => new lang_string('description'),
'city' => new lang_string('city'),
'country' => new lang_string('country'),
+ 'timezone' => new lang_string('timezone'),
'webpage' => new lang_string('webpage'),
'icqnumber' => new lang_string('icqnumber'),
'skypeid' => new lang_string('skypeid'),
| fullname | shortname | category |
| Course fullname | C_shortname | 0 |
And I log in as "admin"
+ And I am on site homepage
Scenario: Courses list without extended course names (default value)
Then I should see "Course fullname"
And I click on "Courses" "link" in the "//div[@id='settingsnav']/descendant::li[contains(concat(' ', normalize-space(@class), ' '), ' type_setting ')][contains(., 'Appearance')]" "xpath_element"
And I set the field "Display extended course names" to "1"
When I press "Save changes"
- And I am on homepage
+ And I am on site homepage
Then I should see "C_shortname Course fullname"
Background:
Given the following "users" exist:
| username | firstname | lastname | email | auth | confirmed |
- | user1 | User | One | one@asd.com | manual | 0 |
- | user2 | User | Two | two@asd.com | ldap | 1 |
- | user3 | User | Three | three@asd.com | manual | 1 |
- | user4 | User | Four | four@asd.com | ldap | 0 |
+ | user1 | User | One | one@example.com | manual | 0 |
+ | user2 | User | Two | two@example.com | ldap | 1 |
+ | user3 | User | Three | three@example.com | manual | 1 |
+ | user4 | User | Four | four@example.com | ldap | 0 |
And the following "cohorts" exist:
| name | idnumber |
| Cohort 1 | CH1 |
| user2 | C1 | student |
| user3 | C1 | student |
And I log in as "admin"
- And I add "User Two (two@asd.com)" user to "CH1" cohort members
- And I add "User Three (three@asd.com)" user to "CH1" cohort members
+ And I add "User Two (two@example.com)" user to "CH1" cohort members
+ And I add "User Three (three@example.com)" user to "CH1" cohort members
And I follow "Browse list of users"
@javascript
| fullname | shortname | category |
| Course fullname | C_shortname | 0 |
And I log in as "admin"
+ And I am on site homepage
And I should see "Course fullname"
And I should not see "C_shortname Course fullname"
Scenario: set admin value with full name
Given the following config values are set as admin:
| courselistshortnames | 1 |
- And I am on homepage
+ And I am on site homepage
Then I should see "C_shortname Course fullname"
Scenario: set admin value with short name
Given the following config values are set as admin:
| courselistshortnames | 1 |
- And I am on homepage
- Then I should see "C_shortname Course fullname"
\ No newline at end of file
+ And I am on site homepage
+ Then I should see "C_shortname Course fullname"
And I should see "Tom"
And I should see "Jones"
And I should see "verysecret"
- And I should see "jonest@someplace.edu"
+ And I should see "jonest@example.com"
And I should see "Reznor"
And I should see "course1"
And I should see "math102"
And I follow "Browse list of users"
And I should see "Tom Jones"
And I should see "Trent Reznor"
- And I should see "reznor@someplace.edu"
- And I am on homepage
+ And I should see "reznor@example.com"
+ And I am on site homepage
And I follow "Maths"
And I expand "Users" node
And I follow "Groups"
}
require_once($CFG->dirroot.'/calendar/lib.php');
- $timezones = get_list_of_timezones();
+ $timezones = core_date::get_list_of_timezones(null, true);
echo '<center><form action="timezone.php" method="post">';
echo html_writer::label($strusers . ' (' . $strall . '): ', 'menuzone');
- echo html_writer::select($timezones, "zone", $current, array('99'=>get_string("serverlocaltime")));
+ echo html_writer::select($timezones, "zone", $current);
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />";
echo '<input type="submit" value="'.s($strsavechanges).'" />';
echo "</form></center>";
And the following config values are set as admin:
| enableavailability | 1 |
And I log in as "admin"
- And I am on homepage
+ And I am on site homepage
When I navigate to "Manage restrictions" node in "Site administration > Plugins > Availability restrictions"
# Check the icon is there (it should be a Hide icon, meaning is currently visible).
# OK, toggling works. Set the grade one to Hide and we'll go see if it actually worked.
And I click on "input[title=Hide]" "css_element" in the "Restriction by grade" "table_row"
- And I am on homepage
+ And I am on site homepage
And I follow "Course 1"
And I turn editing mode on
And I add a "Page" to section "1"
$help = "
Behat utilities to initialise behat tests
+Usage:
+ php init.php [--parallel=value [--maxruns=value] [--fromrun=value --torun=value]] [--help]
+
Options:
-j, --parallel Number of parallel behat run to initialise
-m, --maxruns Max parallel processes to be executed at one time.
$utilfile = 'util_single_run.php';
$paralleloption = "";
// If parallel run then use utilparallel.
-if ($options['parallel']) {
+if ($options['parallel'] && $options['parallel'] > 1) {
$utilfile = 'util.php';
$paralleloption = "";
foreach ($options as $option => $value) {
'help' => false,
'tags' => '',
'profile' => '',
+ 'feature' => '',
'fromrun' => 1,
'torun' => 0,
+ 'single-run' => false,
),
array(
'h' => 'help',
't' => 'tags',
'p' => 'profile',
+ 's' => 'single-run',
)
);
// Checking run.php CLI script usage.
$help = "
Behat utilities to run behat tests in parallel
+
+Usage:
+ php run.php [--BEHAT_OPTION=\"value\"] [--feature=\"value\"] [--replace] [--fromrun=value --torun=value] [--help]
+
Options:
--t, --tags Tags to execute.
--p, --profile Profile to execute.
---stop-on-failure Stop on failure in any parallel run.
---verbose Verbose output
+--BEHAT_OPTION Any combination of behat option specified in http://behat.readthedocs.org/en/v2.5/guides/6.cli.html
+--feature Only execute specified feature file (Absolute path of feature file).
--replace Replace args string with run process number, useful for output.
--fromrun Execute run starting from (Used for parallel runs on different vms)
--torun Execute run till (Used for parallel runs on different vms)
-h, --help Print out this help
Example from Moodle root directory:
-\$ php admin/tool/behat/cli/run.php --parallel=2
+\$ php admin/tool/behat/cli/run.php --tags=\"@javascript\"
More info in http://docs.moodle.org/dev/Acceptance_testing#Running_tests
";
}
}
-// If empty parallelrun then just check with user if it's a run single behat test.
-if (empty($parallelrun)) {
- if (cli_input("This is not a parallel site, do you want to run single behat run? (Y/N)", 'n', array('y', 'n')) == 'y') {
- $runtestscommand = behat_command::get_behat_command();
- $runtestscommand .= ' --config ' . behat_config_manager::get_behat_cli_config_filepath();
- exec("php $runtestscommand", $output, $code);
- echo implode(PHP_EOL, $output) . PHP_EOL;
- exit($code);
- } else {
- exit(1);
- }
-}
-
-// Create site symlink if necessary.
-if (!behat_config_manager::create_parallel_site_links($options['fromrun'], $options['torun'])) {
- echo "Check permissions. If on windows, make sure you are running this command as admin" . PHP_EOL;
- exit(1);
-}
-
$time = microtime(true);
array_walk($unrecognised, function (&$v) {
if ($x = preg_filter("#^(-+\w+)=(.+)#", "\$1='\$2'", $v)) {
$extraopts[] = '--tags="' . $tags . '"';
}
+// Feature should be added to last, for behat command.
+if ($options['feature']) {
+ $extraopts[] = $options['feature'];
+ // Only run 1 process as process.
+ // Feature file is picked from absolute path provided, so no need to check for behat.yml.
+ $options['torun'] = $options['fromrun'];
+}
+
+// Set of options to pass to behat.
+$extraopts = implode(' ', $extraopts);
+
+// If empty parallelrun then just check with user if it's a run single behat test.
+if (empty($parallelrun)) {
+ $cwd = getcwd();
+ chdir(__DIR__);
+ $runtestscommand = behat_command::get_behat_command(false, false, true);
+ $runtestscommand .= ' --config ' . behat_config_manager::get_behat_cli_config_filepath();
+ $runtestscommand .= ' ' . $extraopts;
+ echo "Running single behat site:" . PHP_EOL;
+ passthru("php $runtestscommand", $code);
+ chdir($cwd);
+ exit($code);
+}
+
// Update config file if tags defined.
if ($tags) {
// Hack to set proper dataroot and wwwroot.
$behatwwwroot = $CFG->behat_wwwroot;
for ($i = 1; $i <= $parallelrun; $i++) {
$CFG->behatrunprocess = $i;
- $CFG->behat_dataroot = $behatdataroot . $i;
- if (!empty($CFG->behat_parallel_run['behat_wwwroot'][$i - 1]['behat_wwwroot'])) {
- $CFG->behat_wwwroot = $CFG->behat_parallel_run['behat_wwwroot'][$i - 1]['behat_wwwroot'];
+
+ if (!empty($CFG->behat_parallel_run[$i - 1]['behat_wwwroot'])) {
+ $CFG->behat_wwwroot = $CFG->behat_parallel_run[$i - 1]['behat_wwwroot'];
} else {
$CFG->behat_wwwroot = $behatwwwroot . "/" . BEHAT_PARALLEL_SITE_NAME . $i;
}
+ if (!empty($CFG->behat_parallel_run[$i - 1]['behat_dataroot'])) {
+ $CFG->behat_dataroot = $CFG->behat_parallel_run[$i - 1]['behat_dataroot'];
+ } else {
+ $CFG->behat_dataroot = $behatdataroot . $i;
+ }
behat_config_manager::update_config_file('', true, $tags);
}
$CFG->behat_dataroot = $behatdataroot;
}
$cmds = array();
-$extraopts = implode(' ', $extraopts);
echo "Running " . ($options['torun'] - $options['fromrun'] + 1) . " parallel behat sites:" . PHP_EOL;
for ($i = $options['fromrun']; $i <= $options['torun']; $i++) {
// Options parameters to be added to each run.
$myopts = !empty($options['replace']) ? str_replace($options['replace'], $i, $extraopts) : $extraopts;
- $behatcommand = behat_command::get_behat_command();
+ $behatcommand = behat_command::get_behat_command(false, false, true);
$behatconfigpath = behat_config_manager::get_behat_cli_config_filepath($i);
// Command to execute behat run.
exit(1);
}
+// Create site symlink if necessary.
+if (!behat_config_manager::create_parallel_site_links($options['fromrun'], $options['torun'])) {
+ echo "Check permissions. If on windows, make sure you are running this command as admin" . PHP_EOL;
+ exit(1);
+}
+
// Execute all commands.
-$processes = cli_execute_parallel($cmds);
+$processes = cli_execute_parallel($cmds, __DIR__);
$stoponfail = empty($options['stop-on-failure']) ? false : true;
// Print header.
$status = (bool)$status || (bool)$exitcode;
}
+// Run finished. Show exit code and output from individual process.
+$verbose = empty($options['verbose']) ? false : true;
+$verbose = $verbose || $status;
+
// Show exit code from each process, if any process failed.
-if ($status) {
- echo "Exit codes: " . implode(" ", $exitcodes) . PHP_EOL;
- echo "To re-run failed processes, you can use following commands:" . PHP_EOL;
- foreach ($cmds as $name => $cmd) {
- if (!empty($exitcodes[$name])) {
- echo "[" . $name . "] " . $cmd . PHP_EOL;
+if ($verbose) {
+ // Echo exit codes.
+ echo "Exit codes for each behat run: " . PHP_EOL;
+ ksort($exitcodes);
+ foreach ($exitcodes as $run => $exitcode) {
+ echo $run . ": " . $exitcode . PHP_EOL;
+ }
+
+ // Show failed re-run commands.
+ if ($status) {
+ echo "To re-run failed processes, you can use following commands:" . PHP_EOL;
+ foreach ($cmds as $name => $cmd) {
+ if (!empty($exitcodes[$name])) {
+ echo "[" . $name . "] " . $cmd . PHP_EOL;
+ }
}
}
echo PHP_EOL;
}
-// Run finished. Show exit code and output from individual process.
-$verbose = empty($options['verbose']) ? false : true;
-$verbose = $verbose || $status;
print_each_process_info($processes, $verbose);
// Remove site symlink if necessary.
$help = "
Behat utilities to manage the test environment
+Usage:
+ php util.php [--install|--drop|--enable|--disable|--diag|--updatesteps|--help] [--parallel=value [--maxruns=value]]
+
Options:
--install Installs the test environment for acceptance tests
--drop Drops the database tables and the dataroot contents
--enable Enables test environment and updates tests list
--disable Disables test environment
--diag Get behat test environment status code
+--updatesteps Update feature step file.
-j, --parallel Number of parallel behat run operation
-m, --maxruns Max parallel processes to be executed at one time.
---updatesteps Update feature step file.
-h, --help Print out this help
} else if ($options['disable']) {
echo "Acceptance tests environment disabled for " . $options['parallel'] . " parallel sites" . PHP_EOL;
+} else if ($options['diag']) {
+ // Valid option, so nothing to do.
} else {
echo $help;
+ chdir($cwd);
+ exit(1);
}
chdir($cwd);
$help = "
Behat utilities to manage the test environment
+Usage:
+ php util_single_run.php [--install|--drop|--enable|--disable|--diag|--updatesteps|--help]
+
Options:
--install Installs the test environment for acceptance tests
--drop Drops the database tables and the dataroot contents
@javascript
Scenario: Basic contents assertions
Given I log in as "admin"
- And I am on homepage
+ And I am on site homepage
And I expand "Users" node
And I follow "Groups"
And I press "Create group"
Then I should see "I'm the description"
And "Grouping" "select" in the "region-main" "region" should be visible
And "Group" "select" should be visible
- And "Messaging" "link" in the "Administration" "block" should not be visible
- And "Change password" "link" should not be visible
+ And "Activity report" "link" in the "Administration" "block" should not be visible
+ And "Event monitoring rules" "link" should not be visible
And I should see "Filter groups by"
And I should not see "Filter groupssss by"
And I should see "Group members" in the "#region-main table th.c1" "css_element"
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And I log in as "admin"
+ And I am on site homepage
And I follow "Course 1"
When I dock "Administration" block
Then I should not see "Question bank" in the ".block-region" "css_element"
| Course 2 | COURSE2 | CAT3 |
| Course 3 | COURSE3 | 0 |
When I log in as "admin"
+ And I am on site homepage
Then I should see "Course 1"
And I should see "Course 2"
And I should see "Course 3"
| Grouping 1 | C1 | GG1 |
| Grouping 2 | C1 | GG2 |
When I log in as "admin"
+ And I am on site homepage
And I follow "Course 1"
And I expand "Users" node
And I follow "Groups"
Scenario: Role overrides
Given the following "users" exist:
| username | firstname | lastname | email |
- | teacher1 | Teacher | 1 | teacher1@asd.com |
- | student1 | Student | 1 | student1@asd.com |
+ | teacher1 | Teacher | 1 | teacher1@example.com |
+ | student1 | Student | 1 | student1@example.com |
And the following "categories" exist:
| name | category | idnumber |
| Cat 1 | 0 | CAT1 |
| mod/forum:editanypost | Allow | student | Course | C1 |
| mod/forum:replynews | Prevent | editingteacher | Course | C1 |
When I log in as "admin"
+ And I am on site homepage
And I follow "Course 1"
And I expand "Users" node
And I follow "Permissions"
Scenario: Add course enrolments
Given the following "users" exist:
| username | firstname | lastname | email |
- | student1 | Student | 1 | student1@asd.com |
+ | student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
| Custom student | custom2 | | |
And the following "users" exist:
| username | firstname | lastname | email |
- | user1 | User | 1 | user1@moodlemoodle.com |
- | user2 | User | 2 | user2@moodlemoodle.com |
- | user3 | User | 3 | user3@moodlemoodle.com |
- | user4 | User | 4 | user4@moodlemoodle.com |
- | user5 | User | 5 | user5@moodlemoodle.com |
+ | user1 | User | 1 | user1@example.com |
+ | user2 | User | 2 | user2@example.com |
+ | user3 | User | 3 | user3@example.com |
+ | user4 | User | 4 | user4@example.com |
+ | user5 | User | 5 | user5@example.com |
And the following "categories" exist:
| name | category | idnumber |
| Cat 1 | 0 | CAT1 |
| user3 | editingteacher | Course | C1 |
| user5 | custom2 | System | |
When I log in as "user1"
+ And I am on site homepage
Then I should see "Front page settings"
And I log out
And I log in as "user2"
+ And I am on site homepage
And I follow "Course 1"
And I should see "Turn editing on"
And I log out
And I log in as "user3"
+ And I am on site homepage
And I follow "Course 1"
And I should see "Turn editing on"
And I log out
And I log in as "user4"
+ And I am on site homepage
And I follow "Course 1"
And I should see "Turn editing on"
And I log out
And I log in as "user5"
And I should see "You are logged in as"
+ And I am on site homepage
And I follow "Course 1"
And I should see "You can not enrol yourself in this course."
| activity | name | intro | course | idnumber | grade |
| assign | Test assignment name with scale | Test assignment description | C1 | assign1 | Test Scale 1 |
When I log in as "admin"
+ And I am on site homepage
And I follow "Course 1"
Then I should see "Test assignment name"
# Assignment 2.2 module type is disabled by default
Scenario: Add relations between users and groups
Given the following "users" exist:
| username | firstname | lastname | email |
- | student1 | Student | 1 | student1@asd.com |
- | student2 | Student | 2 | student2@asd.com |
+ | student1 | Student | 1 | student1@example.com |
+ | student2 | Student | 2 | student2@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
| grouping | group |
| GG1 | G1 |
When I log in as "admin"
+ And I am on site homepage
And I follow "Course 1"
And I expand "Users" node
And I follow "Groups"
| Cat 1 | 0 | CAT1 |
And the following "users" exist:
| username | firstname | lastname | email |
- | student1 | Student | 1 | student1@asd.com |
- | student2 | Student | 2 | student2@asd.com |
+ | student1 | Student | 1 | student1@example.com |
+ | student2 | Student | 2 | student2@example.com |
And the following "cohorts" exist:
| name | idnumber |
| System cohort A | CHSA |
| fullname | course | gradecategory |
| Grade sub category 2 | C1 | Grade category 1 |
When I log in as "admin"
+ And I am on site homepage
And I follow "Courses"
And I follow "Course 1"
And I navigate to "Grades" node in "Course administration"
| Test Grade Item 2 | C1 | Grade category 1 |
| Test Grade Item 3 | C1 | Grade sub category 2 |
When I log in as "admin"
+ And I am on site homepage
And I follow "Course 1"
And I follow "Grades"
And I expand "Setup" node
| name | scale |
| Test Scale 1 | Disappointing, Good, Very good, Excellent |
When I log in as "admin"
+ And I am on site homepage
And I follow "Course 1"
And I follow "Grades"
And I follow "Scales"
And the following config values are set as admin:
| enableoutcomes | 1 |
When I log in as "admin"
- And I follow "Home"
+ And I am on site homepage
And I follow "Course 1"
And I follow "Outcomes"
Then I should see "Grade outcome 1" in the "#addoutcomes" "css_element"
And the following config values are set as admin:
| enableoutcomes | 1 |
When I log in as "admin"
- And I follow "Home"
+ And I am on site homepage
And I follow "Course 1"
And I follow "Grades"
And I expand "Setup" node
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
- | teacher1 | Teacher | 1 | teacher1@asd.com |
+ | teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
| Course 1 | C1 | 0 |
And the following "users" exist:
| username | email | firstname | lastname |
- | student1 | s1@asd.com | Student | 1 |
- | student2 | s2@asd.com | Student | 2 |
- | student3 | s3@asd.com | Student | 3 |
+ | student1 | s1@example.com | Student | 1 |
+ | student2 | s2@example.com | Student | 2 |
+ | student3 | s3@example.com | Student | 3 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
# Select (multi-select) - We will check "I set the field...".
And I set the field "otagsadd" to "OT1, OT2, OT3, OT4, OT5"
And I press "Add official tags"
- And I am on homepage
+ And I am on site homepage
And I follow "Course 1"
And I turn editing mode on
And I follow "Test this one"
@javascript
Scenario: Basic forms manipulation
Given I log in as "admin"
- And I navigate to "Edit profile" node in "My profile settings"
+ And I follow "My preferences" in the user menu
+ And I follow "Edit profile"
When I set the field "First name" to "Field value"
- And I set the field "Text editor" to "Plain text area"
+ And I set the field "Select a country" to "Japan"
And I set the field "Unmask" to "1"
And I expand all fieldsets
Then the field "First name" matches value "Field value"
- And the "Text editor" select box should contain "Plain text area"
+ And the "Select a country" select box should contain "Japan"
And the field "Unmask" matches value "1"
And I set the field "Unmask" to ""
And the field "Unmask" matches value ""
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And I log in as "admin"
+ And I am on site homepage
And I follow "Course 1"
And I turn editing mode on
And I add a "Quiz" to section "1"
I need to apply some transformations to the steps arguments
Background:
- Given I am on homepage
+ Given I am on site homepage
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And I log in as "admin"
- And I navigate to "Edit profile" node in "My profile settings"
+ And I follow "My preferences" in the user menu
+ And I follow "Edit profile"
+ @javascript
Scenario: Use nasty strings on steps arguments
When I set the field "Surname" to "$NASTYSTRING1"
And I set the field "Description" to "$NASTYSTRING2"
And the field "Surname" matches value "$NASTYSTRING1"
And the field "City/town" matches value "$NASTYSTRING3"
+ @javascript
Scenario: Use nasty strings on table nodes
When I set the following fields to these values:
| Surname | $NASTYSTRING1 |
And the field "Surname" matches value "$NASTYSTRING1"
And the field "City/town" matches value "$NASTYSTRING3"
+ @javascript
Scenario: Use double quotes
When I set the following fields to these values:
| First name | va"lue1 |
I need to use the test environment instead of the regular environment
Scenario: Accessing the site
- When I am on homepage
+ When I am on site homepage
Then I should see "Acceptance test site"
| Custom description | Froggy file |
And I press "Save changes"
# Create a resource activity and add it to a course
- And I am on homepage
+ And I am on site homepage
And I follow "Course 1"
And I turn editing mode on
When I add a "File" to section "1"
* @return string to display on the mangesubs page.
*/
protected function render_rules(rules $renderable) {
- $o = $this->render_course_select($renderable);
+ $o = '';
if (!empty($renderable->totalcount)) {
$o .= $this->render_table($renderable);
}
return false;
}
$orderby = 'visible DESC, sortorder ASC';
- $options = array(0 => get_string('site'));
+ $options = array();
if ($courses = get_user_capability_course('tool/monitor:subscribe', null, true, 'fullname', $orderby)) {
foreach ($courses as $course) {
$options[$course->id] = format_string($course->fullname, true,
array('context' => \context_course::instance($course->id)));
}
}
+ // If there are no options to display, then don't display anything.
+ if (count($options) === 0) {
+ return false;
+ }
$url = new \moodle_url('/admin/tool/monitor/index.php');
$select = new \single_select($url, 'courseid', $options, $this->courseid);
$select->set_label(get_string('selectacourse', 'tool_monitor'));
require_once(__DIR__ . '/../../../config.php');
require_once($CFG->libdir.'/adminlib.php');
-$courseid = optional_param('courseid', 0, PARAM_INT);
+$courseid = optional_param('courseid', SITEID, PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHA);
$cmid = optional_param('cmid', 0, PARAM_INT);
$ruleid = optional_param('ruleid', 0, PARAM_INT);
$subscriptionid = optional_param('subscriptionid', 0, PARAM_INT);
$confirm = optional_param('confirm', false, PARAM_BOOL);
-// Validate course id.
+require_login();
+
+// We need to explicitly check that the course id is something legitimate.
if (empty($courseid)) {
- require_login();
-} else {
- // They might want to see rules for this course.
- $course = get_course($courseid);
- require_login($course);
- $coursecontext = context_course::instance($course->id);
- // Check for caps.
- require_capability('tool/monitor:subscribe', $coursecontext);
- $coursename = format_string($course->fullname, true, array('context' => $coursecontext));
+ $courseid = SITEID;
}
+$coursecontext = context_course::instance($courseid);
+
if (!get_config('tool_monitor', 'enablemonitor')) {
// This should never happen as the this page does not appear in navigation when the tool is disabled.
throw new coding_exception('Event monitoring is disabled');
}
-// Always build the page in site context.
-$context = context_system::instance();
-$sitename = format_string($SITE->fullname, true, array('context' => $context));
-$PAGE->set_context($context);
+$sitename = format_string($SITE->fullname, true, array('context' => $coursecontext));
+$PAGE->set_context(context_user::instance($USER->id));
// Set up the page.
$indexurl = new moodle_url('/admin/tool/monitor/index.php', array('courseid' => $courseid));
$PAGE->set_url($indexurl);
$PAGE->set_pagelayout('report');
$PAGE->set_title($sitename);
-$PAGE->set_heading($sitename);
+$PAGE->set_heading(fullname($USER));
+$settingsnode = $PAGE->settingsnav->find('monitor', null)->make_active();
// Create/delete subscription if needed.
if (!empty($action)) {
} else {
$subscription = \tool_monitor\subscription_manager::get_subscription($subscriptionid);
echo $OUTPUT->header();
- echo $OUTPUT->confirm(get_string('subareyousure', 'tool_monitor', $subscription->get_name($context)),
+ echo $OUTPUT->confirm(get_string('subareyousure', 'tool_monitor', $subscription->get_name($coursecontext)),
$confirmurl, $cancelurl);
echo $OUTPUT->footer();
exit();
echo $OUTPUT->header();
}
+$renderer = $PAGE->get_renderer('tool_monitor', 'managesubs');
+
+// Render the course selector.
+$totalrules = \tool_monitor\rule_manager::count_rules_by_courseid($courseid);
+$rules = new \tool_monitor\output\managesubs\rules('toolmonitorrules', $indexurl, $courseid);
+
+$usercourses = $rules->get_user_courses_select();
+if (!empty($usercourses)) {
+ echo $renderer->render($usercourses);
+} else {
+ // Nothing to show at all. Show a notification.
+ echo $OUTPUT->notification(get_string('rulenopermission', 'tool_monitor'), 'notifyproblem');
+}
+
// Render the current subscriptions list.
$totalsubs = \tool_monitor\subscription_manager::count_user_subscriptions();
-$renderer = $PAGE->get_renderer('tool_monitor', 'managesubs');
if (!empty($totalsubs)) {
// Show the subscriptions section only if there are subscriptions.
$subs = new \tool_monitor\output\managesubs\subs('toolmonitorsubs', $indexurl, $courseid);
}
// Render the potential rules list.
-$totalrules = \tool_monitor\rule_manager::count_rules_by_courseid($courseid);
-echo $OUTPUT->heading(get_string('rulescansubscribe', 'tool_monitor'), 3);
-$rules = new \tool_monitor\output\managesubs\rules('toolmonitorrules', $indexurl, $courseid);
-echo $renderer->render($rules);
+// Check the capability here before displaying any rules to subscribe to.
+if (has_capability('tool/monitor:subscribe', $coursecontext)) {
+ echo $OUTPUT->heading(get_string('rulescansubscribe', 'tool_monitor'), 3);
+ echo $renderer->render($rules);
+}
// Check if the user can manage the course rules we are viewing.
-if (empty($courseid)) {
- $canmanagerules = has_capability('tool/monitor:managerules', $context);
-} else {
- $canmanagerules = has_capability('tool/monitor:managerules', $coursecontext);
-}
+$canmanagerules = has_capability('tool/monitor:managerules', $coursecontext);
+
if (empty($totalrules)) {
// No rules present. Show a link to manage rules page if permissions permit.
echo html_writer::start_div();
$string['ruledeletesuccess'] = 'Rule successfully deleted';
$string['rulehelp'] = 'Rule details';
$string['rulehelp_help'] = 'This rule listens for when the event \'{$a->eventname}\' in \'{$a->eventcomponent}\' has been triggered {$a->frequency} time(s) in {$a->minutes} minute(s).';
+$string['rulenopermission'] = 'You do not have permission to subscribe to any events.';
$string['rulenopermissions'] = 'You do not have permissions to "{$a} a rule"';
$string['rulescansubscribe'] = 'Rules you can subscribe to';
$string['selectacourse'] = 'Select a course';
*/
function tool_monitor_extend_navigation_user_settings($navigation, $user, $usercontext, $course, $coursecontext) {
global $USER, $SITE;
- if (($USER->id == $user->id) && (has_capability('tool/monitor:subscribe', $coursecontext)
- && get_config('tool_monitor', 'enablemonitor'))) {
+
+ // Don't show the setting if the event monitor isn't turned on. No access to other peoples subscriptions.
+ if (get_config('tool_monitor', 'enablemonitor') && $USER->id == $user->id) {
// The $course->id will always be the course that corresponds to the current context.
$courseid = $course->id;
// A $course->id of $SITE->id might either be the frontpage or the site. So if we get the site ID back, check the...
}
$url = new moodle_url('/admin/tool/monitor/index.php', array('courseid' => $courseid));
$subsnode = navigation_node::create(get_string('managesubscriptions', 'tool_monitor'), $url,
- navigation_node::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
+ navigation_node::TYPE_SETTING, null, 'monitor', new pix_icon('i/settings', ''));
if (isset($subsnode) && !empty($navigation)) {
$navigation->add_node($subsnode);
| Course 1 | C1 |
And the following "users" exist:
| username | firstname | lastname | email |
- | teacher1 | Teacher | 1 | teacher1@asd.com |
+ | teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I navigate to "Event monitoring rules" node in "Site administration > Reports"
And I click on "Enable" "link"
- And I am on homepage
+ And I am on site homepage
And I follow "Course 1"
And I navigate to "Event mon