mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
MDL-53976 mod_quiz: Add missing parameter preflightdata in WS
External functions view_attempt and view_attempt_summary are missing the parameter preflightdata
This commit is contained in:
parent
3219a4535f
commit
9be3072d33
2 changed files with 36 additions and 4 deletions
|
@ -1389,6 +1389,14 @@ class mod_quiz_external extends external_api {
|
||||||
array(
|
array(
|
||||||
'attemptid' => new external_value(PARAM_INT, 'attempt id'),
|
'attemptid' => new external_value(PARAM_INT, 'attempt id'),
|
||||||
'page' => new external_value(PARAM_INT, 'page number'),
|
'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 $attemptid attempt id
|
||||||
* @param int $page page number
|
* @param int $page page number
|
||||||
|
* @param array $preflightdata preflight required data (like passwords)
|
||||||
* @return array of warnings and status result
|
* @return array of warnings and status result
|
||||||
* @since Moodle 3.1
|
* @since Moodle 3.1
|
||||||
*/
|
*/
|
||||||
public static function view_attempt($attemptid, $page) {
|
public static function view_attempt($attemptid, $page, $preflightdata = array()) {
|
||||||
|
|
||||||
$warnings = array();
|
$warnings = array();
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'attemptid' => $attemptid,
|
'attemptid' => $attemptid,
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
|
'preflightdata' => $preflightdata,
|
||||||
);
|
);
|
||||||
$params = self::validate_parameters(self::view_attempt_parameters(), $params);
|
$params = self::validate_parameters(self::view_attempt_parameters(), $params);
|
||||||
list($attemptobj, $messages) = self::validate_attempt($params);
|
list($attemptobj, $messages) = self::validate_attempt($params);
|
||||||
|
@ -1451,6 +1461,14 @@ class mod_quiz_external extends external_api {
|
||||||
return new external_function_parameters (
|
return new external_function_parameters (
|
||||||
array(
|
array(
|
||||||
'attemptid' => new external_value(PARAM_INT, 'attempt id'),
|
'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.
|
* Trigger the attempt summary viewed event.
|
||||||
*
|
*
|
||||||
* @param int $attemptid attempt id
|
* @param int $attemptid attempt id
|
||||||
|
* @param array $preflightdata preflight required data (like passwords)
|
||||||
* @return array of warnings and status result
|
* @return array of warnings and status result
|
||||||
* @since Moodle 3.1
|
* @since Moodle 3.1
|
||||||
*/
|
*/
|
||||||
public static function view_attempt_summary($attemptid) {
|
public static function view_attempt_summary($attemptid, $preflightdata = array()) {
|
||||||
|
|
||||||
$warnings = array();
|
$warnings = array();
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'attemptid' => $attemptid,
|
'attemptid' => $attemptid,
|
||||||
|
'preflightdata' => $preflightdata,
|
||||||
);
|
);
|
||||||
$params = self::validate_parameters(self::view_attempt_summary_parameters(), $params);
|
$params = self::validate_parameters(self::view_attempt_summary_parameters(), $params);
|
||||||
list($attemptobj, $messages) = self::validate_attempt($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.
|
// Now, force the quiz with QUIZ_NAVMETHOD_SEQ (sequencial) navigation method.
|
||||||
$DB->set_field('quiz', 'navmethod', QUIZ_NAVMETHOD_SEQ, array('id' => $quiz->id));
|
$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.
|
// 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);
|
$result = external_api::clean_returnvalue(mod_quiz_external::view_attempt_returns(), $result);
|
||||||
$this->assertTrue($result['status']);
|
$this->assertTrue($result['status']);
|
||||||
|
|
||||||
|
@ -1311,7 +1315,7 @@ class mod_quiz_external_testcase extends externallib_advanced_testcase {
|
||||||
// Trigger and capture the event.
|
// Trigger and capture the event.
|
||||||
$sink = $this->redirectEvents();
|
$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);
|
$result = external_api::clean_returnvalue(mod_quiz_external::view_attempt_summary_returns(), $result);
|
||||||
$this->assertTrue($result['status']);
|
$this->assertTrue($result['status']);
|
||||||
|
|
||||||
|
@ -1327,6 +1331,14 @@ class mod_quiz_external_testcase extends externallib_advanced_testcase {
|
||||||
$this->assertEventContextNotUsed($event);
|
$this->assertEventContextNotUsed($event);
|
||||||
$this->assertNotEmpty($event->get_name());
|
$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…
Add table
Add a link
Reference in a new issue