public static function get_feedbacks_by_courses($courseids = array()) {
        global $PAGE;

        $warnings = array();
        $returnedfeedbacks = array();

        $params = array(
            'courseids' => $courseids,
        );
        $params = self::validate_parameters(self::get_feedbacks_by_courses_parameters(), $params);

        $mycourses = array();
        if (empty($params['courseids'])) {
            $mycourses = enrol_get_my_courses();
            $params['courseids'] = array_keys($mycourses);
        }

        // Ensure there are courseids to loop through.
        if (!empty($params['courseids'])) {

            list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);
            $output = $PAGE->get_renderer('core');

            // Get the feedbacks in this course, this function checks users visibility permissions.
            // We can avoid then additional validate_context calls.
            $feedbacks = get_all_instances_in_courses("feedback", $courses);
            foreach ($feedbacks as $feedback) {

                $context = context_module::instance($feedback->coursemodule);

                // Remove fields that are not from the feedback (added by get_all_instances_in_courses).
                unset($feedback->coursemodule, $feedback->context, $feedback->visible, $feedback->section, $feedback->groupmode,
                        $feedback->groupingid);

                // Check permissions.
                if (!has_capability('mod/feedback:edititems', $context)) {
                    // Don't return the optional properties.
                    $properties = feedback_summary_exporter::properties_definition();
                    foreach ($properties as $property => $config) {
                        if (!empty($config['optional'])) {
                            unset($feedback->{$property});
                        }
                    }
                }
                $exporter = new feedback_summary_exporter($feedback, array('context' => $context));
                $returnedfeedbacks[] = $exporter->export($output);
            }
        }

        $result = array(
            'feedbacks' => $returnedfeedbacks,
            'warnings' => $warnings
        );
        return $result;
    }
public static function get_feedbacks_by_courses($courseids = array()) {
        global $PAGE;

        $warnings = array();
        $returnedfeedbacks = array();

        $params = array(
            'courseids' => $courseids,
        );
        $params = self::validate_parameters(self::get_feedbacks_by_courses_parameters(), $params);

        $mycourses = array();
        if (empty($params['courseids'])) {
            $mycourses = enrol_get_my_courses();
            $params['courseids'] = array_keys($mycourses);
        }

        // Ensure there are courseids to loop through.
        if (!empty($params['courseids'])) {

            list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);
            $output = $PAGE->get_renderer('core');

            // Get the feedbacks in this course, this function checks users visibility permissions.
            // We can avoid then additional validate_context calls.
            $feedbacks = get_all_instances_in_courses("feedback", $courses);
            foreach ($feedbacks as $feedback) {

                $context = context_module::instance($feedback->coursemodule);

                // Remove fields that are not from the feedback (added by get_all_instances_in_courses).
                unset($feedback->coursemodule, $feedback->context, $feedback->visible, $feedback->section, $feedback->groupmode,
                        $feedback->groupingid);

                // Check permissions.
                if (!has_capability('mod/feedback:edititems', $context)) {
                    // Don't return the optional properties.
                    $properties = feedback_summary_exporter::properties_definition();
                    foreach ($properties as $property => $config) {
                        if (!empty($config['optional'])) {
                            unset($feedback->{$property});
                        }
                    }
                }
                $exporter = new feedback_summary_exporter($feedback, array('context' => $context));
                $returnedfeedbacks[] = $exporter->export($output);
            }
        }

        $result = array(
            'feedbacks' => $returnedfeedbacks,
            'warnings' => $warnings
        );
        return $result;
    }
public static function get_feedbacks_by_courses ( $ courseids = array ( ) ) { global $ PAGE ; $ warnings = array ( ) ; $ returnedfeedbacks = array ( ) ; $ params = array ( 'courseids' => $ courseids , ) ; $ params = self :: validate_parameters ( self :: get_feedbacks_by_courses_parameters ( ) , $ params ) ; $ mycourses = array ( ) ; if ( empty ( $ params [ 'courseids' ] ) ) { $ mycourses = enrol_get_my_courses ( ) ; $ params [ 'courseids' ] = array_keys ( $ mycourses ) ; } // Ensure there are courseids to loop through. if ( ! empty ( $ params [ 'courseids' ] ) ) { list ( $ courses , $ warnings ) = external_util :: validate_courses ( $ params [ 'courseids' ] , $ mycourses ) ; $ output = $ PAGE -> get_renderer ( 'core' ) ; // Get the feedbacks in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $ feedbacks = get_all_instances_in_courses ( "feedback" , $ courses ) ; foreach ( $ feedbacks as $ feedback ) { $ context = context_module :: instance ( $ feedback -> coursemodule ) ; // Remove fields that are not from the feedback (added by get_all_instances_in_courses). unset ( $ feedback -> coursemodule , $ feedback -> context , $ feedback -> visible , $ feedback -> section , $ feedback -> groupmode , $ feedback -> groupingid ) ; // Check permissions. if ( ! has_capability ( 'mod/feedback:edititems' , $ context ) ) { // Don't return the optional properties. $ properties = feedback_summary_exporter :: properties_definition ( ) ; foreach ( $ properties as $ property => $ config ) { if ( ! empty ( $ config [ 'optional' ] ) ) { unset ( $ feedback -> { $ property } ) ; } } } $ exporter = new feedback_summary_exporter ( $ feedback , array ( 'context' => $ context ) ) ; $ returnedfeedbacks [ ] = $ exporter -> export ( $ output ) ; } } $ result = array ( 'feedbacks' => $ returnedfeedbacks , 'warnings' => $ warnings ) ; return $ result ; }
Returns a list of feedbacks in a provided list of courses.
If no list is provided all feedbacks that the user can view will be returned.

@param array $courseids course ids
@return array of warnings and feedbacks
@since Moodle 3.3
Returns a list of feedbacks in a provided list of courses . If no list is provided all feedbacks that the user can view will be returned .