PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.10
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.10
4.4.10 4.4.9.1 4.4.9 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 All 142 releases
← All changes | inc/Models/Question/QuestionPostModel.php +28 -16 4.4.1 → 4.4.10 View file →
@@ -10,14 +10,15 @@
10 10 */
11 11
12 12 namespace LearnPress\Models\Question;
13 13
14 -use ClassPress\Helpers\Debug;
15 14 use Exception;
16 15 use LearnPress\Databases\QuestionAnswersDB;
17 16 use LearnPress\Filters\QuestionAnswersFilter;
17 +use LearnPress\Helpers\Template;
18 18 use LearnPress\Models\PostModel;
19 19 use LP_Cache;
20 +use LP_Debug;
20 21 use LP_Question_Filter;
21 22
22 23 class QuestionPostModel extends PostModel {
23 24 /**
@@ -90,9 +91,9 @@
90 91
91 92 $this->answer_options = $answer_options;
92 93 }
93 94 } catch ( Exception $e ) {
94 - Debug::error_log( $e );
95 + LP_Debug::error_log( $e );
95 96 }
96 97
97 98 return $this->answer_options;
98 99 }
@@ -161,19 +162,8 @@
161 162 return $this->question_type;
162 163 }
163 164
164 165 /**
165 - * @param $question_type
166 - * @return $this
167 - */
168 - public function set_type($question_type)
169 - {
170 - $this->question_type = $question_type;
171 -
172 - return $this;
173 - }
174 -
175 - /**
176 166 * Check type question is valid
177 167 *
178 168 * @param string $type
179 169 *
@@ -208,9 +198,11 @@
208 198 /**
209 199 * @return mixed
210 200 */
211 201 public function get_hint() {
212 - return $this->get_meta_value_by_key( self::META_KEY_HINT, '' );
202 + return Template::sanitize_html_content(
203 + (string) $this->get_meta_value_by_key( self::META_KEY_HINT, '' )
204 + );
213 205 }
214 206
215 207 /**
216 208 * @return mixed
@@ -215,9 +207,11 @@
215 207 /**
216 208 * @return mixed
217 209 */
218 210 public function get_explanation() {
219 - return $this->get_meta_value_by_key( self::META_KEY_EXPLANATION, '' );
211 + return Template::sanitize_html_content(
212 + (string) $this->get_meta_value_by_key( self::META_KEY_EXPLANATION, '' )
213 + );
220 214 }
221 215
222 216 /**
223 217 * @return mixed
@@ -222,9 +216,9 @@
222 216 /**
223 217 * @return mixed
224 218 */
225 219 public function get_mark() {
226 - return $this->get_meta_value_by_key( self::META_KEY_MARK, 1 );
220 + return (float) $this->get_meta_value_by_key( self::META_KEY_MARK, 1 );
227 221 }
228 222
229 223 /**
230 224 * Create default answers for question
@@ -271,6 +265,24 @@
271 265 * @return string
272 266 */
273 267 public function random_value( int $length = 10 ): string {
274 268 return substr( md5( uniqid( mt_rand(), true ) ), 0, $length );
269 + }
270 +
271 + /**
272 + * Check capabilities create question
273 + *
274 + * @return bool
275 + */
276 + public function check_capabilities_create(): bool {
277 + return current_user_can( 'edit_' . LP_LESSON_CPT . 's' );
278 + }
279 +
280 + /**
281 + * Check capabilities update question
282 + *
283 + * @return bool
284 + */
285 + public function check_capabilities_update(): bool {
286 + return current_user_can( 'edit_' . LP_LESSON_CPT, $this->ID );
275 287 }
276 288 }