From ca4d06b7b17ad2ba487346fdc750484adb58ebaf Mon Sep 17 00:00:00 2001 From: andrea Date: Thu, 6 Jul 2023 13:49:56 +0200 Subject: [PATCH] Read quizzes from disk and render the UI --- app.go | 6 ---- data/quizzes/test.md | 2 +- data/quizzes/test_2.md | 6 ++++ frontend/src/lib/components/QuizCard.svelte | 33 +++++++++------------ frontend/src/lib/wailsjs/go/main/App.d.ts | 2 -- frontend/src/lib/wailsjs/go/main/App.js | 4 --- frontend/src/routes/+layout.svelte | 4 +-- frontend/src/routes/+layout.ts | 1 + frontend/src/routes/+page.svelte | 11 +++---- frontend/src/routes/+page.ts | 5 ++++ 10 files changed, 35 insertions(+), 39 deletions(-) create mode 100644 data/quizzes/test_2.md create mode 100644 frontend/src/routes/+layout.ts create mode 100644 frontend/src/routes/+page.ts diff --git a/app.go b/app.go index 920f8d6..35e3681 100644 --- a/app.go +++ b/app.go @@ -2,7 +2,6 @@ package main import ( "context" - "fmt" "git.andreafazzi.eu/andrea/probo/models" "git.andreafazzi.eu/andrea/probo/store/file" @@ -35,11 +34,6 @@ func (a *App) startup(ctx context.Context) { a.ctx = ctx } -// Greet returns a greeting for the given name -func (a *App) Greet(name string) string { - return fmt.Sprintf("Hello %s, It's show time!", name) -} - func (a *App) ReadAllQuizzes() ([]*models.Quiz, error) { return a.store.ReadAllQuizzes() } diff --git a/data/quizzes/test.md b/data/quizzes/test.md index 212d16b..d04f734 100644 --- a/data/quizzes/test.md +++ b/data/quizzes/test.md @@ -1,4 +1,4 @@ -Cosa mette in relazione l'esperienza di Oersted? +Quali grandezze fisiche mette in relazione l'esperienza di Oersted? * Campo magnetico con campo elettrico * Campo gravitazionale con campo elettrico diff --git a/data/quizzes/test_2.md b/data/quizzes/test_2.md new file mode 100644 index 0000000..c072694 --- /dev/null +++ b/data/quizzes/test_2.md @@ -0,0 +1,6 @@ +La corrente elettrica rappresenta + +* Un moto ordinato di cariche elettriche +* Un moto disordinato di cariche elettriche +* Un moto disordinato di masse +* Un moto ordinato di masse diff --git a/frontend/src/lib/components/QuizCard.svelte b/frontend/src/lib/components/QuizCard.svelte index 7cf1855..de13ee2 100644 --- a/frontend/src/lib/components/QuizCard.svelte +++ b/frontend/src/lib/components/QuizCard.svelte @@ -1,3 +1,8 @@ + +
@@ -13,31 +18,21 @@
-

1ad25d0000…

+

{quiz.hash.slice(0,10)+'…'}


- Per intensità di corrente elettrica si intende + {quiz.question.Text}

-
+
- - - - + {#each quiz.answers as answer} + + {/each}

diff --git a/frontend/src/lib/wailsjs/go/main/App.d.ts b/frontend/src/lib/wailsjs/go/main/App.d.ts index 92ad4b2..3818c17 100755 --- a/frontend/src/lib/wailsjs/go/main/App.d.ts +++ b/frontend/src/lib/wailsjs/go/main/App.d.ts @@ -2,6 +2,4 @@ // This file is automatically generated. DO NOT EDIT import {models} from '../models'; -export function Greet(arg1:string):Promise; - export function ReadAllQuizzes():Promise>; diff --git a/frontend/src/lib/wailsjs/go/main/App.js b/frontend/src/lib/wailsjs/go/main/App.js index 0a0c880..ce99eee 100755 --- a/frontend/src/lib/wailsjs/go/main/App.js +++ b/frontend/src/lib/wailsjs/go/main/App.js @@ -2,10 +2,6 @@ // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL // This file is automatically generated. DO NOT EDIT -export function Greet(arg1) { - return window['go']['main']['App']['Greet'](arg1); -} - export function ReadAllQuizzes() { return window['go']['main']['App']['ReadAllQuizzes'](); } diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index 96737da..4d9c585 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -7,7 +7,7 @@ import '../app.postcss'; import { AppShell, AppBar, AppRail, AppRailTile, AppRailAnchor } from '@skeletonlabs/skeleton'; - let currentTile; + let currentTile; @@ -24,7 +24,7 @@ - Probo + Probo - import QuizCard from "$lib/components/QuizCard.svelte" + import QuizCard from "$lib/components/QuizCard.svelte" + export let data; +
- - - + {#each data.quizzes as quiz} + + {/each}
- diff --git a/frontend/src/routes/+page.ts b/frontend/src/routes/+page.ts new file mode 100644 index 0000000..20e0853 --- /dev/null +++ b/frontend/src/routes/+page.ts @@ -0,0 +1,5 @@ +import { ReadAllQuizzes } from "$lib/wailsjs/go/main/App" + +export async function load() { + return { quizzes: await ReadAllQuizzes() } +}