-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathforum_data_test.go
40 lines (34 loc) · 914 Bytes
/
forum_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
package moodle
import (
"fmt"
"testing"
)
func TestGetForumsWithCourseId(t *testing.T) {
api := NewMoodleApi(requireEnv("MOODLE_URL", t), requireEnv("MOODLE_KEY", t))
api.SetLogger(&PrintMoodleLogger{})
fmt.Println("Check for Forums")
forums, err := api.GetForumsWithCourseId([]int{194})
if err != nil {
t.Errorf("API call failed: %s", err)
return
}
if len(forums) < 1 {
t.Errorf("No results found")
return
}
for _, a := range forums {
fmt.Printf("%v,%v,%v, scale: %v, grade: %v, assessed: %v, type: %v\n", a.CourseId, a.Name, a.DueDate, a.Scale, a.Grade, a.Assessed, a.Type)
discussions, err := api.GetForumsDiscussions(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()
}