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 / EnrollmentSchemas.php

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

174 lines 3.6 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 use LearnPress\MCP\Support\Validator;
7
8 defined( 'ABSPATH' ) || exit;
9
10 /**
11 * Input/output schemas for enrollment write tools.
12 */
13 class EnrollmentSchemas {
14
15 /**
16 * Enrollment status enum schema.
17 *
18 * @return array
19 */
20 protected static function status_enum(): array {
21 return array(
22 'type' => 'string',
23 'enum' => Validator::enrollment_statuses(),
24 );
25 }
26
27 /**
28 * Status enum allowed when creating a manual enrollment (active states only).
29 *
30 * @return array
31 */
32 protected static function create_status_enum(): array {
33 return array(
34 'type' => 'string',
35 'enum' => Validator::enroll_create_statuses(),
36 );
37 }
38
39 /**
40 * Graduation enum schema.
41 *
42 * @return array
43 */
44 protected static function graduation_enum(): array {
45 return array(
46 'type' => 'string',
47 'enum' => Validator::graduations(),
48 );
49 }
50
51 /**
52 * enroll-student input.
53 *
54 * @return array
55 */
56 public static function enroll_input(): array {
57 return Schemas::object(
58 array(
59 'user_id' => Schemas::id(),
60 'course_id' => Schemas::id(),
61 'status' => self::create_status_enum(),
62 'start_time' => Schemas::string(),
63 ),
64 array( 'user_id', 'course_id' )
65 );
66 }
67
68 /**
69 * update-enrollment input.
70 *
71 * @return array
72 */
73 public static function update_input(): array {
74 return Schemas::object(
75 array(
76 'enrollment_id' => Schemas::id(),
77 'user_id' => Schemas::id(),
78 'course_id' => Schemas::id(),
79 'status' => self::status_enum(),
80 'graduation' => self::graduation_enum(),
81 'start_time' => Schemas::string(),
82 'end_time' => Schemas::string(),
83 ),
84 array( 'enrollment_id' )
85 );
86 }
87
88 /**
89 * enroll-student output.
90 *
91 * @return array
92 */
93 public static function enroll_output(): array {
94 return Schemas::object(
95 array(
96 'enrollment_id' => Schemas::integer(),
97 'user_id' => Schemas::integer(),
98 'course_id' => Schemas::integer(),
99 'status' => Schemas::string(),
100 'start_time' => Schemas::string(),
101 'already_enrolled' => Schemas::boolean(),
102 ),
103 array( 'enrollment_id', 'user_id', 'course_id' )
104 );
105 }
106
107 /**
108 * Write output wrapped under "enrollment".
109 *
110 * @return array
111 */
112 public static function write_output(): array {
113 return Schemas::object_output( 'enrollment' );
114 }
115
116 /**
117 * get-student-progress input (read).
118 *
119 * @return array
120 */
121 public static function progress_input(): array {
122 return array(
123 'type' => 'object',
124 'additionalProperties' => false,
125 'required' => array( 'user_id', 'course_id' ),
126 'properties' => array(
127 'user_id' => array(
128 'type' => 'integer',
129 'minimum' => 1,
130 ),
131 'course_id' => array(
132 'type' => 'integer',
133 'minimum' => 1,
134 ),
135 ),
136 );
137 }
138
139 /**
140 * get-enrollments input (read).
141 *
142 * @return array
143 */
144 public static function get_enrollments_input(): array {
145 return array(
146 'type' => 'object',
147 'additionalProperties' => false,
148 'properties' => array(
149 'course_id' => array(
150 'type' => 'integer',
151 'minimum' => 1,
152 ),
153 'user_id' => array(
154 'type' => 'integer',
155 'minimum' => 1,
156 ),
157 'status' => array( 'type' => array( 'string', 'array', 'null' ) ),
158 'page' => array(
159 'type' => 'integer',
160 'minimum' => 1,
161 'default' => 1,
162 ),
163 'per_page' => array(
164 'type' => 'integer',
165 'minimum' => 1,
166 'maximum' => 100,
167 'default' => 10,
168 ),
169 ),
170 'default' => array(),
171 );
172 }
173 }
174