Read quizzes from disk and render the UI

This commit is contained in:
andrea 2023-07-06 13:49:56 +02:00
parent 381a4973c9
commit ca4d06b7b1
10 changed files with 35 additions and 39 deletions

6
app.go
View file

@ -2,7 +2,6 @@ package main
import ( import (
"context" "context"
"fmt"
"git.andreafazzi.eu/andrea/probo/models" "git.andreafazzi.eu/andrea/probo/models"
"git.andreafazzi.eu/andrea/probo/store/file" "git.andreafazzi.eu/andrea/probo/store/file"
@ -35,11 +34,6 @@ func (a *App) startup(ctx context.Context) {
a.ctx = ctx 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) { func (a *App) ReadAllQuizzes() ([]*models.Quiz, error) {
return a.store.ReadAllQuizzes() return a.store.ReadAllQuizzes()
} }

View file

@ -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 magnetico con campo elettrico
* Campo gravitazionale con campo elettrico * Campo gravitazionale con campo elettrico

6
data/quizzes/test_2.md Normal file
View file

@ -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

View file

@ -1,3 +1,8 @@
<script lang="ts">
import { models } from "$lib/wailsjs/go/models"
export let quiz: models.Quiz
</script>
<div class="card p-4 my-3 mx-4 font-heading-token"> <div class="card p-4 my-3 mx-4 font-heading-token">
<header class="p-3"> <header class="p-3">
<div class="flex justify-between"> <div class="flex justify-between">
@ -13,31 +18,21 @@
</svg> </svg>
</button> </button>
</div> </div>
<span class="badge variant-ghost-secondary"><h1 class="text-xs">1ad25d0000…</h1></span> <span class="badge variant-ghost-secondary"><h1 class="text-xs">{quiz.hash.slice(0,10)+'…'}</h1></span>
</div> </div>
</header> </header>
<hr class="opacity-50" /> <hr class="opacity-50" />
<p class="p-4"> <p class="p-4">
Per intensità di corrente elettrica si intende {quiz.question.Text}
</p> </p>
<form id="question1"> <form id="form-id-{quiz.id}">
<div class="space-y-2 p-4"> <div class="space-y-2 p-4">
<label class="flex items-center space-x-2"> {#each quiz.answers as answer}
<input class="radio" type="radio" checked name="radio-direct" value="1" /> <label class="flex items-center space-x-2">
<p>La quantità di carica che scorre in un circuito per unità di tempo</p> <input class="radio" type="radio" checked name="radio-direct" value="{answer.ID}" />
</label> <p>{answer.Text}</p>
<label class="flex items-center space-x-2"> </label>
<input class="radio" type="radio" name="radio-direct" value="2" /> {/each}
<p>La differenza di potenziale elettrico</p>
</label>
<label class="flex items-center space-x-2">
<input class="radio" type="radio" name="radio-direct" value="3" />
<p>La quantità di carica elettrica</p>
</label>
<label class="flex items-center space-x-2">
<input class="radio" type="radio" name="radio-direct" value="3" />
<p>L'accelerazione a cui sono sottoposti gli elettroni all'interno del circuito</p>
</label>
</div> </div>
</form> </form>
<hr class="opacity-50" /> <hr class="opacity-50" />

View file

@ -2,6 +2,4 @@
// This file is automatically generated. DO NOT EDIT // This file is automatically generated. DO NOT EDIT
import {models} from '../models'; import {models} from '../models';
export function Greet(arg1:string):Promise<string>;
export function ReadAllQuizzes():Promise<Array<models.Quiz>>; export function ReadAllQuizzes():Promise<Array<models.Quiz>>;

View file

@ -2,10 +2,6 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT // This file is automatically generated. DO NOT EDIT
export function Greet(arg1) {
return window['go']['main']['App']['Greet'](arg1);
}
export function ReadAllQuizzes() { export function ReadAllQuizzes() {
return window['go']['main']['App']['ReadAllQuizzes'](); return window['go']['main']['App']['ReadAllQuizzes']();
} }

View file

@ -7,7 +7,7 @@
import '../app.postcss'; import '../app.postcss';
import { AppShell, AppBar, AppRail, AppRailTile, AppRailAnchor } from '@skeletonlabs/skeleton'; import { AppShell, AppBar, AppRail, AppRailTile, AppRailAnchor } from '@skeletonlabs/skeleton';
let currentTile; let currentTile;
</script> </script>
@ -24,7 +24,7 @@
<path d="M4.462 19.462c.42-.419.753-.89 1-1.394.453.213.902.434 1.347.661a6.743 6.743 0 01-1.286 1.794.75.75 0 11-1.06-1.06z" /> <path d="M4.462 19.462c.42-.419.753-.89 1-1.394.453.213.902.434 1.347.661a6.743 6.743 0 01-1.286 1.794.75.75 0 11-1.06-1.06z" />
</svg> </svg>
</span> </span>
<strong class="text-xl uppercase">Probo</strong> <strong class="text-xl uppercase">Probo</strong>
</svelte:fragment> </svelte:fragment>
<svelte:fragment slot="trail"> <svelte:fragment slot="trail">
<a <a

View file

@ -0,0 +1 @@
export const ssr = false

View file

@ -1,7 +1,9 @@
<script lang="ts"> <script lang="ts">
import QuizCard from "$lib/components/QuizCard.svelte" import QuizCard from "$lib/components/QuizCard.svelte"
export let data;
</script> </script>
<div class="h-full flex flex-col"> <div class="h-full flex flex-col">
<button type="button" class="btn sticky top-0 mt-4 mx-4 variant-ghost-secondary"> <button type="button" class="btn sticky top-0 mt-4 mx-4 variant-ghost-secondary">
@ -11,8 +13,7 @@
</span> </span>
<span>Add a new quiz</span> <span>Add a new quiz</span>
</button> </button>
{#each data.quizzes as quiz}
<QuizCard /> <QuizCard {quiz} />
{/each}
</div> </div>

View file

@ -0,0 +1,5 @@
import { ReadAllQuizzes } from "$lib/wailsjs/go/main/App"
export async function load() {
return { quizzes: await ReadAllQuizzes() }
}