2025-06-10 21:09:58 +02:00
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.819
package component
//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
import (
"bytes"
"context"
2025-06-15 14:46:32 +02:00
"fmt"
2025-06-10 21:09:58 +02:00
"forge.cadoles.com/wpetit/kouiz/internal/http/form"
common "forge.cadoles.com/wpetit/kouiz/internal/http/handler/webui/common/component"
2025-06-13 16:55:46 +02:00
"forge.cadoles.com/wpetit/kouiz/internal/store"
2025-06-10 21:09:58 +02:00
"github.com/pkg/errors"
"github.com/yuin/goldmark"
"log/slog"
2025-06-15 14:46:32 +02:00
"slices"
"strconv"
"time"
2025-06-10 21:09:58 +02:00
)
type QuizPageVModel struct {
2025-06-15 14:46:32 +02:00
Player * store . Player
CurrentTurn * store . QuizTurn
2025-06-15 16:44:44 +02:00
PlayDelay time . Duration
2025-06-16 00:07:03 +02:00
IsOffDay bool
2025-06-10 21:09:58 +02:00
}
2025-06-15 14:46:32 +02:00
func NewSelectEntryForm ( ) * form . Form {
2025-06-10 21:09:58 +02:00
return form . New (
form . NewField (
2025-06-15 14:46:32 +02:00
"entry" ,
form . Attrs { } ,
form . NonEmpty ( "Ce champ ne doit pas être vide." ) ,
) ,
)
}
func NewAnswerForm ( ) * form . Form {
return form . New (
form . NewField (
"answer" ,
2025-06-10 21:09:58 +02:00
form . Attrs { } ,
form . NonEmpty ( "Ce champ ne doit pas être vide." ) ,
) ,
)
}
func QuizPage ( vmodel QuizPageVModel ) templ . Component {
return templruntime . GeneratedTemplate ( func ( templ_7745c5c3_Input templruntime . GeneratedComponentInput ) ( templ_7745c5c3_Err error ) {
templ_7745c5c3_W , ctx := templ_7745c5c3_Input . Writer , templ_7745c5c3_Input . Context
if templ_7745c5c3_CtxErr := ctx . Err ( ) ; templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer , templ_7745c5c3_IsBuffer := templruntime . GetBuffer ( templ_7745c5c3_W )
if ! templ_7745c5c3_IsBuffer {
defer func ( ) {
templ_7745c5c3_BufErr := templruntime . ReleaseBuffer ( templ_7745c5c3_Buffer )
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
} ( )
}
ctx = templ . InitializeContext ( ctx )
templ_7745c5c3_Var1 := templ . GetChildren ( ctx )
if templ_7745c5c3_Var1 == nil {
templ_7745c5c3_Var1 = templ . NopComponent
}
ctx = templ . ClearChildren ( ctx )
templ_7745c5c3_Var2 := templruntime . GeneratedTemplate ( func ( templ_7745c5c3_Input templruntime . GeneratedComponentInput ) ( templ_7745c5c3_Err error ) {
templ_7745c5c3_W , ctx := templ_7745c5c3_Input . Writer , templ_7745c5c3_Input . Context
templ_7745c5c3_Buffer , templ_7745c5c3_IsBuffer := templruntime . GetBuffer ( templ_7745c5c3_W )
if ! templ_7745c5c3_IsBuffer {
defer func ( ) {
templ_7745c5c3_BufErr := templruntime . ReleaseBuffer ( templ_7745c5c3_Buffer )
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
} ( )
}
ctx = templ . InitializeContext ( ctx )
2025-06-15 14:46:32 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 1 , "<h2 class=\"title is-size-3\">Tour #" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . FormatUint ( uint64 ( vmodel . CurrentTurn . ID ) , 10 ) )
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 49 , Col : 91 }
2025-06-15 14:46:32 +02:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var3 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 2 , "</h2>" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
if vmodel . IsOffDay {
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 3 , "<div class=\"message is-warning\"><div class=\"message-header\"><p>Jeu désactivé aujourd'hui</p></div><div class=\"message-body\"><div class=\"content\"><p>Désolé, le jeu est désactivé pour la journée. Revenez prochainement pour le prochain tour !</p></div></div></div>" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else if vmodel . Player . PlayedAt . After ( vmodel . CurrentTurn . StartedAt ) {
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 4 , "<div class=\"content has-text-centered is-size-5\"></div><div class=\"message is-info\"><div class=\"message-header\"><p>En attente du prochain tour</p></div><div class=\"message-body\"><div class=\"content\"><p>Il commencera dans " )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Var4 , templ_7745c5c3_Err = templ . JoinStringErrs ( vmodel . CurrentTurn . EndedAt . Local ( ) . Sub ( time . Now ( ) . Local ( ) ) . Round ( time . Second ) . String ( ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 69 , Col : 116 }
2025-06-15 14:46:32 +02:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var4 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 5 , ".</p></div></div></div>" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else if vmodel . Player . SelectedEntry == nil || vmodel . Player . SelectedTurn == nil || * vmodel . Player . SelectedTurn != vmodel . CurrentTurn . ID {
templ_7745c5c3_Err = QuizQuestionSelector ( vmodel ) . Render ( ctx , templ_7745c5c3_Buffer )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = QuizQuestion ( vmodel ) . Render ( ctx , templ_7745c5c3_Buffer )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-06-10 21:09:58 +02:00
return nil
} )
templ_7745c5c3_Err = common . AppPage ( common . WithPageOptions (
2025-06-15 16:44:44 +02:00
common . WithTitle ( fmt . Sprintf ( "Tour #%d" , vmodel . CurrentTurn . ID ) ) ,
2025-06-10 21:09:58 +02:00
) ) . Render ( templ . WithChildren ( ctx , templ_7745c5c3_Var2 ) , templ_7745c5c3_Buffer )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
} )
}
2025-06-15 14:46:32 +02:00
func QuizQuestionSelector ( vmodel QuizPageVModel ) templ . Component {
return templruntime . GeneratedTemplate ( func ( templ_7745c5c3_Input templruntime . GeneratedComponentInput ) ( templ_7745c5c3_Err error ) {
templ_7745c5c3_W , ctx := templ_7745c5c3_Input . Writer , templ_7745c5c3_Input . Context
if templ_7745c5c3_CtxErr := ctx . Err ( ) ; templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer , templ_7745c5c3_IsBuffer := templruntime . GetBuffer ( templ_7745c5c3_W )
if ! templ_7745c5c3_IsBuffer {
defer func ( ) {
templ_7745c5c3_BufErr := templruntime . ReleaseBuffer ( templ_7745c5c3_Buffer )
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
} ( )
}
ctx = templ . InitializeContext ( ctx )
templ_7745c5c3_Var5 := templ . GetChildren ( ctx )
if templ_7745c5c3_Var5 == nil {
templ_7745c5c3_Var5 = templ . NopComponent
}
ctx = templ . ClearChildren ( ctx )
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 6 , "<form action=\"" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 templ . SafeURL = common . BaseURL ( ctx , common . WithPath ( "/quiz/select" ) )
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( string ( templ_7745c5c3_Var6 ) ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 7 , "\" method=\"post\"><h3 class=\"title is-size-3\">Choisissez votre prochaine question</h3><div class=\"message is-info\"><div class=\"message-body\"><p><strong>Attention</strong>, une fois la thématique sélectionnée vous aurez <strong>" )
2025-06-15 16:44:44 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7 , templ_7745c5c3_Err = templ . JoinStringErrs ( vmodel . PlayDelay . String ( ) )
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 87 , Col : 118 }
2025-06-15 16:44:44 +02:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var7 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 8 , " pour répondre</strong>. Faites le bon choix !</p></div></div>" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _ , entry := range vmodel . CurrentTurn . Entries {
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 9 , "<div class=\"box\"><div class=\"level mx-5\"><div class=\"level-left\"><div class=\"level-item\"><div class=\"content\"><p class=\"title\">" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
2025-06-15 16:44:44 +02:00
templ_7745c5c3_Var8 , templ_7745c5c3_Err = templ . JoinStringErrs ( entry . Category . Theme )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 98 , Col : 31 }
2025-06-15 14:46:32 +02:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var8 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 10 , "</p><p class=\"subtitle\">" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
2025-06-15 16:44:44 +02:00
templ_7745c5c3_Var9 , templ_7745c5c3_Err = templ . JoinStringErrs ( entry . Category . Name )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 100 , Col : 49 }
2025-06-15 14:46:32 +02:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var9 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 11 , "</p><div class=\"content is-italic\"><p>" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var10 string
2025-06-15 16:44:44 +02:00
templ_7745c5c3_Var10 , templ_7745c5c3_Err = templ . JoinStringErrs ( entry . Category . Description )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 102 , Col : 40 }
2025-06-15 14:46:32 +02:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var10 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 12 , "</p></div></div></div></div><div class=\"level-right\"><div class=\"level-item\"><div class=\"content\"><p class=\"is-size-4 is-family-secondary has-text-right\" style=\"width:300px\"><span></span> <span class=\"has-text-weight-bold\">" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var11 string
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Var11 , templ_7745c5c3_Err = templ . JoinStringErrs ( store . DifficultyLevel ( entry . Level ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 111 , Col : 94 }
2025-06-15 14:46:32 +02:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var11 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 13 , "</span><br><span>+" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var12 string
2025-06-15 16:44:44 +02:00
templ_7745c5c3_Var12 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . FormatInt ( int64 ( ( entry . Level + 1 ) * 2 ) , 10 ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 113 , Col : 65 }
2025-06-15 14:46:32 +02:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var12 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 14 , " points</span></p></div></div><div class=\"level-item\"><button class=\"button is-large ml-5\" name=\"entry\" value=\"" )
2025-06-15 16:44:44 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . FormatInt ( int64 ( entry . ID ) , 10 ) )
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 118 , Col : 103 }
2025-06-15 16:44:44 +02:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var13 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 15 , "\"><span class=\"icon\"><i class=\"fas fa-chevron-right\"></i></span></button></div></div></div></div>" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 16 , "</form>" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
} )
}
func QuizQuestion ( vmodel QuizPageVModel ) templ . Component {
return templruntime . GeneratedTemplate ( func ( templ_7745c5c3_Input templruntime . GeneratedComponentInput ) ( templ_7745c5c3_Err error ) {
templ_7745c5c3_W , ctx := templ_7745c5c3_Input . Writer , templ_7745c5c3_Input . Context
if templ_7745c5c3_CtxErr := ctx . Err ( ) ; templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer , templ_7745c5c3_IsBuffer := templruntime . GetBuffer ( templ_7745c5c3_W )
if ! templ_7745c5c3_IsBuffer {
defer func ( ) {
templ_7745c5c3_BufErr := templruntime . ReleaseBuffer ( templ_7745c5c3_Buffer )
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
} ( )
}
ctx = templ . InitializeContext ( ctx )
2025-06-15 16:44:44 +02:00
templ_7745c5c3_Var14 := templ . GetChildren ( ctx )
if templ_7745c5c3_Var14 == nil {
templ_7745c5c3_Var14 = templ . NopComponent
2025-06-15 14:46:32 +02:00
}
ctx = templ . ClearChildren ( ctx )
selectedEntryIndex := slices . IndexFunc ( vmodel . CurrentTurn . Entries , func ( e * store . QuizEntry ) bool {
return vmodel . Player . SelectedEntry != nil && * vmodel . Player . SelectedEntry == e . ID
} )
selectedEntry := vmodel . CurrentTurn . Entries [ selectedEntryIndex ]
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 17 , "<div class=\"content\"><p class=\"title is-size-3\">" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-15 16:44:44 +02:00
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15 , templ_7745c5c3_Err = templ . JoinStringErrs ( selectedEntry . Question )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 138 , Col : 27 }
2025-06-15 14:46:32 +02:00
}
2025-06-15 16:44:44 +02:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var15 ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 18 , "</p><p class=\"subtitle\">" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-15 16:44:44 +02:00
var templ_7745c5c3_Var16 string
templ_7745c5c3_Var16 , templ_7745c5c3_Err = templ . JoinStringErrs ( selectedEntry . Category . Name )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 140 , Col : 51 }
2025-06-15 14:46:32 +02:00
}
2025-06-15 16:44:44 +02:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var16 ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 19 , " - " )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-15 16:44:44 +02:00
var templ_7745c5c3_Var17 string
templ_7745c5c3_Var17 , templ_7745c5c3_Err = templ . JoinStringErrs ( selectedEntry . Category . Theme )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 140 , Col : 86 }
2025-06-15 14:46:32 +02:00
}
2025-06-15 16:44:44 +02:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var17 ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 20 , "</p></div><form action=\"" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-15 16:44:44 +02:00
var templ_7745c5c3_Var18 templ . SafeURL = common . BaseURL ( ctx , common . WithPath ( "/quiz/answer" ) )
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( string ( templ_7745c5c3_Var18 ) ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 21 , "\" method=\"post\">" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for index , proposition := range selectedEntry . Propositions {
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 22 , "<div class=\"box\"><div class=\"level\"><div class=\"level-left\"><div class=\"level-item\"><div class=\"content\"><p class=\"has-font-weight-bold is-size-4\"><span class=\"has-text-grey\t\">" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-15 16:44:44 +02:00
var templ_7745c5c3_Var19 string
templ_7745c5c3_Var19 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . FormatInt ( int64 ( index ) , 10 ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 150 , Col : 75 }
2025-06-15 14:46:32 +02:00
}
2025-06-15 16:44:44 +02:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var19 ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 23 , ".</span> <span class=\"is-family-secondary\">" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-15 16:44:44 +02:00
var templ_7745c5c3_Var20 string
templ_7745c5c3_Var20 , templ_7745c5c3_Err = templ . JoinStringErrs ( proposition )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 150 , Col : 133 }
2025-06-15 14:46:32 +02:00
}
2025-06-15 16:44:44 +02:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var20 ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 24 , "</span></p></div></div></div><div class=\"level-right\"><div class=\"level-item\"><button class=\"button is-large ml-5\" name=\"answer\" value=\"" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-15 16:44:44 +02:00
var templ_7745c5c3_Var21 string
templ_7745c5c3_Var21 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . FormatInt ( int64 ( index ) , 10 ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 157 , Col : 101 }
2025-06-15 14:46:32 +02:00
}
2025-06-15 16:44:44 +02:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var21 ) )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 25 , "\"><span class=\"icon\"><i class=\"fas fa-chevron-right\"></i></span></button></div></div></div></div>" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 26 , "</form>" )
2025-06-15 16:44:44 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
remainingSeconds := vmodel . Player . SelectedAt . Add ( vmodel . PlayDelay ) . Sub ( time . Now ( ) . UTC ( ) ) . Seconds ( )
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 27 , "<progress id=\"question-timer\" class=\"progress is-info is-small mt-5\" value=\"" )
2025-06-15 16:44:44 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var22 string
templ_7745c5c3_Var22 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . FormatInt ( int64 ( remainingSeconds ) , 10 ) )
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 167 , Col : 124 }
2025-06-15 16:44:44 +02:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var22 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 28 , "\" max=\"" )
2025-06-15 16:44:44 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var23 string
templ_7745c5c3_Var23 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . FormatInt ( int64 ( remainingSeconds ) , 10 ) )
if templ_7745c5c3_Err != nil {
2025-06-16 00:07:03 +02:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` internal/http/handler/webui/quiz/component/quiz_page.templ ` , Line : 167 , Col : 179 }
2025-06-15 16:44:44 +02:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var23 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-06-16 00:07:03 +02:00
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 29 , "\"></progress><script>\n\t\t(function(){\n\t\t\tconst element = document.getElementById(\"question-timer\")\n\t\t\tconst updateProgress = () => {\n\t\t\t\telement.value = parseInt(element.value)-1;\n\t\t\t\tsetTimeout(updateProgress, 1000);\n\t\t\t};\n\t\t\tsetTimeout(updateProgress, 1000);\n\t\t}());\n\t</script>" )
2025-06-15 14:46:32 +02:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
} )
}
2025-06-10 21:09:58 +02:00
func markdownToHTML ( ctx context . Context , text string ) string {
var buff bytes . Buffer
if err := goldmark . Convert ( [ ] byte ( text ) , & buff ) ; err != nil {
slog . ErrorContext ( ctx , "could not convert markdown to html" , slog . Any ( "error" , errors . WithStack ( err ) ) )
return ""
}
return buff . String ( )
}
var _ = templruntime . GeneratedTemplate