Skip to content

Commit

Permalink
feat: show question number in Candidate App
Browse files Browse the repository at this point in the history
Show the number of the current question and the total number when
answering questions in the Candidate App.
  • Loading branch information
kaljarv committed Oct 2, 2024
1 parent b0c6f6c commit 00a8135
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions frontend/src/lib/candidate/templates/question/QuestionPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
let openAnswerTextArea: MultilangTextInput; // Used to clear the local storage from the parent component
let options: Array<AnswerOption>;
let questionId: string;
let questionIndex: number | undefined;
let selectedKey: AnswerOption['key'] | undefined;
const {opinionAnswers, progress, questionsLocked, unansweredOpinionQuestions} =
const {opinionAnswers, progress, questionsLocked, opinionQuestions, unansweredOpinionQuestions} =
getContext<CandidateContext>('candidate');
$: {
questionId = currentQuestion.id;
questionIndex = $opinionQuestions?.findIndex((q) => q === currentQuestion);
// Set the selected key on page load, local storage takes precedence
likertLocal = `candidate-app-question-${questionId}-likert`;
openAnswerLocal = `candidate-app-question-${questionId}-open`;
Expand Down Expand Up @@ -174,9 +176,18 @@ In addition to the question, includes a Likert scale and a text area for comment
>{$t('candidateApp.common.editingNotAllowed')}</Warning>

<HeadingGroup slot="heading" id="hgroup-{questionId}">
{#if category}
<PreHeading><CategoryTag {category} /></PreHeading>
{/if}
<PreHeading>
{#if questionIndex != null && $opinionQuestions}
<!-- Index of question within all questions -->
{#if !category}
{$t('common.question')}
{/if}
<span class="text-secondary">{questionIndex + 1}/{$opinionQuestions.length}</span>
{/if}
{#if category}
<CategoryTag {category} />
{/if}
</PreHeading>
<h1>{currentQuestion.text}</h1>
</HeadingGroup>

Expand Down

0 comments on commit 00a8135

Please sign in to comment.