| @@ -12,10 +12,12 @@ | ||
| 12 | 12 | if ( ! class_exists( 'LP_Question_Answers' ) ) { |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Class LP_Question_Answers |
| 16 | + * | |
| 17 | + * @deprecated 4.1.7.3 | |
| 16 | 18 | */ |
| 17 | - class LP_Question_Answers implements ArrayAccess, Iterator { | |
| 19 | + class LP_Question_Answers { | |
| 18 | 20 | /** |
| 19 | 21 | * Answers |
| 20 | 22 | * |
| 21 | 23 | * @var array |
| @@ -102,8 +104,15 @@ | ||
| 102 | 104 | } |
| 103 | 105 | } |
| 104 | 106 | |
| 105 | 107 | /** |
| 108 | + * @return array | |
| 109 | + */ | |
| 110 | + public function get_answers(): array { | |
| 111 | + return $this->_answers; | |
| 112 | + } | |
| 113 | + | |
| 114 | + /** | |
| 106 | 115 | * Set new option for an answer |
| 107 | 116 | * |
| 108 | 117 | * @param int|array $id |
| 109 | 118 | * @param mixed $options |
| @@ -249,9 +258,12 @@ | ||
| 249 | 258 | protected function _shuffle() { |
| 250 | 259 | LP_Helper::shuffle_assoc( $this->_answers ); |
| 251 | 260 | } |
| 252 | 261 | |
| 253 | - public function get_class( $more = '' ) { | |
| 262 | + /** | |
| 263 | + * @deprecated 4.2.7.6 | |
| 264 | + */ | |
| 265 | + /*public function get_class( $more = '' ) { | |
| 254 | 266 | $classes = array( 'answer-options' ); |
| 255 | 267 | if ( $more && is_string( $more ) ) { |
| 256 | 268 | $more = explode( ' ', $more ); |
| 257 | 269 | } |
| @@ -266,9 +278,9 @@ | ||
| 266 | 278 | // sanitize unwanted classes |
| 267 | 279 | $classes = LP_Helper::sanitize_array( $classes ); |
| 268 | 280 | |
| 269 | 281 | return apply_filters( 'learn-press/question/answer-options/classes', $classes, $this ); |
| 270 | - } | |
| 282 | + }*/ | |
| 271 | 283 | |
| 272 | 284 | /** |
| 273 | 285 | * Return an answer from a position. |
| 274 | 286 | * |
| @@ -289,13 +301,14 @@ | ||
| 289 | 301 | } |
| 290 | 302 | |
| 291 | 303 | /** |
| 292 | 304 | * @param string $more |
| 305 | + * @deprecated 4.1.7.3 | |
| 293 | 306 | */ |
| 294 | - public function answers_class( $more = '' ) { | |
| 307 | + /*public function answers_class( $more = '' ) { | |
| 295 | 308 | $classes = $this->get_class( $more ); |
| 296 | 309 | echo 'class="' . join( ' ', $classes ) . '"'; |
| 297 | - } | |
| 310 | + }*/ | |
| 298 | 311 | } |
| 299 | 312 | } |
| 300 | 313 | |
| 301 | 314 | if ( ! class_exists( 'LP_Question_Answer_Option' ) ) { |
| @@ -303,9 +316,9 @@ | ||
| 303 | 316 | * Class LP_Question_Answer_Option |
| 304 | 317 | * |
| 305 | 318 | * @since 3.0.0 |
| 306 | 319 | */ |
| 307 | - class LP_Question_Answer_Option implements ArrayAccess { | |
| 320 | + class LP_Question_Answer_Option { | |
| 308 | 321 | /** |
| 309 | 322 | * Option data |
| 310 | 323 | * |
| 311 | 324 | * @var array |
| @@ -359,14 +372,14 @@ | ||
| 359 | 372 | * Return true if option is TRUE |
| 360 | 373 | * |
| 361 | 374 | * @return bool |
| 362 | 375 | */ |
| 363 | - public function is_true() { | |
| 376 | + public function is_true(): bool { | |
| 364 | 377 | return apply_filters( 'learn-press/question/option-is-true', array_key_exists( 'is_true', $this->_data ) && $this->_data['is_true'] === 'yes', $this ); |
| 365 | 378 | } |
| 366 | 379 | |
| 367 | 380 | public function get_id() { |
| 368 | - return isset( $this->_data['question_answer_id'] ) ? $this->_data['question_answer_id'] : 0; | |
| 381 | + return $this->_data['question_answer_id'] ?? 0; | |
| 369 | 382 | } |
| 370 | 383 | |
| 371 | 384 | /** |
| 372 | 385 | * CSS class for option |
| @@ -373,53 +386,54 @@ | ||
| 373 | 386 | * |
| 374 | 387 | * @param string $more |
| 375 | 388 | * |
| 376 | 389 | * @return array |
| 390 | + * @deprecated 4.2.7.6 | |
| 377 | 391 | */ |
| 378 | - public function get_class( $more = '' ) { | |
| 379 | - $classes = array( 'answer-option' ); | |
| 380 | - if ( $more && is_string( $more ) ) { | |
| 381 | - $more = explode( ' ', $more ); | |
| 382 | - } | |
| 392 | +// public function get_class( $more = '' ) { | |
| 393 | +// $classes = array( 'answer-option' ); | |
| 394 | +// if ( $more && is_string( $more ) ) { | |
| 395 | +// $more = explode( ' ', $more ); | |
| 396 | +// } | |
| 397 | +// | |
| 398 | +// if ( $more && is_array( $more ) ) { | |
| 399 | +// $classes = array_merge( $classes, $more ); | |
| 400 | +// } | |
| 401 | +// $is_checked = $this->is_checked(); | |
| 402 | +// $is_true = $this->is_true(); | |
| 403 | +// | |
| 404 | +// if ( $this->get_question()->show_correct_answers() === 'yes' ) { | |
| 405 | +// | |
| 406 | +// if ( $is_true ) { | |
| 407 | +// $classes[] = 'answer-correct'; | |
| 408 | +// } | |
| 409 | +// | |
| 410 | +// if ( $is_checked ) { | |
| 411 | +// $classes[] = 'answer-selected'; | |
| 412 | +// } | |
| 413 | +// | |
| 414 | +// if ( $is_checked && $is_true ) { | |
| 415 | +// $classes[] = 'answered-correct'; | |
| 416 | +// } elseif ( $is_checked && ! $is_true ) { | |
| 417 | +// $classes[] = 'answered-wrong'; | |
| 418 | +// } elseif ( ! $is_checked && $is_true ) { | |
| 419 | +// $classes[] = 'answered-wrong'; | |
| 420 | +// } | |
| 421 | +// } | |
| 422 | +// /*elseif ( learn_press_is_review_questions() ) { | |
| 423 | +// if ( $is_checked && $is_true ) { | |
| 424 | +// $classes[] = 'answered-correct'; | |
| 425 | +// } elseif ( $is_checked && ! $is_true ) { | |
| 426 | +// $classes[] = 'answered-wrong'; | |
| 427 | +// } | |
| 428 | +// }*/ | |
| 429 | +// | |
| 430 | +// // sanitize unwanted classes | |
| 431 | +// $classes = LP_Helper::sanitize_array( $classes ); | |
| 432 | +// | |
| 433 | +// return apply_filters( 'learn-press/question/answer-option/classes', $classes, $this ); | |
| 434 | +// } | |
| 383 | 435 | |
| 384 | - if ( $more && is_array( $more ) ) { | |
| 385 | - $classes = array_merge( $classes, $more ); | |
| 386 | - } | |
| 387 | - $is_checked = $this->is_checked(); | |
| 388 | - $is_true = $this->is_true(); | |
| 389 | - | |
| 390 | - if ( $this->get_question()->show_correct_answers() === 'yes' ) { | |
| 391 | - | |
| 392 | - if ( $is_true ) { | |
| 393 | - $classes[] = 'answer-correct'; | |
| 394 | - } | |
| 395 | - | |
| 396 | - if ( $is_checked ) { | |
| 397 | - $classes[] = 'answer-selected'; | |
| 398 | - } | |
| 399 | - | |
| 400 | - if ( $is_checked && $is_true ) { | |
| 401 | - $classes[] = 'answered-correct'; | |
| 402 | - } elseif ( $is_checked && ! $is_true ) { | |
| 403 | - $classes[] = 'answered-wrong'; | |
| 404 | - } elseif ( ! $is_checked && $is_true ) { | |
| 405 | - $classes[] = 'answered-wrong'; | |
| 406 | - } | |
| 407 | - } | |
| 408 | - /*elseif ( learn_press_is_review_questions() ) { | |
| 409 | - if ( $is_checked && $is_true ) { | |
| 410 | - $classes[] = 'answered-correct'; | |
| 411 | - } elseif ( $is_checked && ! $is_true ) { | |
| 412 | - $classes[] = 'answered-wrong'; | |
| 413 | - } | |
| 414 | - }*/ | |
| 415 | - | |
| 416 | - // sanitize unwanted classes | |
| 417 | - $classes = LP_Helper::sanitize_array( $classes ); | |
| 418 | - | |
| 419 | - return apply_filters( 'learn-press/question/answer-option/classes', $classes, $this ); | |
| 420 | - } | |
| 421 | - | |
| 422 | 436 | /** |
| 423 | 437 | * @param bool $echo |
| 424 | 438 | * |
| 425 | 439 | * @return string |
| @@ -481,12 +495,13 @@ | ||
| 481 | 495 | /** |
| 482 | 496 | * Print class attribute |
| 483 | 497 | * |
| 484 | 498 | * @param string $more |
| 499 | + * @deprecated 4.2.7.6 | |
| 485 | 500 | */ |
| 486 | - public function option_class( $more = '' ) { | |
| 501 | + /*public function option_class( $more = '' ) { | |
| 487 | 502 | echo 'class="' . join( ' ', $this->get_class( $more ) ) . '"'; |
| 488 | - } | |
| 503 | + }*/ | |
| 489 | 504 | |
| 490 | 505 | public function get_data() { |
| 491 | 506 | return $this->_data; |
| 492 | 507 | } |