PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / MCP / Schemas / QuizSchemas.php

QuizSchemas.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.8, at inc/MCP/Schemas/QuizSchemas.php

168 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace LearnPress\MCP\Schemas;
4
5 use LearnPress\MCP\Support\Schemas;
6
7 defined( 'ABSPATH' ) || exit;
8
9 /**
10 * Input/output schemas for quiz write tools.
11 */
12 class QuizSchemas {
13
14 /**
15 * Shared quiz writable setting schemas.
16 *
17 * @return array
18 */
19 protected static function settings(): array {
20 return array(
21 'content' => Schemas::string(),
22 'status' => Schemas::status(),
23 'duration' => Schemas::string(),
24 'passing_grade' => array(
25 'type' => 'number',
26 'minimum' => 0,
27 'maximum' => 100,
28 ),
29 'retake_count' => Schemas::integer( 0 ),
30 'instant_check' => Schemas::boolean(),
31 'negative_marking' => Schemas::boolean(),
32 'show_correct_review' => Schemas::boolean(),
33 'order' => Schemas::integer( 1 ),
34 );
35 }
36
37 /**
38 * create-quiz input.
39 *
40 * @return array
41 */
42 public static function create_input(): array {
43 $properties = array_merge(
44 array(
45 'course_id' => Schemas::id(),
46 'section_id' => Schemas::id(),
47 'title' => Schemas::string(),
48 ),
49 self::settings()
50 );
51
52 return Schemas::object( $properties, array( 'course_id', 'section_id', 'title' ) );
53 }
54
55 /**
56 * update-quiz input.
57 *
58 * @return array
59 */
60 public static function update_input(): array {
61 $properties = array_merge(
62 array(
63 'quiz_id' => Schemas::id(),
64 'title' => Schemas::string(),
65 'section_id' => Schemas::id(),
66 ),
67 self::settings()
68 );
69
70 return Schemas::object( $properties, array( 'quiz_id' ) );
71 }
72
73 /**
74 * delete-quiz input.
75 *
76 * @return array
77 */
78 public static function delete_input(): array {
79 return Schemas::object(
80 array(
81 'quiz_id' => Schemas::id(),
82 'course_id' => Schemas::id(),
83 'section_id' => Schemas::id(),
84 ),
85 array( 'quiz_id' )
86 );
87 }
88
89 /**
90 * Write output wrapped under "quiz".
91 *
92 * @return array
93 */
94 public static function write_output(): array {
95 return Schemas::object_output( 'quiz' );
96 }
97
98 /**
99 * delete-quiz output.
100 *
101 * @return array
102 */
103 public static function delete_output(): array {
104 return Schemas::object(
105 array(
106 'trashed' => Schemas::boolean(),
107 'quiz_id' => Schemas::integer(),
108 'removed_from_curriculum' => Schemas::boolean(),
109 'recovery' => array( 'type' => 'object' ),
110 ),
111 array( 'trashed', 'quiz_id' )
112 );
113 }
114
115 /**
116 * list-quizzes input (read).
117 *
118 * @return array
119 */
120 public static function list_quizzes_input(): array {
121 return array(
122 'type' => 'object',
123 'additionalProperties' => false,
124 'required' => array( 'course_id' ),
125 'properties' => array(
126 'course_id' => array(
127 'type' => 'integer',
128 'minimum' => 1,
129 ),
130 'page' => array(
131 'type' => 'integer',
132 'minimum' => 1,
133 'default' => 1,
134 ),
135 'per_page' => array(
136 'type' => 'integer',
137 'minimum' => 1,
138 'maximum' => 100,
139 'default' => 10,
140 ),
141 ),
142 );
143 }
144
145 /**
146 * Quiz list-item summary schema (read).
147 *
148 * @return array
149 */
150 public static function quiz_summary(): array {
151 return array(
152 'type' => 'object',
153 'properties' => array(
154 'quiz_id' => array( 'type' => 'integer' ),
155 'course_id' => array( 'type' => 'integer' ),
156 'section_id' => array( 'type' => 'integer' ),
157 'section_name' => array( 'type' => 'string' ),
158 'title' => array( 'type' => 'string' ),
159 'duration' => array( 'type' => 'string' ),
160 'passing_grade' => array( 'type' => 'number' ),
161 'questions_count' => array( 'type' => 'integer' ),
162 'status' => array( 'type' => 'string' ),
163 'permalink' => array( 'type' => 'string' ),
164 ),
165 );
166 }
167 }
168