Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
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 * Steps definitions related to mod_workshop. 19 * 20 * @package mod_workshop 21 * @category test 22 * @copyright 2014 Marina Glancy 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 * Steps definitions related to mod_workshop. 34 * 35 * @package mod_workshop 36 * @category test 37 * @copyright 2014 Marina Glancy 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 class behat_mod_workshop extends behat_base { 41 /** 42 * Changes the submission phase for the workshop. 43 * 44 * @When /^I change phase in workshop "(?P<workshop_name_string>(?:[^"]|\\")*)" to "(?P<phase_name_string>(?:[^"]|\\")*)"$/ 45 * @param string $questiontype 46 * @param string $workshopname 47 */ 48 public function i_change_phase_in_workshop_to($workshopname, $phase) { 49 $workshopname = $this->escape($workshopname); 50 $phaseliteral = behat_context_helper::escape($phase); 51 52 $xpath = "//*[@class='userplan']/descendant::div[./span[contains(.,$phaseliteral)]]"; 53 $continue = $this->escape(get_string('continue')); 54 55 $this->execute("behat_general::i_click_on_in_the", [$this->escape($workshopname), 'link', 'page', 'region']); 56 57 $this->execute('behat_general::i_click_on_in_the', 58 array('a.action-icon', "css_element", $this->escape($xpath), "xpath_element") 59 ); 60 61 $this->execute("behat_forms::press_button", $continue); 62 } 63 64 /** 65 * Adds or edits a student workshop submission. 66 * 67 * @When /^I add a submission in workshop "(?P<workshop_name_string>(?:[^"]|\\")*)" as:$/ 68 * @When /^I add a submission in workshop "(?P<workshop_name_string>(?:[^"]|\\")*)" as:"$/ 69 * @param string $workshopname 70 * @param TableNode $table data to fill the submission form with, must contain 'Title' 71 */ 72 public function i_add_a_submission_in_workshop_as($workshopname, $table) { 73 $workshopname = $this->escape($workshopname); 74 $savechanges = $this->escape(get_string('savechanges')); 75 $xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' ownsubmission ')]/descendant::*[@type='submit']"; 76 77 $this->execute("behat_navigation::i_am_on_page_instance", [$this->escape($workshopname), 'workshop activity']); 78 79 $this->execute("behat_general::i_click_on", array($xpath, "xpath_element")); 80 81 $this->execute("behat_forms::i_set_the_following_fields_to_these_values", $table); 82 83 $this->execute("behat_forms::press_button", $savechanges); 84 } 85 86 /** 87 * Sets the workshop assessment form. 88 * 89 * @When /^I edit assessment form in workshop "(?P<workshop_name_string>(?:[^"]|\\")*)" as:$/ 90 * @When /^I edit assessment form in workshop "(?P<workshop_name_string>(?:[^"]|\\")*)" as:"$/ 91 * @param string $workshopname 92 * @param TableNode $table data to fill the submission form with, must contain 'Title' 93 */ 94 public function i_edit_assessment_form_in_workshop_as($workshopname, $table) { 95 $this->execute("behat_navigation::i_am_on_page_instance", [$this->escape($workshopname), 'workshop activity']); 96 97 $this->execute('behat_navigation::i_navigate_to_in_current_page_administration', 98 get_string('editassessmentform', 'workshop')); 99 100 $this->execute("behat_forms::i_set_the_following_fields_to_these_values", $table); 101 102 $this->execute("behat_forms::press_button", get_string('saveandclose', 'workshop')); 103 } 104 105 /** 106 * Peer-assesses a workshop submission. 107 * 108 * @When /^I assess submission "(?P<submission_string>(?:[^"]|\\")*)" in workshop "(?P<workshop_name_string>(?:[^"]|\\")*)" as:$/ 109 * @When /^I assess submission "(?P<submission_string>(?:[^"]|\\")*)" in workshop "(?P<workshop_name_string>(?:[^"]|\\")*)" as:"$/ 110 * @param string $submission 111 * @param string $workshopname 112 * @param TableNode $table 113 */ 114 public function i_assess_submission_in_workshop_as($submission, $workshopname, TableNode $table) { 115 $workshopname = $this->escape($workshopname); 116 $submissionliteral = behat_context_helper::escape($submission); 117 $xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' assessment-summary ') ". 118 "and contains(.,$submissionliteral)]"; 119 $assess = $this->escape(get_string('assess', 'workshop')); 120 $saveandclose = $this->escape(get_string('saveandclose', 'workshop')); 121 122 $this->execute("behat_navigation::i_am_on_page_instance", [$workshopname, 'workshop activity']); 123 124 $this->execute('behat_general::i_click_on_in_the', 125 array($assess, "button", $xpath, "xpath_element") 126 ); 127 128 $this->execute("behat_forms::i_set_the_following_fields_to_these_values", $table); 129 130 $this->execute("behat_forms::press_button", $saveandclose); 131 } 132 133 /** 134 * Checks that the user has particular grade set by his reviewing peer in workshop 135 * 136 * @Then /^I should see grade "(?P<grade_string>[^"]*)" for workshop participant "(?P<participant_name_string>(?:[^"]|\\")*)" set by peer "(?P<reviewer_name_string>(?:[^"]|\\")*)"$/ 137 * @param string $grade 138 * @param string $participant 139 * @param string $reviewer 140 */ 141 public function i_should_see_grade_for_workshop_participant_set_by_peer($grade, $participant, $reviewer) { 142 $participantliteral = behat_context_helper::escape($participant); 143 $reviewerliteral = behat_context_helper::escape($reviewer); 144 $gradeliteral = behat_context_helper::escape($grade); 145 $participantselector = "contains(concat(' ', normalize-space(@class), ' '), ' participant ') ". 146 "and contains(.,$participantliteral)"; 147 $trxpath = "//table/tbody/tr[td[$participantselector]]"; 148 $tdparticipantxpath = "//table/tbody/tr/td[$participantselector]"; 149 $tdxpath = "/td[contains(concat(' ', normalize-space(@class), ' '), ' receivedgrade ') and contains(.,$reviewerliteral)]/". 150 "descendant::span[contains(concat(' ', normalize-space(@class), ' '), ' grade ') and .=$gradeliteral]"; 151 152 $tr = $this->find('xpath', $trxpath); 153 $rowspan = $this->find('xpath', $tdparticipantxpath)->getAttribute('rowspan'); 154 155 $xpath = $trxpath.$tdxpath; 156 if (!empty($rowspan)) { 157 for ($i = 1; $i < $rowspan; $i++) { 158 $xpath .= ' | '.$trxpath."/following-sibling::tr[$i]".$tdxpath; 159 } 160 } 161 $this->find('xpath', $xpath); 162 } 163 164 /** 165 * Configure portfolio plugin, set value for portfolio instance 166 * 167 * @When /^I set portfolio instance "(?P<portfolioinstance_string>(?:[^"]|\\")*)" to "(?P<value_string>(?:[^"]|\\")*)"$/ 168 * @param string $portfolioinstance 169 * @param string $value 170 */ 171 public function i_set_portfolio_instance_to($portfolioinstance, $value) { 172 173 $rowxpath = "//table[contains(@class, 'generaltable')]//tr//td[contains(text(), '" 174 . $portfolioinstance . "')]/following-sibling::td"; 175 176 $selectxpath = $rowxpath.'//select'; 177 $select = $this->find('xpath', $selectxpath); 178 $select->selectOption($value); 179 180 if (!$this->running_javascript()) { 181 $this->execute('behat_general::i_click_on_in_the', 182 array(get_string('go'), "button", $rowxpath, "xpath_element") 183 ); 184 } 185 } 186 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body