mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
Merge branch 'MDL-41091' of git://github.com/timhunt/moodle
This commit is contained in:
commit
defb89c30c
@ -1011,7 +1011,7 @@ class question_attempt {
|
||||
* that it is valid or cleaning it in any way.
|
||||
* @return array name => value.
|
||||
*/
|
||||
protected function get_all_submitted_qt_vars($postdata) {
|
||||
public function get_all_submitted_qt_vars($postdata) {
|
||||
if (is_null($postdata)) {
|
||||
$postdata = $_POST;
|
||||
}
|
||||
@ -1020,7 +1020,7 @@ class question_attempt {
|
||||
$prefixlen = strlen($this->get_field_prefix());
|
||||
|
||||
$submitteddata = array();
|
||||
foreach ($_POST as $name => $value) {
|
||||
foreach ($postdata as $name => $value) {
|
||||
if (preg_match($pattern, $name)) {
|
||||
$submitteddata[substr($name, $prefixlen)] = $value;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ require_once(dirname(__FILE__) . '/helpers.php');
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class question_attempt_test extends advanced_testcase {
|
||||
class question_attempt_testcase extends advanced_testcase {
|
||||
private $question;
|
||||
private $usageid;
|
||||
private $qa;
|
||||
@ -138,4 +138,15 @@ class question_attempt_test extends advanced_testcase {
|
||||
$this->assertSame(0.0, $this->qa->get_submitted_var(
|
||||
'name', question_attempt::PARAM_MARK, array('name' => 'frog')));
|
||||
}
|
||||
|
||||
public function test_get_all_submitted_qt_vars() {
|
||||
$this->qa->set_usage_id('MDOgzdhS4W');
|
||||
$this->qa->set_slot(1);
|
||||
$this->assertEquals(array('omval_response1' => 1, 'omval_response2' => 666, 'omact_gen_14' => 'Check'),
|
||||
$this->qa->get_all_submitted_qt_vars(array(
|
||||
'qMDOgzdhS4W:1_omval_response1' => 1,
|
||||
'qMDOgzdhS4W:1_omval_response2' => 666,
|
||||
'qMDOgzdhS4W:1_omact_gen_14' => 'Check',
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user