[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Grading methods steps definitions. 19 * 20 * @package core_grading 21 * @category test 22 * @copyright 2013 David Monllaó 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. 27 28 require_once (__DIR__ . '/../../../../lib/behat/behat_base.php'); 29 30 use Behat\Gherkin\Node\TableNode as TableNode; 31 32 /** 33 * Generic grading methods step definitions. 34 * 35 * @package core_grading 36 * @category test 37 * @copyright 2013 David Monllaó 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 class behat_grading extends behat_base { 41 42 /** 43 * Goes to the selected advanced grading page. You should be in the course page when this step begins. 44 * 45 * @Given /^I go to "(?P<activity_name_string>(?:[^"]|\\")*)" advanced grading page$/ 46 * @param string $activityname 47 */ 48 public function i_go_to_advanced_grading_page($activityname) { 49 50 $this->execute('behat_general::click_link', $this->escape($activityname)); 51 52 $this->execute('behat_general::click_link', get_string('gradingmanagement', 'grading')); 53 } 54 55 /** 56 * Goes to the selected advanced grading definition page. You should be in the course page when this step begins. 57 * 58 * @Given /^I go to "(?P<activity_name_string>(?:[^"]|\\")*)" advanced grading definition page$/ 59 * @param string $activityname 60 */ 61 public function i_go_to_advanced_grading_definition_page($activityname) { 62 63 // Transforming to literals, probably not necessary, just in case. 64 $newactionliteral = behat_context_helper::escape(get_string("manageactionnew", "grading")); 65 $editactionliteral = behat_context_helper::escape(get_string("manageactionedit", "grading")); 66 67 // Working both when adding and editing. 68 $definitionxpath = "//a[@class='action']" . 69 "[./descendant::*[contains(., $newactionliteral) or contains(., $editactionliteral)]]"; 70 71 $this->execute('behat_grading::i_go_to_advanced_grading_page', $this->escape($activityname)); 72 73 $this->execute("behat_general::i_click_on", array($this->escape($definitionxpath), "xpath_element")); 74 } 75 /** 76 * Goes to the student's advanced grading page. 77 * 78 * @Given /^I go to "(?P<user_fullname_string>(?:[^"]|\\")*)" "(?P<activity_name_string>(?:[^"]|\\")*)" activity advanced grading page$/ 79 * @param string $userfullname The user full name including firstname and lastname. 80 * @param string $activityname The activity name 81 */ 82 public function i_go_to_activity_advanced_grading_page($userfullname, $activityname) { 83 84 // Step to access the user grade page from the grading page. 85 $gradetext = get_string('grade'); 86 87 $this->execute('behat_general::click_link', $this->escape($activityname)); 88 89 $this->execute('behat_general::click_link', $this->escape(get_string('viewgrading', 'assign'))); 90 91 $this->execute('behat_general::i_click_on_in_the', 92 array( 93 $this->escape($gradetext), 94 'link', 95 $this->escape($userfullname), 96 'table_row' 97 )); 98 } 99 100 /** 101 * Publishes current activity grading defined form as a public template. 102 * 103 * @Given /^I publish "(?P<activity_name_string>(?:[^"]|\\")*)" grading form definition as a public template$/ 104 * @param string $activityname 105 */ 106 public function i_publish_grading_form_definition_as_a_public_template($activityname) { 107 108 $this->execute('behat_grading::i_go_to_advanced_grading_page', $this->escape($activityname)); 109 110 $this->execute("behat_general::i_click_on", array($this->escape(get_string("manageactionshare", "grading")), "link")); 111 112 $this->execute('behat_forms::press_button', get_string('continue')); 113 } 114 115 /** 116 * Sets a previously created grading form as the activity grading form. 117 * 118 * @Given /^I set "(?P<activity_name_string>(?:[^"]|\\")*)" activity to use "(?P<grading_form_template_string>(?:[^"]|\\")*)" grading form$/ 119 * @param string $activityname 120 * @param string $templatename 121 */ 122 public function i_set_activity_to_use_grading_form($activityname, $templatename) { 123 124 $templateliteral = behat_context_helper::escape($templatename); 125 126 $templatexpath = "//h2[@class='template-name'][contains(., $templateliteral)]/" . 127 "following-sibling::div[contains(concat(' ', normalize-space(@class), ' '), ' template-actions ')]"; 128 129 // Should work with both templates and own forms. 130 $literaltemplate = behat_context_helper::escape(get_string('templatepick', 'grading')); 131 $literalownform = behat_context_helper::escape(get_string('templatepickownform', 'grading')); 132 $usetemplatexpath = "/a[./descendant::div[text()=$literaltemplate]]|" . 133 "/a[./descendant::div[text()=$literalownform]]"; 134 135 $this->execute('behat_grading::i_go_to_advanced_grading_page', $this->escape($activityname)); 136 137 $this->execute('behat_general::click_link', $this->escape(get_string('manageactionclone', 'grading'))); 138 $this->execute('behat_forms::i_set_the_field_to', array(get_string('searchownforms', 'grading'), 1)); 139 $this->execute('behat_general::i_click_on_in_the', 140 array(get_string('search'), "button", "region-main", "region") 141 ); 142 $this->execute('behat_general::i_click_on_in_the', 143 array($this->escape($usetemplatexpath), "xpath_element", $this->escape($templatexpath), "xpath_element") 144 ); 145 $this->execute('behat_forms::press_button', get_string('continue')); 146 147 } 148 149 /** 150 * Saves the current page advanced grading form. 151 * 152 * @When /^I save the advanced grading form$/ 153 */ 154 public function i_save_the_advanced_grading_form() { 155 156 $this->execute('behat_forms::press_button', get_string('savechanges')); 157 $this->execute('behat_forms::press_button', 'Ok'); 158 $this->execute('behat_general::i_click_on', array($this->escape(get_string('editsettings')), 'link')); 159 $this->execute('behat_forms::press_button', get_string('cancel')); 160 $this->execute('behat_general::i_click_on', array($this->escape(get_string('viewgrading', 'mod_assign')), 'link')); 161 } 162 163 /** 164 * Grades an activity using advanced grading. Note the grade is set by other steps, depending on the grading method. 165 * 166 * @Given /^I complete the advanced grading form with these values:$/ 167 * @param TableNode $data 168 */ 169 public function i_complete_the_advanced_grading_form_with_these_values(TableNode $data) { 170 $this->execute("behat_forms::i_set_the_following_fields_to_these_values", $data); 171 $this->execute('behat_grading::i_save_the_advanced_grading_form'); 172 } 173 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |