fix: if empty que title not render answers

This commit is contained in:
skeris 2025-06-17 17:21:37 +03:00
parent d0d7b1af55
commit 19cba7f57e
3 changed files with 11 additions and 5 deletions

@ -483,7 +483,7 @@
</tr> </tr>
{{ range .AllAnswers }} {{ range .AllAnswers }}
{{ if index $.QuestionsMap .AnswerID }} {{ if keyExists $.QuestionsMap .AnswerID }}
<tr> <tr>
<td colspan="2" style="padding: 0"> <td colspan="2" style="padding: 0">
<table <table

@ -6,9 +6,10 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"gitea.pena/SQuiz/common/model"
"golang.org/x/net/html" "golang.org/x/net/html"
"html/template" "html/template"
"gitea.pena/SQuiz/common/model" "io"
"strings" "strings"
) )
@ -54,6 +55,10 @@ func generateTextFromTemplate(data TemplateData, tpl string) (string, error) {
} }
var tmplFuncs = template.FuncMap{ var tmplFuncs = template.FuncMap{
"keyExists": func(m map[uint64]string, key uint64) bool {
_, ok := m[key]
return ok
},
"renderImage": RenderImage, "renderImage": RenderImage,
} }

@ -80,6 +80,7 @@
<tr> <tr>
<td colspan="2" style="height: 100%"> <td colspan="2" style="height: 100%">
<a <a
href="https://quiz.pena.digital/results/{{ .QuizID }}"
style=" style="
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -482,7 +483,7 @@
</tr> </tr>
{{ range .AllAnswers }} {{ range .AllAnswers }}
{{ if index $.QuestionsMap .AnswerID }} {{ if keyExists $.QuestionsMap .AnswerID }}
<tr> <tr>
<td colspan="2" style="padding: 0"> <td colspan="2" style="padding: 0">
<table <table