- {#each $current_theme.exercices[k].tags as tag, idx}
+ {#each exercice.tags as tag, idx}
#{tag}
{/each}
- {#if $my && $my.exercices[k]}
+ {#if $my && $my.exercices[exercice.id]}
- {#if $my.exercices[k].wip}
+ {#if $my.exercices[exercice.id].wip}
{/if}
- {$current_theme.exercices[k].title}
+ {exercice.title}
{:else}
- {$current_theme.exercices[k].title}
+ {exercice.title}
{/if}
- {#if $current_theme.exercices[k].curcoeff > 1.0}
+ {#if exercice.curcoeff > 1.0}
{/if}
-
{@html $current_theme.exercices[k].headline}
+
{@html exercice.headline}
- {#if $my && $my.exercices[k]}
-
+ {#if $my && $my.exercices[exercice.id]}
+
{:else}
diff --git a/frontend/ui/src/routes/tags/[tag]/+page.svelte b/frontend/ui/src/routes/tags/[tag]/+page.svelte
index 87cfc52b..bc530a68 100644
--- a/frontend/ui/src/routes/tags/[tag]/+page.svelte
+++ b/frontend/ui/src/routes/tags/[tag]/+page.svelte
@@ -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});
}
}
}
diff --git a/libfic/theme_export.go b/libfic/theme_export.go
index cdfd0eb6..2b301d5b 100644
--- a/libfic/theme_export.go
+++ b/libfic/theme_export.go
@@ -10,6 +10,7 @@ var GlobalScoreCoefficient float64 = 1
// exportedExercice is a structure representing a challenge, as exposed to players.
type exportedExercice struct {
+ Id int64 `json:"id"`
Title string `json:"title"`
Headline string `json:"headline,omitempty"`
URLId string `json:"urlid"`
@@ -22,16 +23,16 @@ type exportedExercice struct {
// exportedTheme is a structure representing a Theme, as exposed to players.
type exportedTheme struct {
- Name string `json:"name"`
- URLId string `json:"urlid"`
- Authors string `json:"authors"`
- Headline string `json:"headline,omitempty"`
- Intro string `json:"intro"`
- Image string `json:"image,omitempty"`
- PartnerImage string `json:"partner_img,omitempty"`
- PartnerLink string `json:"partner_href,omitempty"`
- PartnerText string `json:"partner_txt,omitempty"`
- Exercices map[string]exportedExercice `json:"exercices"`
+ Name string `json:"name"`
+ URLId string `json:"urlid"`
+ Authors string `json:"authors"`
+ Headline string `json:"headline,omitempty"`
+ Intro string `json:"intro"`
+ Image string `json:"image,omitempty"`
+ PartnerImage string `json:"partner_img,omitempty"`
+ PartnerLink string `json:"partner_href,omitempty"`
+ PartnerText string `json:"partner_txt,omitempty"`
+ Exercices []exportedExercice `json:"exercices"`
}
// Exportedthemes exports themes from the database, to be displayed to players.
@@ -44,10 +45,11 @@ func ExportThemes() (interface{}, error) {
if exercices, err := theme.GetExercices(); err != nil {
return nil, err
} else {
- exos := map[string]exportedExercice{}
+ exos := []exportedExercice{}
for _, exercice := range exercices {
tags, _ := exercice.GetTags()
- exos[fmt.Sprintf("%d", exercice.Id)] = exportedExercice{
+ exos = append(exos, exportedExercice{
+ exercice.Id,
exercice.Title,
exercice.Headline,
exercice.URLId,
@@ -56,7 +58,7 @@ func ExportThemes() (interface{}, error) {
exercice.Coefficient,
exercice.SolvedCount(),
exercice.TriedTeamCount(),
- }
+ })
}
imgpath := ""