| @@ -10,14 +10,14 @@ | ||
| 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; |
| 18 | 17 | use LearnPress\Models\PostModel; |
| 19 | 18 | use LP_Cache; |
| 19 | +use LP_Debug; | |
| 20 | 20 | use LP_Question_Filter; |
| 21 | 21 | |
| 22 | 22 | class QuestionPostModel extends PostModel { |
| 23 | 23 | /** |
| @@ -90,9 +90,9 @@ | ||
| 90 | 90 | |
| 91 | 91 | $this->answer_options = $answer_options; |
| 92 | 92 | } |
| 93 | 93 | } catch ( Exception $e ) { |
| 94 | - Debug::error_log( $e ); | |
| 94 | + LP_Debug::error_log( $e ); | |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | return $this->answer_options; |
| 98 | 98 | } |
| @@ -161,19 +161,8 @@ | ||
| 161 | 161 | return $this->question_type; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
| 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 | 165 | * Check type question is valid |
| 177 | 166 | * |
| 178 | 167 | * @param string $type |
| 179 | 168 | * |
| @@ -271,6 +260,24 @@ | ||
| 271 | 260 | * @return string |
| 272 | 261 | */ |
| 273 | 262 | public function random_value( int $length = 10 ): string { |
| 274 | 263 | return substr( md5( uniqid( mt_rand(), true ) ), 0, $length ); |
| 264 | + } | |
| 265 | + | |
| 266 | + /** | |
| 267 | + * Check capabilities create question | |
| 268 | + * | |
| 269 | + * @return bool | |
| 270 | + */ | |
| 271 | + public function check_capabilities_create(): bool { | |
| 272 | + return current_user_can( 'edit_' . LP_LESSON_CPT . 's' ); | |
| 273 | + } | |
| 274 | + | |
| 275 | + /** | |
| 276 | + * Check capabilities update question | |
| 277 | + * | |
| 278 | + * @return bool | |
| 279 | + */ | |
| 280 | + public function check_capabilities_update(): bool { | |
| 281 | + return current_user_can( 'edit_' . LP_LESSON_CPT, $this->ID ); | |
| 275 | 282 | } |
| 276 | 283 | } |