-
Notifications
You must be signed in to change notification settings - Fork 0
/
distribLatex.go
62 lines (49 loc) · 1.72 KB
/
distribLatex.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package testparts
import (
"fmt"
)
func (r *ReadingCompSt) DistribLatex(testTitle string, numTest uint) []string {
return questDistrib(r.AllQuestions, r.Title, testTitle, r.Points, numTest)
}
func (m *MultipleChoiceSt) DistribLatex(testTitle string, numTest uint) []string {
return questDistrib(m.AllQuestions, m.Title, testTitle, m.Points, numTest)
}
func (w *WordProblemSt) DistribLatex(testTitle string, numTest uint) []string {
return questDistrib(w.AllQuestions, w.Title, testTitle, w.Points, numTest)
}
func (q *QuizSt) DistribLatex(testTitle string, numTest uint) []string {
return questDistrib(q.AllQuestions, q.Title, testTitle, q.Points, numTest)
}
func (c *CompQuestionsSt) DistribLatex(testTitle string, numTest uint) []string {
return questDistrib(c.AllQuestions, c.Title, testTitle, c.Points, numTest)
}
func (w *WordMatchSt) DistribLatex(testTitle string, numTest uint) []string {
return []string{}
}
func (p *PassageCompletionSt) DistribLatex(testTitle string, numTest uint) []string {
return []string{}
}
func (c *CustomSt) DistribLatex(testTitle string, numTest uint) []string {
return []string{}
}
func questDistrib(questions QuestionSetSt, title, testTitle string,
points, yMax uint) []string {
outStr := testSectionBegin(
ternary(title == "", testTitle, title),
points, "")
outStr = append(outStr, []string{
`\begin{tikzpicture}`,
fmt.Sprintf(
`\begin{axis} [ybar ,bar width=15pt, xmin=0, xmax=%d, ymin=0, ymax=%d, width=\linewidth]`,
questions.Size()+1, yMax),
`\addplot coordinates {`,
}...)
questions.Each(func(qi int, q *QuestionsSt) {
outStr = append(outStr, fmt.Sprintf(`(%d, %d)`, qi+1, q.Used))
})
return append(outStr, []string{
`};`,
`\end{axis}`,
`\end{tikzpicture}`,
}...)
}