MDL-57820 mod_feedback: Create function to get analysis for external api
This commit is contained in:
committed by
Eloy Lafuente (stronk7)
parent
e3aced3b59
commit
ac122465e0
@@ -202,4 +202,17 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
$data[] = $CFG->recaptchapublickey;
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the analysis data ready for external functions.
|
||||
*
|
||||
* @param stdClass $item the item (question) information
|
||||
* @param int $groupid the group id to filter data (optional)
|
||||
* @param int $courseid the course id (optional)
|
||||
* @return array an array of data with non scalar types json encoded
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public function get_analysed_for_external($item, $groupid = false, $courseid = false) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,6 +274,17 @@ abstract class feedback_item_base {
|
||||
public function get_data_for_external($item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the analysis data ready for external functions.
|
||||
*
|
||||
* @param stdClass $item the item (question) information
|
||||
* @param int $groupid the group id to filter data (optional)
|
||||
* @param int $courseid the course id (optional)
|
||||
* @return array an array of data with non scalar types json encoded
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
abstract public function get_analysed_for_external($item, $groupid = false, $courseid = false);
|
||||
}
|
||||
|
||||
//a dummy class to realize pagebreaks
|
||||
@@ -347,4 +358,17 @@ class feedback_item_pagebreak extends feedback_item_base {
|
||||
);
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the analysis data ready for external functions.
|
||||
*
|
||||
* @param stdClass $item the item (question) information
|
||||
* @param int $groupid the group id to filter data (optional)
|
||||
* @param int $courseid the course id (optional)
|
||||
* @return array an array of data with non scalar types json encoded
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public function get_analysed_for_external($item, $groupid = false, $courseid = false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,4 +297,26 @@ class feedback_item_info extends feedback_item_base {
|
||||
// Return the default value (course name, category name or timestamp).
|
||||
return $this->get_current_value($item, $feedback, $feedback->course);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the analysis data ready for external functions.
|
||||
*
|
||||
* @param stdClass $item the item (question) information
|
||||
* @param int $groupid the group id to filter data (optional)
|
||||
* @param int $courseid the course id (optional)
|
||||
* @return array an array of data with non scalar types json encoded
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public function get_analysed_for_external($item, $groupid = false, $courseid = false) {
|
||||
|
||||
$externaldata = array();
|
||||
$data = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
if (is_array($data->data)) {
|
||||
foreach ($data->data as $d) {
|
||||
$externaldata[] = json_encode($d);
|
||||
}
|
||||
}
|
||||
return $externaldata;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,4 +243,17 @@ class feedback_item_label extends feedback_item_base {
|
||||
}
|
||||
public function get_printval($item, $value) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the analysis data ready for external functions.
|
||||
*
|
||||
* @param stdClass $item the item (question) information
|
||||
* @param int $groupid the group id to filter data (optional)
|
||||
* @param int $courseid the course id (optional)
|
||||
* @return array an array of data with non scalar types json encoded
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public function get_analysed_for_external($item, $groupid = false, $courseid = false) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,4 +473,26 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the analysis data ready for external functions.
|
||||
*
|
||||
* @param stdClass $item the item (question) information
|
||||
* @param int $groupid the group id to filter data (optional)
|
||||
* @param int $courseid the course id (optional)
|
||||
* @return array an array of data with non scalar types json encoded
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public function get_analysed_for_external($item, $groupid = false, $courseid = false) {
|
||||
|
||||
$externaldata = array();
|
||||
$data = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
if (!empty($data[2]) && is_array($data[2])) {
|
||||
foreach ($data[2] as $d) {
|
||||
$externaldata[] = json_encode($d);
|
||||
}
|
||||
}
|
||||
return $externaldata;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,4 +469,26 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the analysis data ready for external functions.
|
||||
*
|
||||
* @param stdClass $item the item (question) information
|
||||
* @param int $groupid the group id to filter data (optional)
|
||||
* @param int $courseid the course id (optional)
|
||||
* @return array an array of data with non scalar types json encoded
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public function get_analysed_for_external($item, $groupid = false, $courseid = false) {
|
||||
|
||||
$externaldata = array();
|
||||
$data = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
if (!empty($data[2]) && is_array($data[2])) {
|
||||
foreach ($data[2] as $d) {
|
||||
$externaldata[] = json_encode($d);
|
||||
}
|
||||
}
|
||||
return $externaldata;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,4 +306,24 @@ class feedback_item_numeric extends feedback_item_base {
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the analysis data ready for external functions.
|
||||
*
|
||||
* @param stdClass $item the item (question) information
|
||||
* @param int $groupid the group id to filter data (optional)
|
||||
* @param int $courseid the course id (optional)
|
||||
* @return array an array of data with non scalar types json encoded
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public function get_analysed_for_external($item, $groupid = false, $courseid = false) {
|
||||
|
||||
$externaldata = array();
|
||||
$data = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
if (is_array($data->data)) {
|
||||
return $data->data; // No need to json, scalar type.
|
||||
}
|
||||
return $externaldata;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,4 +196,24 @@ class feedback_item_textarea extends feedback_item_base {
|
||||
public function create_value($data) {
|
||||
return s($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the analysis data ready for external functions.
|
||||
*
|
||||
* @param stdClass $item the item (question) information
|
||||
* @param int $groupid the group id to filter data (optional)
|
||||
* @param int $courseid the course id (optional)
|
||||
* @return array an array of data with non scalar types json encoded
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public function get_analysed_for_external($item, $groupid = false, $courseid = false) {
|
||||
|
||||
$externaldata = array();
|
||||
$data = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
if (is_array($data->data)) {
|
||||
return $data->data; // No need to json, scalar type.
|
||||
}
|
||||
return $externaldata;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,4 +195,24 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
public function create_value($value) {
|
||||
return s($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the analysis data ready for external functions.
|
||||
*
|
||||
* @param stdClass $item the item (question) information
|
||||
* @param int $groupid the group id to filter data (optional)
|
||||
* @param int $courseid the course id (optional)
|
||||
* @return array an array of data with non scalar types json encoded
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public function get_analysed_for_external($item, $groupid = false, $courseid = false) {
|
||||
|
||||
$externaldata = array();
|
||||
$data = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
if (is_array($data->data)) {
|
||||
return $data->data; // No need to json, scalar type.
|
||||
}
|
||||
return $externaldata;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user