themes.json: Use a exercice list instead of hash
This commit is contained in:
parent
3fcf705dcf
commit
ef1eafb789
11 changed files with 82 additions and 82 deletions
|
|
@ -49,12 +49,12 @@
|
|||
{/if}
|
||||
|
||||
<Row cols={{ lg: 3, md: 2, sm: 1 }}>
|
||||
{#each Object.keys($themes) as th, index}
|
||||
{#each $themes as th, index}
|
||||
<Col class="mb-3">
|
||||
<CardTheme
|
||||
class="{$my && $my.team_id && $myThemes[$themes[th].id].exercice_solved > 0?'border-light ':''}{$themes[th].exercice_coeff_max > 1?'border-success ':''}"
|
||||
theme={$themes[th]}
|
||||
on:click={goto(`${$themes[th].urlid}`)}
|
||||
class="{$my && $my.team_id && $myThemes[th.id].exercice_solved > 0?'border-light ':''}{th.exercice_coeff_max > 1?'border-success ':''}"
|
||||
theme={th}
|
||||
on:click={goto(`${th.urlid}`)}
|
||||
/>
|
||||
</Col>
|
||||
{/each}
|
||||
|
|
|
|||
|
|
@ -50,56 +50,56 @@
|
|||
|
||||
{#if $current_theme.exercices}
|
||||
<ul class="list-group">
|
||||
{#each Object.keys($current_theme.exercices) as k, index}
|
||||
{#each $current_theme.exercices as exercice, index}
|
||||
<li
|
||||
class="list-group-item"
|
||||
class:list-group-item-action={$my && $my.exercices[k]}
|
||||
on:click={goto(`${$current_theme.urlid}/${$current_theme.exercices[k].urlid}`)}
|
||||
on:keypress={goto(`${$current_theme.urlid}/${$current_theme.exercices[k].urlid}`)}
|
||||
class:list-group-item-action={$my && $my.exercices[exercice.id]}
|
||||
on:click={goto(`${$current_theme.urlid}/${exercice.urlid}`)}
|
||||
on:keypress={goto(`${$current_theme.urlid}/${exercice.urlid}`)}
|
||||
>
|
||||
<div class="row">
|
||||
<div class="col-1" style="margin-top: -0.5rem; margin-bottom: -0.5rem; text-align: right; border-right: 5px solid #{$my && $my.exercices[k] && $my.exercices[k].solved_rank ? '62c462' : 'bbb'}">
|
||||
<div class="col-1" style="margin-top: -0.5rem; margin-bottom: -0.5rem; text-align: right; border-right: 5px solid #{$my && $my.exercices[exercice.id] && $my.exercices[exercice.id].solved_rank ? '62c462' : 'bbb'}">
|
||||
</div>
|
||||
<div class="col-10">
|
||||
<div style="position: absolute; margin-left: calc(var(--bs-gutter-x) * -.5 - 15px); margin-top: -0.5rem;">
|
||||
<svg style="height: 50px; width: 23px;">
|
||||
<rect
|
||||
style="fill:#{$my && $my.exercices[k] && (index < 1 || ($my.exercices[Object.keys($current_theme.exercices)[index-1]] && $my.exercices[Object.keys($current_theme.exercices)[index-1]].solved_rank)) ? '62c462' : 'bbb'}"
|
||||
style="fill:#{$my && $my.exercices[exercice.id] && (index < 1 || ($my.exercices[$current_theme.exercices[index-1].id] && $my.exercices[$current_theme.exercices[index-1].id].solved_rank)) ? '62c462' : 'bbb'}"
|
||||
width="5"
|
||||
height="30"
|
||||
x="10"
|
||||
y="0" />
|
||||
<path
|
||||
style="fill:#{$my && $my.exercices[k] ? ($my.exercices[k].solved_rank ? '62c462' : ($current_theme.exercices[k].curcoeff > 1.0 ? 'f89406' : '5bc0de')) : '555'}"
|
||||
style="fill:#{$my && $my.exercices[exercice.id] ? ($my.exercices[exercice.id].solved_rank ? '62c462' : (exercice.curcoeff > 1.0 ? 'f89406' : '5bc0de')) : '555'}"
|
||||
d="m 22,20 a 9.5700617,9.5700617 0 0 1 -9.5690181,9.57006 9.5700617,9.5700617 0 0 1 -9.57110534,-9.56797 9.5700617,9.5700617 0 0 1 9.56692984,-9.57215 9.5700617,9.5700617 0 0 1 9.5731926,9.56588" />
|
||||
</svg>
|
||||
</div>
|
||||
{#each $current_theme.exercices[k].tags as tag, idx}
|
||||
{#each exercice.tags as tag, idx}
|
||||
<Badge href="tags/{tag}" pill color="secondary" class="mx-1 float-end">#{tag}</Badge>
|
||||
{/each}
|
||||
<h5 class="fw-bold">
|
||||
{#if $my && $my.exercices[k]}
|
||||
{#if $my && $my.exercices[exercice.id]}
|
||||
<span style="white-space: nowrap">
|
||||
{#if $my.exercices[k].wip}
|
||||
{#if $my.exercices[exercice.id].wip}
|
||||
<Icon name="cone-striped" aria-hidden="true" title="Cette étape est encore en construction." />
|
||||
{/if}
|
||||
{$current_theme.exercices[k].title}
|
||||
{exercice.title}
|
||||
</span>
|
||||
{:else}
|
||||
<span style="white-space: nowrap">
|
||||
<Icon name="lock-fill" aria-hidden="true" title="Vous n'avez pas encore accès à ce défi" />
|
||||
{$current_theme.exercices[k].title}
|
||||
{exercice.title}
|
||||
</span>
|
||||
{/if}
|
||||
{#if $current_theme.exercices[k].curcoeff > 1.0}
|
||||
{#if exercice.curcoeff > 1.0}
|
||||
<Icon name="gift" aria-hidden="true" title="Un bonus est actuellement appliqué lors de la résolution de ce défi" />
|
||||
{/if}
|
||||
</h5>
|
||||
<p>{@html $current_theme.exercices[k].headline}</p>
|
||||
<p>{@html exercice.headline}</p>
|
||||
</div>
|
||||
<div class="d-none d-md-block col-1">
|
||||
{#if $my && $my.exercices[k]}
|
||||
<a class="float-right" href="{$current_theme.urlid}/{$current_theme.exercices[k].urlid}" style="font-size: 3rem">
|
||||
{#if $my && $my.exercices[exercice.id]}
|
||||
<a class="float-right" href="{$current_theme.urlid}/{exercice.urlid}" style="font-size: 3rem">
|
||||
<Icon name="chevron-right" aria-hidden="true" />
|
||||
</a>
|
||||
{:else}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,11 @@
|
|||
$: {
|
||||
let tmp_exercices = [];
|
||||
|
||||
for (let th in $themes) {
|
||||
for (let ex in $themes[th].exercices) {
|
||||
if ($themes[th].exercices[ex].tags.indexOf(data.tag) >= 0) {
|
||||
tmp_exercices.push({theme: $themes[th], exercice: $themes[th].exercices[ex], index: th + "," + ex});
|
||||
for (let k in $themes) {
|
||||
const th = $themes[k];
|
||||
for (const ex of th.exercices) {
|
||||
if (ex.tags.indexOf(data.tag) >= 0) {
|
||||
tmp_exercices.push({theme: th, exercice: ex, index: k + "," + ex});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue