[ Index ] |
PHP Cross Reference of moodle-2.8 |
[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 Behat\Behat\Context\Step\Given as Given, 32 Behat\Behat\Context\Step\When as When; 33 34 /** 35 * Generic grading methods step definitions. 36 * 37 * @package core_grading 38 * @category test 39 * @copyright 2013 David Monllaó 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 */ 42 class behat_grading extends behat_base { 43 44 /** 45 * Goes to the selected advanced grading page. You should be in the course page when this step begins. 46 * 47 * @Given /^I go to "(?P<activity_name_string>(?:[^"]|\\")*)" advanced grading page$/ 48 * @param string $activityname 49 * @return Given[] 50 */ 51 public function i_go_to_advanced_grading_page($activityname) { 52 return array( 53 new Given('I follow "' . $this->escape($activityname) . '"'), 54 new Given('I follow "' . get_string('gradingmanagement', 'grading') . '"'), 55 ); 56 } 57 58 /** 59 * Goes to the selected advanced grading definition page. You should be in the course page when this step begins. 60 * 61 * @Given /^I go to "(?P<activity_name_string>(?:[^"]|\\")*)" advanced grading definition page$/ 62 * @param string $activityname 63 * @return Given[] 64 */ 65 public function i_go_to_advanced_grading_definition_page($activityname) { 66 67 // Transforming to literals, probably not necessary, just in case. 68 $newactionliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral(get_string("manageactionnew", "grading")); 69 $editactionliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral(get_string("manageactionedit", "grading")); 70 71 // Working both when adding and editing. 72 $definitionxpath = "//a[@class='action']" . 73 "[./descendant::*[contains(., $newactionliteral) or contains(., $editactionliteral)]]"; 74 75 return array( 76 new Given('I go to "' . $this->escape($activityname) . '" advanced grading page'), 77 new Given('I click on "' . $this->escape($definitionxpath) . '" "xpath_element"'), 78 ); 79 } 80 /** 81 * Goes to the student's advanced grading page. 82 * 83 * @Given /^I go to "(?P<user_fullname_string>(?:[^"]|\\")*)" "(?P<activity_name_string>(?:[^"]|\\")*)" activity advanced grading page$/ 84 * @param string $userfullname The user full name including firstname and lastname. 85 * @param string $activityname The activity name 86 * @return Given[] 87 */ 88 public function i_go_to_activity_advanced_grading_page($userfullname, $activityname) { 89 90 // Step to access the user grade page from the grading page. 91 $usergradetext = get_string('gradeuser', 'assign', $userfullname); 92 $gradeuserstep = new Given('I follow "' . $this->escape($usergradetext) . '"'); 93 94 // Shortcut in case we already are in the grading page. 95 $usergradetextliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($usergradetext); 96 if ($this->getSession()->getPage()->find('named', array('link', $usergradetextliteral))) { 97 return $gradeuserstep; 98 } 99 100 return array( 101 new Given('I follow "' . $this->escape($activityname) . '"'), 102 new Given('I follow "' . $this->escape(get_string('viewgrading', 'assign')) . '"'), 103 $gradeuserstep 104 ); 105 } 106 107 /** 108 * Publishes current activity grading defined form as a public template. 109 * 110 * @Given /^I publish "(?P<activity_name_string>(?:[^"]|\\")*)" grading form definition as a public template$/ 111 * @param string $activityname 112 * @return Given[] 113 */ 114 public function i_publish_grading_form_definition_as_a_public_template($activityname) { 115 116 return array( 117 new Given('I go to "' . $this->escape($activityname) . '" advanced grading page'), 118 new Given('I click on "' . $this->escape(get_string("manageactionshare", "grading")) . '" "link"'), 119 new Given('I press "' . get_string('continue') . '"') 120 ); 121 } 122 123 /** 124 * Sets a previously created grading form as the activity grading form. 125 * 126 * @Given /^I set "(?P<activity_name_string>(?:[^"]|\\")*)" activity to use "(?P<grading_form_template_string>(?:[^"]|\\")*)" grading form$/ 127 * @param string $activityname 128 * @param string $templatename 129 * @return Given[] 130 */ 131 public function i_set_activity_to_use_grading_form($activityname, $templatename) { 132 133 $templateliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($templatename); 134 135 $templatexpath = "//h2[@class='template-name'][contains(., $templateliteral)]/" . 136 "following-sibling::div[contains(concat(' ', normalize-space(@class), ' '), ' template-actions ')]"; 137 138 // Should work with both templates and own forms. 139 $literaltemplate = $this->getSession()->getSelectorsHandler()->xpathLiteral(get_string('templatepick', 'grading')); 140 $literalownform = $this->getSession()->getSelectorsHandler()->xpathLiteral(get_string('templatepickownform', 'grading')); 141 $usetemplatexpath = "/a[./descendant::div[text()=$literaltemplate]]|" . 142 "/a[./descendant::div[text()=$literalownform]]"; 143 144 return array( 145 new Given('I go to "' . $this->escape($activityname) . '" advanced grading page'), 146 new Given('I follow "' . $this->escape(get_string('manageactionclone', 'grading')) . '"'), 147 new Given('I set the field "' . get_string('searchownforms', 'grading') . '" to "1"'), 148 new Given('I click on "' . get_string('search') . '" "button" in the "region-main" "region"'), 149 new Given('I click on "' . $this->escape($usetemplatexpath) . '" "xpath_element" ' . 150 'in the "' . $this->escape($templatexpath) . '" "xpath_element"'), 151 new Given('I press "' . get_string('continue') . '"') 152 ); 153 } 154 155 /** 156 * Saves the current page advanced grading form. 157 * 158 * @When /^I save the advanced grading form$/ 159 * @return When[] 160 */ 161 public function i_save_the_advanced_grading_form() { 162 return array( 163 new When('I press "' . get_string('savechanges') . '"'), 164 new When('I press "' . get_string('continue') . '"') 165 ); 166 } 167 168 /** 169 * Grades an activity using advanced grading. Note the grade is set by other steps, depending on the grading method. 170 * 171 * @Given /^I complete the advanced grading form with these values:$/ 172 * @param TableNode $data 173 * @return Given[] 174 */ 175 public function i_complete_the_advanced_grading_form_with_these_values(TableNode $data) { 176 return array( 177 new Given('I set the following fields to these values:', $data), 178 new Given('I save the advanced grading form') 179 ); 180 } 181 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |