public static function get_questions($surveyid) {
        global $DB, $USER;

        $params = self::validate_parameters(self::get_questions_parameters(),
                                            array(
                                                'surveyid' => $surveyid
                                            ));
        $warnings = array();

        // Request and permission validation.
        $survey = $DB->get_record('survey', array('id' => $params['surveyid']), '*', MUST_EXIST);
        list($course, $cm) = get_course_and_cm_from_instance($survey, 'survey');

        $context = context_module::instance($cm->id);
        self::validate_context($context);
        require_capability('mod/survey:participate', $context);

        $mainquestions = survey_get_questions($survey);

        foreach ($mainquestions as $question) {
            if ($question->type >= 0) {
                // Parent is used in subquestions.
                $question->parent = 0;
                $questions[] = survey_translate_question($question);

                // Check if the question has subquestions.
                if ($question->multi) {
                    $subquestions = survey_get_subquestions($question);
                    foreach ($subquestions as $sq) {
                        $sq->parent = $question->id;
                        $questions[] = survey_translate_question($sq);
                    }
                }
            }
        }

        $result = array();
        $result['questions'] = $questions;
        $result['warnings'] = $warnings;
        return $result;
    }
public static function get_questions($surveyid) {
        global $DB, $USER;

        $params = self::validate_parameters(self::get_questions_parameters(),
                                            array(
                                                'surveyid' => $surveyid
                                            ));
        $warnings = array();

        // Request and permission validation.
        $survey = $DB->get_record('survey', array('id' => $params['surveyid']), '*', MUST_EXIST);
        list($course, $cm) = get_course_and_cm_from_instance($survey, 'survey');

        $context = context_module::instance($cm->id);
        self::validate_context($context);
        require_capability('mod/survey:participate', $context);

        $mainquestions = survey_get_questions($survey);

        foreach ($mainquestions as $question) {
            if ($question->type >= 0) {
                // Parent is used in subquestions.
                $question->parent = 0;
                $questions[] = survey_translate_question($question);

                // Check if the question has subquestions.
                if ($question->multi) {
                    $subquestions = survey_get_subquestions($question);
                    foreach ($subquestions as $sq) {
                        $sq->parent = $question->id;
                        $questions[] = survey_translate_question($sq);
                    }
                }
            }
        }

        $result = array();
        $result['questions'] = $questions;
        $result['warnings'] = $warnings;
        return $result;
    }
public static function get_questions ( $ surveyid ) { global $ DB , $ USER ; $ params = self :: validate_parameters ( self :: get_questions_parameters ( ) , array ( 'surveyid' => $ surveyid ) ) ; $ warnings = array ( ) ; // Request and permission validation. $ survey = $ DB -> get_record ( 'survey' , array ( 'id' => $ params [ 'surveyid' ] ) , '*' , MUST_EXIST ) ; list ( $ course , $ cm ) = get_course_and_cm_from_instance ( $ survey , 'survey' ) ; $ context = context_module :: instance ( $ cm -> id ) ; self :: validate_context ( $ context ) ; require_capability ( 'mod/survey:participate' , $ context ) ; $ mainquestions = survey_get_questions ( $ survey ) ; foreach ( $ mainquestions as $ question ) { if ( $ question -> type >= 0 ) { // Parent is used in subquestions. $ question -> parent = 0 ; $ questions [ ] = survey_translate_question ( $ question ) ; // Check if the question has subquestions. if ( $ question -> multi ) { $ subquestions = survey_get_subquestions ( $ question ) ; foreach ( $ subquestions as $ sq ) { $ sq -> parent = $ question -> id ; $ questions [ ] = survey_translate_question ( $ sq ) ; } } } } $ result = array ( ) ; $ result [ 'questions' ] = $ questions ; $ result [ 'warnings' ] = $ warnings ; return $ result ; }
Get the complete list of questions for the survey, including subquestions.

@param int $surveyid the survey instance id
@return array of warnings and the question list
@since Moodle 3.0
@throws moodle_exception
Get the complete list of questions for the survey including subquestions .