diff --git a/enrol/self/tests/self_test.php b/enrol/self/tests/self_test.php index 1cf5509e0f488..0a6fcffe03483 100644 --- a/enrol/self/tests/self_test.php +++ b/enrol/self/tests/self_test.php @@ -602,8 +602,8 @@ public function test_can_self_enrol() { $selfplugin->enrol_user($instance1, $user2->id, $editingteacherrole->id); $this->setUser($guest); - $noaccesshtml = get_string('noguestaccess', 'enrol') . $OUTPUT->continue_button(get_login_url()); - $this->assertSame($noaccesshtml, $selfplugin->can_self_enrol($instance1, true)); + $this->assertContains(get_string('noguestaccess', 'enrol'), + $selfplugin->can_self_enrol($instance1, true)); $this->setUser($user1); $this->assertTrue($selfplugin->can_self_enrol($instance1, true)); diff --git a/grade/tests/importlib_test.php b/grade/tests/importlib_test.php index 234e6a4dc5ad1..8e4ac6a9d04c2 100644 --- a/grade/tests/importlib_test.php +++ b/grade/tests/importlib_test.php @@ -194,15 +194,11 @@ public function test_grade_import_commit() { 'itemid' => $gradeitem->id )); - $url = $CFG->wwwroot . '/grade/index.php'; - $expectedresponse = "++ Grade import success ++ -
id\" />
"; - ob_start(); $status = grade_import_commit($course->id, $importcode); $output = ob_get_contents(); ob_end_clean(); $this->assertTrue($status); - $this->assertEquals($expectedresponse, $output); + $this->assertContains("++ Grade import success ++", $output); } } diff --git a/theme/bootstrapbase/classes/output/core_renderer.php b/theme/bootstrapbase/classes/output/core_renderer.php deleted file mode 100644 index 0a53221b52f3a..0000000000000 --- a/theme/bootstrapbase/classes/output/core_renderer.php +++ /dev/null @@ -1,470 +0,0 @@ -. - -namespace theme_bootstrapbase\output; - -use coding_exception; -use \html_writer; -use tabobject; -use tabtree; -use custom_menu_item; -use custom_menu; -use block_contents; -use navigation_node; -use action_link; -use stdClass; -use moodle_url; -use preferences_groups; -use action_menu; -use help_icon; -use single_button; -use context_course; -use pix_icon; - -defined('MOODLE_INTERNAL') || die; - -/** - * Renderers to align Moodle's HTML with that expected by Bootstrap - * - * @package theme_bootstrapbase - * @copyright 2012 Bas Brands, www.basbrands.nl - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -class core_renderer extends \core_renderer { - - /** - * Wrapper for header elements. - * - * @return string HTML to display the main header. - */ - public function full_header() { - $html = \html_writer::start_tag('header', array('id' => 'page-header', 'class' => 'clearfix')); - $html .= $this->context_header(); - $html .= \html_writer::start_div('clearfix', array('id' => 'page-navbar')); - $html .= \html_writer::tag('div', $this->navbar(), array('class' => 'breadcrumb-nav')); - $html .= \html_writer::div($this->page_heading_button(), 'breadcrumb-button'); - $html .= html_writer::end_div(); - $html .= html_writer::tag('div', $this->course_header(), array('id' => 'course-header')); - $html .= html_writer::end_tag('header'); - return $html; - } - - /** - * Return the navbar content so that it can be echoed out by the layout - * - * @return string XHTML navbar - */ - public function navbar() { - $items = $this->page->navbar->get_items(); - $itemcount = count($items); - if ($itemcount === 0) { - return ''; - } - - $htmlblocks = array(); - // Iterate the navarray and display each node - $separator = get_separator(); - for ($i=0;$i < $itemcount;$i++) { - $item = $items[$i]; - $item->hideicon = true; - if ($i===0) { - $content = html_writer::tag('li', $this->render($item)); - } else { - $content = html_writer::tag('li', $separator.$this->render($item)); - } - $htmlblocks[] = $content; - } - - //accessibility: heading for navbar list (MDL-20446) - $navbarcontent = html_writer::tag('span', get_string('pagepath'), - array('class' => 'accesshide', 'id' => 'navbar-label')); - $navbarcontent .= html_writer::tag('nav', - html_writer::tag('ul', join('', $htmlblocks)), - array('aria-labelledby' => 'navbar-label')); - // XHTML - return $navbarcontent; - } - - /** - * Returns HTML to display a "Turn editing on/off" button in a form. - * - * @param moodle_url $url The URL + params to send through when clicking the button - * @return string HTML the button - */ - public function edit_button(moodle_url $url) { - - $url->param('sesskey', sesskey()); - if ($this->page->user_is_editing()) { - $url->param('edit', 'off'); - $editstring = get_string('turneditingoff'); - } else { - $url->param('edit', 'on'); - $editstring = get_string('turneditingon'); - } - - return $this->single_button($url, $editstring); - } - - /** - * Get the compact logo URL. - * - * @return string - */ - public function get_compact_logo_url($maxwidth = 100, $maxheight = 100) { - return parent::get_compact_logo_url(null, 70); - } - - /* - * Overriding the custom_menu function ensures the custom menu is - * always shown, even if no menu items are configured in the global - * theme settings page. - */ - public function custom_menu($custommenuitems = '') { - global $CFG; - if (empty($custommenuitems) && !empty($CFG->custommenuitems)) { - $custommenuitems = $CFG->custommenuitems; - } - if (empty($custommenuitems)) { - return ''; - } - $custommenu = new custom_menu($custommenuitems, current_language()); - return $this->render($custommenu); - } - - /* - * This renders the bootstrap top menu. - * - * This renderer is needed to enable the Bootstrap style navigation. - */ - protected function render_custom_menu(custom_menu $menu) { - static $menucount = 0; - // If the menu has no children return an empty string - if (!$menu->has_children()) { - return ''; - } - // Increment the menu count. This is used for ID's that get worked with - // in JavaScript as is essential - $menucount++; - // Initialise this custom menu (the custom menu object is contained in javascript-static - $jscode = js_writer::function_call_with_Y('M.core_custom_menu.init', array('custom_menu_'.$menucount)); - $jscode = "(function(){{$jscode}})"; - $this->page->requires->yui_module('node-menunav', $jscode); - // Build the root nodes as required by YUI - $content = html_writer::start_tag('div', array('id'=>'custom_menu_'.$menucount, 'class'=>'yui3-menu yui3-menu-horizontal javascript-disabled custom-menu')); - $content .= html_writer::start_tag('div', array('class'=>'yui3-menu-content')); - $content .= html_writer::start_tag('ul'); - // Render each child - foreach ($menu->get_children() as $item) { - $content .= $this->render_custom_menu_item($item); - } - // Close the open tags - $content .= html_writer::end_tag('ul'); - $content .= html_writer::end_tag('div'); - $content .= html_writer::end_tag('div'); - // Return the custom menu - return $content; - } - - /** - * Renders tabtree - * - * @param tabtree $tabtree - * @return string - */ - protected function render_tabtree(tabtree $tabtree) { - if (empty($tabtree->subtree)) { - return ''; - } - $str = ''; - $str .= html_writer::start_tag('div', array('class' => 'tabtree')); - $str .= $this->render_tabobject($tabtree); - $str .= html_writer::end_tag('div'). - html_writer::tag('div', ' ', array('class' => 'clearer')); - return $str; - } - - /** - * Renders tabobject (part of tabtree) - * - * This function is called from {@link core_renderer::render_tabtree()} - * and also it calls itself when printing the $tabobject subtree recursively. - * - * @param tabobject $tabobject - * @return string HTML fragment - */ - protected function render_tabobject(tabobject $tab) { - throw new coding_exception('Tab objects should not be directly rendered.'); - } - - /** - * Prints a nice side block with an optional header. - * - * The content is described - * by a {@link core_renderer::block_contents} object. - * - *
- *
- *
- * ...CONTENT... - * - *
- *
- *
- *
- * - * @param block_contents $bc HTML for the content - * @param string $region the region the block is appearing in. - * @return string the HTML to be output. - */ - public function block(block_contents $bc, $region) { - $bc = clone($bc); // Avoid messing up the object passed in. - if (empty($bc->blockinstanceid) || !strip_tags($bc->title)) { - $bc->collapsible = block_contents::NOT_HIDEABLE; - } - if (!empty($bc->blockinstanceid)) { - $bc->attributes['data-instanceid'] = $bc->blockinstanceid; - } - $skiptitle = strip_tags($bc->title); - if ($bc->blockinstanceid && !empty($skiptitle)) { - $bc->attributes['aria-labelledby'] = 'instance-'.$bc->blockinstanceid.'-header'; - } else if (!empty($bc->arialabel)) { - $bc->attributes['aria-label'] = $bc->arialabel; - } - if ($bc->dockable) { - $bc->attributes['data-dockable'] = 1; - } - if ($bc->collapsible == block_contents::HIDDEN) { - $bc->add_class('hidden'); - } - if (!empty($bc->controls)) { - $bc->add_class('block_with_controls'); - } - - - if (empty($skiptitle)) { - $output = ''; - $skipdest = ''; - } else { - $output = html_writer::link('#sb-'.$bc->skipid, get_string('skipa', 'access', $skiptitle), - array('class' => 'skip skip-block', 'id' => 'fsb-' . $bc->skipid)); - $skipdest = html_writer::span('', 'skip-block-to', - array('id' => 'sb-' . $bc->skipid)); - } - - $output .= html_writer::start_tag('div', $bc->attributes); - - $output .= $this->block_header($bc); - $output .= $this->block_content($bc); - - $output .= html_writer::end_tag('div'); - - $output .= $this->block_annotation($bc); - - $output .= $skipdest; - - $this->init_block_hider_js($bc); - return $output; - } - - /** - * Returns the CSS classes to apply to the body tag. - * - * @since Moodle 2.5.1 2.6 - * @param array $additionalclasses Any additional classes to apply. - * @return string - */ - public function body_css_classes(array $additionalclasses = array()) { - // Add a class for each block region on the page. - // We use the block manager here because the theme object makes get_string calls. - $usedregions = array(); - foreach ($this->page->blocks->get_regions() as $region) { - $additionalclasses[] = 'has-region-'.$region; - if ($this->page->blocks->region_has_content($region, $this)) { - $additionalclasses[] = 'used-region-'.$region; - $usedregions[] = $region; - } else { - $additionalclasses[] = 'empty-region-'.$region; - } - if ($this->page->blocks->region_completely_docked($region, $this)) { - $additionalclasses[] = 'docked-region-'.$region; - } - } - if (!$usedregions) { - // No regions means there is only content, add 'content-only' class. - $additionalclasses[] = 'content-only'; - } else if (count($usedregions) === 1) { - // Add the -only class for the only used region. - $region = array_shift($usedregions); - $additionalclasses[] = $region . '-only'; - } - foreach ($this->page->layout_options as $option => $value) { - if ($value) { - $additionalclasses[] = 'layout-option-'.$option; - } - } - $css = $this->page->bodyclasses .' '. join(' ', $additionalclasses); - return $css; - } - - /** - * Renders preferences groups. - * - * @param preferences_groups $renderable The renderable - * @return string The output. - */ - public function render_preferences_groups(preferences_groups $renderable) { - $html = ''; - $html .= html_writer::start_div('row-fluid'); - $html .= html_writer::start_tag('div', array('class' => 'span12 preferences-groups')); - $i = 0; - $open = false; - foreach ($renderable->groups as $group) { - if ($i == 0 || $i % 3 == 0) { - if ($open) { - $html .= html_writer::end_tag('div'); - } - $html .= html_writer::start_tag('div', array('class' => 'row-fluid')); - $open = true; - } - $html .= $this->render($group); - $i++; - } - - $html .= html_writer::end_tag('div'); - - $html .= html_writer::end_tag('ul'); - $html .= html_writer::end_tag('div'); - $html .= html_writer::end_div(); - return $html; - } - - /** - * Renders an action menu component. - * - * ARIA references: - * - http://www.w3.org/WAI/GL/wiki/Using_ARIA_menus - * - http://stackoverflow.com/questions/12279113/recommended-wai-aria-implementation-for-navigation-bar-menu - * - * @param action_menu $menu - * @return string HTML - */ - public function render_action_menu(action_menu $menu) { - $context = $menu->export_for_template($this); - return $this->render_from_template('core/action_menu', $context); - } - - /** - * Implementation of user image rendering. - * - * @param help_icon $helpicon A help icon instance - * @return string HTML fragment - */ - protected function render_help_icon(help_icon $helpicon) { - return $this->render_from_template('core/help_icon', $helpicon->export_for_template($this)); - } - - /** - * Renders a single button widget. - * - * This will return HTML to display a form containing a single button. - * - * @param single_button $button - * @return string HTML fragment - */ - protected function render_single_button(single_button $button) { - $attributes = array('type' => 'submit', - 'value' => $button->label, - 'disabled' => $button->disabled ? 'disabled' : null, - 'title' => $button->tooltip); - - if ($button->actions) { - $id = html_writer::random_id('single_button'); - $attributes['id'] = $id; - foreach ($button->actions as $action) { - $this->add_action_handler($action, $id); - } - } - - // first the input element - $output = html_writer::empty_tag('input', $attributes); - - // then hidden fields - $params = $button->url->params(); - if ($button->method === 'post') { - $params['sesskey'] = sesskey(); - } - foreach ($params as $var => $val) { - $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $var, 'value' => $val)); - } - - // then div wrapper for xhtml strictness - $output = html_writer::tag('div', $output); - - // now the form itself around it - if ($button->method === 'get') { - $url = $button->url->out_omit_querystring(true); // url without params, the anchor part allowed - } else { - $url = $button->url->out_omit_querystring(); // url without params, the anchor part not allowed - } - if ($url === '') { - $url = '#'; // there has to be always some action - } - $attributes = array('method' => $button->method, - 'action' => $url, - 'id' => $button->formid); - $output = html_writer::tag('form', $output, $attributes); - - // and finally one more wrapper with class - return html_writer::tag('div', $output, array('class' => $button->class)); - } - - /** - * Renders the login form. - * - * @param \core_auth\output\login $form The renderable. - * @return string - */ - public function render_login(\core_auth\output\login $form) { - global $CFG; - - $context = $form->export_for_template($this); - - // Override because rendering is not supported in template yet. - if ($CFG->rememberusername == 0) { - $context->cookieshelpiconformatted = $this->help_icon('cookiesenabledonlysession'); - } else { - $context->cookieshelpiconformatted = $this->help_icon('cookiesenabled'); - } - $context->errorformatted = $this->error_text($context->error); - - return $this->render_from_template('core/loginform', $context); - } - - /** - * Render the login signup form into a nice template for the theme. - * - * @param mform $form - * @return string - */ - public function render_login_signup_form($form) { - $context = $form->export_for_template($this); - - return $this->render_from_template('core/signup_form_layout', $context); - } - -} diff --git a/theme/bootstrapbase/renderers.php b/theme/bootstrapbase/renderers.php index e856a428c783a..96ce9310b82a1 100644 --- a/theme/bootstrapbase/renderers.php +++ b/theme/bootstrapbase/renderers.php @@ -28,4 +28,4 @@ require_once($CFG->dirroot . '/theme/bootstrapbase/renderers/core/course_renderer.php'); require_once($CFG->dirroot . '/theme/bootstrapbase/renderers/core/files_renderer.php'); require_once($CFG->dirroot . '/theme/bootstrapbase/renderers/core_course/management/renderer.php'); -require_once($CFG->dirroot . '/theme/bootstrapbase/renderers/core_question/bank_renderer.php'); +require_once($CFG->dirroot . '/theme/bootstrapbase/renderers/core_question/bank_renderer.php'); \ No newline at end of file diff --git a/theme/bootstrapbase/classes/output/block_settings_renderer.php b/theme/bootstrapbase/renderers/block_settings_renderer.php similarity index 100% rename from theme/bootstrapbase/classes/output/block_settings_renderer.php rename to theme/bootstrapbase/renderers/block_settings_renderer.php diff --git a/theme/bootstrapbase/classes/output/core/course_renderer.php b/theme/bootstrapbase/renderers/core/course_renderer.php similarity index 100% rename from theme/bootstrapbase/classes/output/core/course_renderer.php rename to theme/bootstrapbase/renderers/core/course_renderer.php diff --git a/theme/bootstrapbase/classes/output/core/files_renderer.php b/theme/bootstrapbase/renderers/core/files_renderer.php similarity index 100% rename from theme/bootstrapbase/classes/output/core/files_renderer.php rename to theme/bootstrapbase/renderers/core/files_renderer.php diff --git a/theme/bootstrapbase/classes/output/core_course/management/renderer.php b/theme/bootstrapbase/renderers/core_course/management/renderer.php similarity index 100% rename from theme/bootstrapbase/classes/output/core_course/management/renderer.php rename to theme/bootstrapbase/renderers/core_course/management/renderer.php diff --git a/theme/bootstrapbase/classes/output/core_question/bank_renderer.php b/theme/bootstrapbase/renderers/core_question/bank_renderer.php similarity index 95% rename from theme/bootstrapbase/classes/output/core_question/bank_renderer.php rename to theme/bootstrapbase/renderers/core_question/bank_renderer.php index 2e191cbcc4e4a..11338bf939fcd 100644 --- a/theme/bootstrapbase/classes/output/core_question/bank_renderer.php +++ b/theme/bootstrapbase/renderers/core_question/bank_renderer.php @@ -25,7 +25,7 @@ namespace theme_bootstrapbase\output\core_question; defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot . '/' . $CFG->admin . '/renderer.php'); +require_once($CFG->dirroot . '/question/renderer.php'); /** * Question renderer class. diff --git a/theme/bootstrapbase/renderers/core_renderer.php b/theme/bootstrapbase/renderers/core_renderer.php index 9e009d8397a4c..83d6ed28906df 100644 --- a/theme/bootstrapbase/renderers/core_renderer.php +++ b/theme/bootstrapbase/renderers/core_renderer.php @@ -41,8 +41,8 @@ public function standard_head_html() { // Setup help icon overlays. $this->page->requires->yui_module('moodle-core-popuphelp', 'M.core.init_popuphelp'); $this->page->requires->strings_for_js(array( - 'morehelp', - 'loadinghelp', + 'morehelp', + 'loadinghelp', ), 'moodle'); if ($PAGE->pagelayout == 'frontpage') { @@ -605,4 +605,4 @@ protected function render_single_button(single_button $button) { * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class theme_bootstrapbase_core_renderer_maintenance extends core_renderer_maintenance { -} +} \ No newline at end of file diff --git a/theme/bootstrapbase/classes/output/gradereport_history_renderer.php b/theme/bootstrapbase/renderers/gradereport_history_renderer.php similarity index 100% rename from theme/bootstrapbase/classes/output/gradereport_history_renderer.php rename to theme/bootstrapbase/renderers/gradereport_history_renderer.php diff --git a/theme/bootstrapbase/tests/behat/behat_theme_bootstrapbase_behat_course.php b/theme/bootstrapbase/tests/behat/behat_theme_bootstrapbase_behat_course.php index 9191059fa4af0..595d3f6365224 100644 --- a/theme/bootstrapbase/tests/behat/behat_theme_bootstrapbase_behat_course.php +++ b/theme/bootstrapbase/tests/behat/behat_theme_bootstrapbase_behat_course.php @@ -258,7 +258,7 @@ protected function is_course_editor() { public function i_navigate_to_course_participants() { $coursestr = behat_context_helper::escape(get_string('courses')); $mycoursestr = behat_context_helper::escape(get_string('mycourses')); - $xpath = "//section[contains(@class,'block')]//li[p/*[string(.)=$coursestr or string(.)=$mycoursestr]]"; + $xpath = "//div[contains(@class,'block')]//li[p/*[string(.)=$coursestr or string(.)=$mycoursestr]]"; $this->execute('behat_general::i_click_on_in_the', [get_string('participants'), 'link', $xpath, 'xpath_element']); } } diff --git a/theme/bootstrapbase/tests/behat/behat_theme_bootstrapbase_behat_navigation.php b/theme/bootstrapbase/tests/behat/behat_theme_bootstrapbase_behat_navigation.php index 30388fe4d0e8b..6e7e6a53525cf 100644 --- a/theme/bootstrapbase/tests/behat/behat_theme_bootstrapbase_behat_navigation.php +++ b/theme/bootstrapbase/tests/behat/behat_theme_bootstrapbase_behat_navigation.php @@ -96,7 +96,7 @@ protected function get_top_navigation_node($nodetext) { public function should_exist_in_current_page_administration($element, $selectortype) { $parentnodes = array_map('trim', explode('>', $element)); // Find the name of the first category of the administration block tree. - $xpath = '//section[contains(@class,\'block_settings\')]//div[@id=\'settingsnav\']/ul/li[1]/p[1]/span'; + $xpath = '//div[contains(@class,\'block_settings\')]//div[@id=\'settingsnav\']/ul/li[1]/p[1]/span'; $node = $this->find('xpath', $xpath); array_unshift($parentnodes, $node->getText()); $lastnode = array_pop($parentnodes); @@ -110,7 +110,7 @@ public function should_exist_in_current_page_administration($element, $selectort public function should_not_exist_in_current_page_administration($element, $selectortype) { $parentnodes = array_map('trim', explode('>', $element)); // Find the name of the first category of the administration block tree. - $xpath = '//section[contains(@class,\'block_settings\')]//div[@id=\'settingsnav\']/ul/li[1]/p[1]/span'; + $xpath = '//div[contains(@class,\'block_settings\')]//div[@id=\'settingsnav\']/ul/li[1]/p[1]/span'; $node = $this->find('xpath', $xpath); array_unshift($parentnodes, $node->getText()); $lastnode = array_pop($parentnodes); @@ -124,7 +124,7 @@ public function should_not_exist_in_current_page_administration($element, $selec public function i_navigate_to_in_current_page_administration($nodetext) { $parentnodes = array_map('trim', explode('>', $nodetext)); // Find the name of the first category of the administration block tree. - $xpath = '//section[contains(@class,\'block_settings\')]//div[@id=\'settingsnav\']/ul/li[1]/p[1]/span'; + $xpath = '//div[contains(@class,\'block_settings\')]//div[@id=\'settingsnav\']/ul/li[1]/p[1]/span'; $node = $this->find('xpath', $xpath); array_unshift($parentnodes, $node->getText()); $lastnode = array_pop($parentnodes);