mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'MDL-53976-master' of git://github.com/jleyva/moodle
This commit is contained in:
commit
128beb3d39
@ -1389,6 +1389,14 @@ class mod_quiz_external extends external_api {
|
||||
array(
|
||||
'attemptid' => new external_value(PARAM_INT, 'attempt id'),
|
||||
'page' => new external_value(PARAM_INT, 'page number'),
|
||||
'preflightdata' => new external_multiple_structure(
|
||||
new external_single_structure(
|
||||
array(
|
||||
'name' => new external_value(PARAM_ALPHANUMEXT, 'data name'),
|
||||
'value' => new external_value(PARAM_RAW, 'data value'),
|
||||
)
|
||||
), 'Preflight required data (like passwords)', VALUE_DEFAULT, array()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -1398,16 +1406,18 @@ class mod_quiz_external extends external_api {
|
||||
*
|
||||
* @param int $attemptid attempt id
|
||||
* @param int $page page number
|
||||
* @param array $preflightdata preflight required data (like passwords)
|
||||
* @return array of warnings and status result
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
public static function view_attempt($attemptid, $page) {
|
||||
public static function view_attempt($attemptid, $page, $preflightdata = array()) {
|
||||
|
||||
$warnings = array();
|
||||
|
||||
$params = array(
|
||||
'attemptid' => $attemptid,
|
||||
'page' => $page,
|
||||
'preflightdata' => $preflightdata,
|
||||
);
|
||||
$params = self::validate_parameters(self::view_attempt_parameters(), $params);
|
||||
list($attemptobj, $messages) = self::validate_attempt($params);
|
||||
@ -1451,6 +1461,14 @@ class mod_quiz_external extends external_api {
|
||||
return new external_function_parameters (
|
||||
array(
|
||||
'attemptid' => new external_value(PARAM_INT, 'attempt id'),
|
||||
'preflightdata' => new external_multiple_structure(
|
||||
new external_single_structure(
|
||||
array(
|
||||
'name' => new external_value(PARAM_ALPHANUMEXT, 'data name'),
|
||||
'value' => new external_value(PARAM_RAW, 'data value'),
|
||||
)
|
||||
), 'Preflight required data (like passwords)', VALUE_DEFAULT, array()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -1459,15 +1477,17 @@ class mod_quiz_external extends external_api {
|
||||
* Trigger the attempt summary viewed event.
|
||||
*
|
||||
* @param int $attemptid attempt id
|
||||
* @param array $preflightdata preflight required data (like passwords)
|
||||
* @return array of warnings and status result
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
public static function view_attempt_summary($attemptid) {
|
||||
public static function view_attempt_summary($attemptid, $preflightdata = array()) {
|
||||
|
||||
$warnings = array();
|
||||
|
||||
$params = array(
|
||||
'attemptid' => $attemptid,
|
||||
'preflightdata' => $preflightdata,
|
||||
);
|
||||
$params = self::validate_parameters(self::view_attempt_summary_parameters(), $params);
|
||||
list($attemptobj, $messages) = self::validate_attempt($params);
|
||||
|
@ -1278,8 +1278,12 @@ class mod_quiz_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
// Now, force the quiz with QUIZ_NAVMETHOD_SEQ (sequencial) navigation method.
|
||||
$DB->set_field('quiz', 'navmethod', QUIZ_NAVMETHOD_SEQ, array('id' => $quiz->id));
|
||||
// Quiz requiring preflightdata.
|
||||
$DB->set_field('quiz', 'password', 'abcdef', array('id' => $quiz->id));
|
||||
$preflightdata = array(array("name" => "quizpassword", "value" => 'abcdef'));
|
||||
|
||||
// See next page.
|
||||
$result = mod_quiz_external::view_attempt($attempt->id, 1);
|
||||
$result = mod_quiz_external::view_attempt($attempt->id, 1, $preflightdata);
|
||||
$result = external_api::clean_returnvalue(mod_quiz_external::view_attempt_returns(), $result);
|
||||
$this->assertTrue($result['status']);
|
||||
|
||||
@ -1311,7 +1315,7 @@ class mod_quiz_external_testcase extends externallib_advanced_testcase {
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
|
||||
$result = mod_quiz_external::view_attempt_summary($attempt->id, 0);
|
||||
$result = mod_quiz_external::view_attempt_summary($attempt->id);
|
||||
$result = external_api::clean_returnvalue(mod_quiz_external::view_attempt_summary_returns(), $result);
|
||||
$this->assertTrue($result['status']);
|
||||
|
||||
@ -1327,6 +1331,14 @@ class mod_quiz_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Quiz requiring preflightdata.
|
||||
$DB->set_field('quiz', 'password', 'abcdef', array('id' => $quiz->id));
|
||||
$preflightdata = array(array("name" => "quizpassword", "value" => 'abcdef'));
|
||||
|
||||
$result = mod_quiz_external::view_attempt_summary($attempt->id, $preflightdata);
|
||||
$result = external_api::clean_returnvalue(mod_quiz_external::view_attempt_summary_returns(), $result);
|
||||
$this->assertTrue($result['status']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user