forked from zaddok/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquiz_data_test.go
44 lines (36 loc) · 969 Bytes
/
quiz_data_test.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
package moodle
import (
"fmt"
"testing"
)
func TestGetQuizzesWithCourseId(t *testing.T) {
api := NewMoodleApi(requireEnv("MOODLE_URL", t), requireEnv("MOODLE_KEY", t))
api.SetLogger(&PrintMoodleLogger{})
fmt.Println("Check for Quizzes")
quizzes, err := api.GetQuizzesWithCourseId([]int{36})
if err != nil {
t.Errorf("API call failed: %s", err)
return
}
if len(quizzes) < 1 {
fmt.Println("No quizzes found")
return
}
for _, a := range quizzes {
fmt.Printf("id: %d, course: %d, %v,%v, grademethod: %v, grade: %v, behaviour: %v\n", a.Id, a.CourseId, a.Name, a.TimeClose, a.GradeMethod, a.Grade, a.PreferredBehaviour)
/*
discussions, err := api.GetQuizResults(int(a.Id))
if err != nil {
t.Errorf("API call failed: %s", err)
return
}
if len(discussions) < 1 {
fmt.Println(" No discussions found")
}
for _, d := range discussions {
fmt.Println(" ", d.Id, d.Name, d.Created)
}
*/
}
fmt.Println()
}