public static function get_questions_attempts($lessonid, $attempt, $correct = false, $pageid = null, $userid = null) {
        global $DB, $USER;

        $params = array(
            'lessonid' => $lessonid,
            'attempt' => $attempt,
            'correct' => $correct,
            'pageid' => $pageid,
            'userid' => $userid,
        );
        $params = self::validate_parameters(self::get_questions_attempts_parameters(), $params);
        $warnings = array();

        list($lesson, $course, $cm, $context, $lessonrecord) = self::validate_lesson($params['lessonid']);

        // Default value for userid.
        if (empty($params['userid'])) {
            $params['userid'] = $USER->id;
        }

        // Extra checks so only users with permissions can view other users attempts.
        if ($USER->id != $params['userid']) {
            self::check_can_view_user_data($params['userid'], $course, $cm, $context);
        }

        $result = array();
        $result['attempts'] = $lesson->get_attempts($params['attempt'], $params['correct'], $params['pageid'], $params['userid']);
        $result['warnings'] = $warnings;
        return $result;
    }
public static function get_questions_attempts($lessonid, $attempt, $correct = false, $pageid = null, $userid = null) {
        global $DB, $USER;

        $params = array(
            'lessonid' => $lessonid,
            'attempt' => $attempt,
            'correct' => $correct,
            'pageid' => $pageid,
            'userid' => $userid,
        );
        $params = self::validate_parameters(self::get_questions_attempts_parameters(), $params);
        $warnings = array();

        list($lesson, $course, $cm, $context, $lessonrecord) = self::validate_lesson($params['lessonid']);

        // Default value for userid.
        if (empty($params['userid'])) {
            $params['userid'] = $USER->id;
        }

        // Extra checks so only users with permissions can view other users attempts.
        if ($USER->id != $params['userid']) {
            self::check_can_view_user_data($params['userid'], $course, $cm, $context);
        }

        $result = array();
        $result['attempts'] = $lesson->get_attempts($params['attempt'], $params['correct'], $params['pageid'], $params['userid']);
        $result['warnings'] = $warnings;
        return $result;
    }
public static function get_questions_attempts ( $ lessonid , $ attempt , $ correct = false , $ pageid = null , $ userid = null ) { global $ DB , $ USER ; $ params = array ( 'lessonid' => $ lessonid , 'attempt' => $ attempt , 'correct' => $ correct , 'pageid' => $ pageid , 'userid' => $ userid , ) ; $ params = self :: validate_parameters ( self :: get_questions_attempts_parameters ( ) , $ params ) ; $ warnings = array ( ) ; list ( $ lesson , $ course , $ cm , $ context , $ lessonrecord ) = self :: validate_lesson ( $ params [ 'lessonid' ] ) ; // Default value for userid. if ( empty ( $ params [ 'userid' ] ) ) { $ params [ 'userid' ] = $ USER -> id ; } // Extra checks so only users with permissions can view other users attempts. if ( $ USER -> id != $ params [ 'userid' ] ) { self :: check_can_view_user_data ( $ params [ 'userid' ] , $ course , $ cm , $ context ) ; } $ result = array ( ) ; $ result [ 'attempts' ] = $ lesson -> get_attempts ( $ params [ 'attempt' ] , $ params [ 'correct' ] , $ params [ 'pageid' ] , $ params [ 'userid' ] ) ; $ result [ 'warnings' ] = $ warnings ; return $ result ; }
Return the list of page question attempts in a given lesson.

@param int $lessonid lesson instance id
@param int $attempt the lesson attempt number
@param bool $correct only fetch correct attempts
@param int $pageid only fetch attempts at the given page
@param int $userid only fetch attempts of the given user
@return array of warnings and page attempts
@since Moodle 3.3
@throws moodle_exception
Return the list of page question attempts in a given lesson .