Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -446,162 +446,163 @@ const QuizSettings = ({ contentDripType }: QuizSettingsProps) => {
</div>
</div>
</div>
<Show when={contentType !== 'tutor_h5p_quiz'}>
<div css={styles.card}>
<h5>{__('Navigation & Display', 'tutor')}</h5>

<div css={styles.card}>
<h5>{__('Navigation & Display', 'tutor')}</h5>

<div css={styles.innerCard}>
<Controller
control={form.control}
name="quiz_option.question_layout_view"
render={(controllerProps) => (
<FormQuizLayoutSelect
{...controllerProps}
label={__('Layout', 'tutor')}
description={__('Choose how students will answer the questions.', 'tutor')}
options={[
{
label: __('Single Question', 'tutor'),
value: 'single_question',
image: <QuizSingleLayoutSvg width={72} height={92} />,
},
{
label: __('Full Page', 'tutor'),
value: 'question_below_each_other',
image: <QuizFullPageSvg width={72} height={92} />,
},
]}
/>
)}
/>
<div css={styles.innerCard}>
<Controller
control={form.control}
name="quiz_option.question_layout_view"
render={(controllerProps) => (
<FormQuizLayoutSelect
{...controllerProps}
label={__('Layout', 'tutor')}
description={__('Choose how students will answer the questions.', 'tutor')}
options={[
{
label: __('Single Question', 'tutor'),
value: 'single_question',
image: <QuizSingleLayoutSvg width={72} height={92} />,
},
{
label: __('Full Page', 'tutor'),
value: 'question_below_each_other',
image: <QuizFullPageSvg width={72} height={92} />,
},
]}
/>
)}
/>

<Show when={form.watch('quiz_option.question_layout_view') === 'single_question'}>
<hr />
<Show when={form.watch('quiz_option.question_layout_view') === 'single_question'}>
<hr />

<div css={styles.inlineForm}>
<Controller
control={form.control}
name="quiz_option.enable_pagination"
render={(controllerProps) => (
<FormCheckbox
{...controllerProps}
label={__('Show pagination', 'tutor')}
helpText={
isLegacyLearningMode
? __('Pagination style is unavailable while learning mode is set to Legacy.', 'tutor')
: undefined
}
/>
)}
/>

<Show when={form.watch('quiz_option.enable_pagination')}>
<div css={styles.paginationIcons}>
<SVGIcon
name={getPaginationTypeIcon(form.watch('quiz_option.pagination_type'))}
width={40}
height={32}
/>
</div>
<div css={styles.inlineForm}>
<Controller
control={form.control}
name="quiz_option.pagination_type"
name="quiz_option.enable_pagination"
render={(controllerProps) => (
<FormSelectInput
<FormCheckbox
{...controllerProps}
size="small"
isInlineLabel
disabled={isLegacyLearningMode}
options={[
{
label: __('Shapes', 'tutor'),
value: 'shape',
},
{
label: __('Numbers', 'tutor'),
value: 'number',
},
{
label: __('Radio', 'tutor'),
value: 'radio',
},
]}
label={__('Show pagination', 'tutor')}
helpText={
isLegacyLearningMode
? __('Pagination style is unavailable while learning mode is set to Legacy.', 'tutor')
: undefined
}
/>
)}
/>
</Show>
</div>

<div css={styles.inlineForm}>
<Controller
control={form.control}
name="quiz_option.enable_answer_reveal"
render={(controllerProps) => (
<FormCheckbox {...controllerProps} label={__('Reveal answers after submission', 'tutor')} />
)}
/>

<Show when={form.watch('quiz_option.enable_answer_reveal')}>
<div css={styles.inlineForm({ withPrefix: true })}>
<div data-prefix>{__('For', 'tutor')}</div>
<Show when={form.watch('quiz_option.enable_pagination')}>
<div css={styles.paginationIcons}>
<SVGIcon
name={getPaginationTypeIcon(form.watch('quiz_option.pagination_type'))}
width={40}
height={32}
/>
</div>
<Controller
name="quiz_option.answers_reveal_duration"
control={form.control}
name="quiz_option.pagination_type"
render={(controllerProps) => (
<FormInputWithPresets
<FormSelectInput
{...controllerProps}
size="small"
content={__('secs', 'tutor')}
contentPosition="right"
wrapperCss={styles.maxWidth('80px')}
contentCss={styles.minWidth('fit-content')}
formFieldWrapperCss={styles.width('auto')}
showVerticalBar={false}
presetOptions={[
{
label: __('2', 'tutor'),
value: '2',
},
isInlineLabel
disabled={isLegacyLearningMode}
options={[
{
label: __('5', 'tutor'),
value: '5',
label: __('Shapes', 'tutor'),
value: 'shape',
},
{
label: __('7', 'tutor'),
value: '7',
label: __('Numbers', 'tutor'),
value: 'number',
},
{
label: __('10', 'tutor'),
value: '10',
label: __('Radio', 'tutor'),
value: 'radio',
},
]}
/>
)}
/>
</div>
</Show>
</div>
</Show>
</div>

<hr />
<div css={styles.inlineForm}>
<Controller
control={form.control}
name="quiz_option.enable_answer_reveal"
render={(controllerProps) => (
<FormCheckbox {...controllerProps} label={__('Reveal answers after submission', 'tutor')} />
)}
/>

<Controller
control={form.control}
name="quiz_option.hide_previous_button"
render={(controllerProps) => (
<FormSwitch {...controllerProps} label={__('Hide previous button from students', 'tutor')} />
)}
/>
<Show when={form.watch('quiz_option.enable_answer_reveal')}>
<div css={styles.inlineForm({ withPrefix: true })}>
<div data-prefix>{__('For', 'tutor')}</div>
<Controller
name="quiz_option.answers_reveal_duration"
control={form.control}
render={(controllerProps) => (
<FormInputWithPresets
{...controllerProps}
size="small"
content={__('secs', 'tutor')}
contentPosition="right"
wrapperCss={styles.maxWidth('80px')}
contentCss={styles.minWidth('fit-content')}
formFieldWrapperCss={styles.width('auto')}
showVerticalBar={false}
presetOptions={[
{
label: __('2', 'tutor'),
value: '2',
},
{
label: __('5', 'tutor'),
value: '5',
},
{
label: __('7', 'tutor'),
value: '7',
},
{
label: __('10', 'tutor'),
value: '10',
},
]}
/>
)}
/>
</div>
</Show>
</div>

<Controller
control={form.control}
name="quiz_option.hide_question_number_overview"
render={(controllerProps) => (
<FormSwitch {...controllerProps} label={__('Hide question number', 'tutor')} />
)}
/>
</Show>
<hr />

<Controller
control={form.control}
name="quiz_option.hide_previous_button"
render={(controllerProps) => (
<FormSwitch {...controllerProps} label={__('Hide previous button from students', 'tutor')} />
)}
/>

<Controller
control={form.control}
name="quiz_option.hide_question_number_overview"
render={(controllerProps) => (
<FormSwitch {...controllerProps} label={__('Hide question number', 'tutor')} />
)}
/>
</Show>
</div>
</div>
</div>
</Show>

<Show
when={
Expand Down
11 changes: 10 additions & 1 deletion assets/src/scss/frontend/learning-area/_lesson-content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@
flex-shrink: 0;
}

&:hover:not(.completed) {
&:disabled {
cursor: not-allowed;
background-color: $tutor-button-disabled;
color: $tutor-text-disabled;
svg{
color: $tutor-icon-disabled;
}
}

&:hover:not(.completed):not(:disabled) {
background-color: $tutor-surface-l1;

svg {
Expand Down
8 changes: 5 additions & 3 deletions classes/Quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ private function review_quiz_answers_bulk( int $attempt_id, array $review_status
*
* @return object|null
*/
private function get_attempt_answer( int $attempt_answer_id ) {
public static function get_attempt_answer( int $attempt_answer_id ) {
global $wpdb;

return $wpdb->get_row(
Expand Down Expand Up @@ -1289,7 +1289,7 @@ private function create_skipped_attempt_answer( int $attempt_id, int $question_i
return null;
}

return $this->get_attempt_answer( $inserted_id );
return self::get_attempt_answer( $inserted_id );
}

/**
Expand All @@ -1304,7 +1304,7 @@ private function create_skipped_attempt_answer( int $attempt_id, int $question_i
* @return object|null
*/
private function resolve_attempt_answer_for_review( int $attempt_id, int $attempt_answer_id = 0, int $question_id = 0 ) {
$attempt_answer = $attempt_answer_id ? $this->get_attempt_answer( $attempt_answer_id ) : null;
$attempt_answer = $attempt_answer_id ? self::get_attempt_answer( $attempt_answer_id ) : null;

if ( $attempt_answer ) {
return $attempt_answer;
Expand Down Expand Up @@ -1355,6 +1355,8 @@ private function apply_quiz_answer_review( int $attempt_id, $attempt_answer, str

do_action( 'tutor_quiz_review_answer_before', $attempt_answer_id, $attempt_id, $mark_as );

$mark_as = apply_filters( 'tutor_quiz_review_mark_as', $mark_as, $attempt_answer_id, $attempt_id, $question );

if ( 'correct' === $mark_as ) {
$attempt_update_data = array();
$answer_update_data = array(
Expand Down
1 change: 1 addition & 0 deletions templates/learning-area/lesson/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class="tutor-lesson-content-tab"
<?php endif; ?>
</div>
<?php
do_action( 'tutor_lesson/single/before/content' );
echo apply_filters( 'tutor_learning_area_content', ob_get_clean() ); //phpcs:ignore --already escaped
tutor_load_template( 'learning-area.lesson.footer' );
?>
Expand Down
3 changes: 2 additions & 1 deletion templates/learning-area/quiz/attempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
}
}

$form_id = 'quiz-attempt-form-' . $tutor_is_started_quiz->attempt_id;
$form_id = 'quiz-attempt-form-' . $tutor_is_started_quiz->attempt_id . '-' . $tutor_is_started_quiz->quiz_id;
$modal_id = 'tutor-quiz-abandon-modal';
$submitted_modal_id = 'tutor-quiz-submitted-modal';
$timeout_modal_id = 'tutor-quiz-timeout-modal';
Expand Down Expand Up @@ -197,6 +197,7 @@ class="tutor-quiz-questions"
<?php endif; ?>

<?php
do_action( 'tutor_quiz/body/before', $tutor_is_started_quiz->quiz_id, $quiz_attempt_info );
foreach ( $questions as $index => $question ) {
$question_settings = maybe_unserialize( $question->question_settings );
$answer_required = isset( $question_settings['answer_required'] ) && '1' === $question_settings['answer_required'];
Expand Down
3 changes: 2 additions & 1 deletion templates/learning-area/quiz/question.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

<div
class="tutor-quiz-question"
id="<?php echo esc_attr( $question_id ); ?>"
data-question="<?php echo esc_attr( $question->question_type ); ?>"
data-answer-required="<?php echo esc_attr( $answer_is_required ); ?>"
>
Expand All @@ -70,7 +71,7 @@ class="tutor-quiz-question"

// Render the question type specific answers template.
tutor_load_template(
'learning-area.quiz.questions.' . $question_type,
apply_filters( 'tutor_filter_quiz_question_template', 'learning-area.quiz.questions.' . $question_type, $question_type ),
array(
'question' => wp_parse_args( (array) $question, $default_question ),
'quiz_settings' => $quiz_settings,
Expand Down
Loading
Loading