Skip to content

Commit

Permalink
Merge pull request #48 from RAU-EIT/sl-no-retries
Browse files Browse the repository at this point in the history
remove retry / redo option
  • Loading branch information
bonartm authored Oct 11, 2024
2 parents 3b0e6d3 + cf40dff commit 2926691
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
3 changes: 2 additions & 1 deletion docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ let config = {
primaryColor: 'steelblue', // primary CSS color
secondaryColor: '#f2f2f2', // secondary CSS color
textColor: 'black', // text color of some elements
locale: null // language of the user interface (auto-detect per default)
locale: null, // language of the user interface (auto-detect per default)
enableRetry: true // allow the user to resubmit answers
};

quizdown.init(config);
Expand Down
25 changes: 15 additions & 10 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
$: allVisited = quiz.allVisited;
//let game = new Linear(quiz);
let enableRetry = quiz.config.enableRetry;
registerLanguages(quiz.config.locale);
registerIcons();
Expand Down Expand Up @@ -115,15 +117,18 @@
</div>
{/if}
</svelte:fragment>

<Button
slot="right"
title="{$_('reset')}"
buttonAction="{() => {
reloaded = !reloaded;
quiz.reset();
}}"><Icon name="redo" /></Button
>
<svelte:fragment slot="right">
{#if enableRetry}
<Button
slot="right"
title="{$_('reset')}"
buttonAction="{() => {
reloaded = !reloaded;
quiz.reset();
}}"><Icon name="redo" /></Button
>
{/if}
</svelte:fragment>
</Row>

<Credits />
Expand Down
7 changes: 6 additions & 1 deletion src/components/ResultsView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@

<ol>
{#each quiz.questions as question, i}
<li class="top-list-item" on:click="{() => quiz.jump(i)}">
<li class="top-list-item" on:click="{() => {
if(quiz.config.enableRetry) {
quiz.jump(i);
}
}
}">
<span class="list-question">
{emojis[+question.solved]}
{@html question.text}
Expand Down
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const toRename = {
primary_color: 'primaryColor',
secondary_color: 'secondaryColor',
text_color: 'textColor',
enable_retry: 'enableRetry'
};

export class Config {
Expand All @@ -26,6 +27,7 @@ export class Config {
secondaryColor: string;
textColor: string;
locale: 'de' | 'en' | 'es' | 'fr' | null;
enableRetry: boolean;

constructor(options: Config | object) {
// handle <=v0.3.0 snake_case options for backwards compatibility
Expand All @@ -40,6 +42,7 @@ export class Config {
this.secondaryColor = get(options['secondaryColor'], '#f2f2f2');
this.textColor = get(options['textColor'], 'black');
this.locale = get(options['locale'], null);
this.enableRetry = get(options['enableRetry'],true);
}
}

Expand Down

0 comments on commit 2926691

Please sign in to comment.