Merge branch 'MDL-58412-master' of git://github.com/jleyva/moodle
This commit is contained in:
@@ -424,7 +424,6 @@ class mod_feedback_external extends external_api {
|
||||
$warnings = array();
|
||||
|
||||
list($feedback, $course, $cm, $context) = self::validate_feedback($params['feedbackid']);
|
||||
self::validate_feedback_access($feedback, $course, $cm, $context);
|
||||
|
||||
$feedbackstructure = new mod_feedback_structure($feedback, $cm, $course->id);
|
||||
$returneditems = array();
|
||||
@@ -613,7 +612,7 @@ class mod_feedback_external extends external_api {
|
||||
'name' => new external_value(PARAM_NOTAGS, 'The response name (usually type[index]_id).'),
|
||||
'value' => new external_value(PARAM_RAW, 'The response value.'),
|
||||
)
|
||||
), 'The data to be processed.'
|
||||
), 'The data to be processed.', VALUE_DEFAULT, array()
|
||||
),
|
||||
'goprevious' => new external_value(PARAM_BOOL, 'Whether we want to jump to previous page.', VALUE_DEFAULT, false),
|
||||
)
|
||||
@@ -630,7 +629,7 @@ class mod_feedback_external extends external_api {
|
||||
* @return array of warnings and launch information
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public static function process_page($feedbackid, $page, $responses, $goprevious = false) {
|
||||
public static function process_page($feedbackid, $page, $responses = [], $goprevious = false) {
|
||||
global $USER, $SESSION;
|
||||
|
||||
$params = array('feedbackid' => $feedbackid, 'page' => $page, 'responses' => $responses, 'goprevious' => $goprevious);
|
||||
@@ -645,18 +644,24 @@ class mod_feedback_external extends external_api {
|
||||
// Create the $_POST object required by the feedback question engine.
|
||||
$_POST = array();
|
||||
foreach ($responses as $response) {
|
||||
$_POST[$response['name']] = $response['value'];
|
||||
// First check if we are handling array parameters.
|
||||
if (preg_match('/(.+)\[(.+)\]$/', $response['name'], $matches)) {
|
||||
$_POST[$matches[1]][$matches[2]] = $response['value'];
|
||||
} else {
|
||||
$_POST[$response['name']] = $response['value'];
|
||||
}
|
||||
}
|
||||
// Force fields.
|
||||
$_POST['id'] = $cm->id;
|
||||
$_POST['courseid'] = $course->id;
|
||||
$_POST['gopage'] = $params['page'];
|
||||
$_POST['_qf__mod_feedback_complete_form'] = 1;
|
||||
|
||||
// Determine where to go, backwards or forward.
|
||||
if (!$params['goprevious']) {
|
||||
$_POST['gonextpage'] = 1; // Even if we are saving values we need this set.
|
||||
if ($feedbackcompletion->get_next_page($params['page'], false) === null) {
|
||||
$_POST['savevalues'] = 1; // If there is no next page, it means we are finishing the feedback.
|
||||
} else {
|
||||
$_POST['gonextpage'] = 1; // If we are not going to previous page or finishing we are going forward.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user