Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 144... Línea 144...
144
            $node->press();
144
            $node->press();
145
        }
145
        }
146
    }
146
    }
Línea 147... Línea 147...
147
 
147
 
-
 
148
    /**
-
 
149
     * Gets the grade id from its grade item name and userid.
-
 
150
     *
-
 
151
     * @param int $itemid Item ID
-
 
152
     * @param int $userid User ID
-
 
153
     * @return int
-
 
154
     * @throws Exception
-
 
155
     */
-
 
156
    protected function get_grade_id(int $itemid, int $userid): int {
-
 
157
        global $DB;
-
 
158
 
-
 
159
        if ($id = $DB->get_field('grade_grades', 'id', ['itemid' => $itemid, 'userid' => $userid])) {
-
 
160
            return $id;
-
 
161
        }
-
 
162
 
-
 
163
        throw new Exception('The specified grade with id "' . $itemid . ' and userid' . $userid . '" does not exist');
-
 
164
    }
-
 
165
 
148
    /**
166
    /**
149
     * Gets the grade item id from its name.
167
     * Gets the grade item id from its name.
150
     *
168
     *
151
     * @throws Exception
169
     * @throws Exception
152
     * @param string $itemname Item name
170
     * @param string $itemname Item name
Línea 267... Línea 285...
267
        }
285
        }
268
        $node = $this->get_selected_node("xpath_element", $this->escape($xpath));
286
        $node = $this->get_selected_node("xpath_element", $this->escape($xpath));
269
        $this->execute_js_on_node($node, '{{ELEMENT}}.scrollIntoView({ block: "center", inline: "center" })');
287
        $this->execute_js_on_node($node, '{{ELEMENT}}.scrollIntoView({ block: "center", inline: "center" })');
270
        $this->execute("behat_general::i_click_on", [$this->escape($xpath), "xpath_element"]);
288
        $this->execute("behat_general::i_click_on", [$this->escape($xpath), "xpath_element"]);
271
    }
289
    }
-
 
290
 
-
 
291
    /**
-
 
292
     * Clicks on given grade menu.
-
 
293
     *
-
 
294
     * @Given /^I click on grade menu "([^"]*)" for user "([^"]*)"$/
-
 
295
     * @param string $itemname Item name
-
 
296
     * @param string $username User name
-
 
297
     * @throws Exception
-
 
298
     */
-
 
299
    public function i_click_on_grade_menu(string $itemname, string $username) {
-
 
300
        $this->execute("behat_navigation::i_close_block_drawer_if_open");
-
 
301
 
-
 
302
        $userid = $this->get_user_id_by_identifier($username);
-
 
303
        $itemid = $this->get_grade_item_id($itemname);
-
 
304
        $gradeid = $this->get_grade_id($itemid, $userid);
-
 
305
 
-
 
306
        $xpath = "//table[@id='user-grades']";
-
 
307
        $xpath .= "//*[@data-type='grade'][@data-id='" . $gradeid . "']";
-
 
308
        $node = $this->get_selected_node("xpath_element", $this->escape($xpath));
-
 
309
        $this->execute_js_on_node($node, '{{ELEMENT}}.scrollIntoView({ block: "center", inline: "center" })');
-
 
310
        $this->execute("behat_general::i_click_on", [$this->escape($xpath), "xpath_element"]);
-
 
311
    }
-
 
312
 
272
}
313
}