|
@@ -14,174 +14,176 @@ import (
|
|
|
)
|
|
|
|
|
|
var examPayload = `
|
|
|
-[
|
|
|
- {
|
|
|
- "id": "fe0a7ee0-f31a-413d-ba81-ab5068bc4c73",
|
|
|
- "created_at": "0001-01-01T00:00:00Z",
|
|
|
- "updated_at": "0001-01-01T00:00:00Z",
|
|
|
- "Participant": {
|
|
|
- "ID": "1234",
|
|
|
- "Firstname": "John",
|
|
|
- "Lastname": "Smith",
|
|
|
- "Token": 111222,
|
|
|
- "Attributes": {
|
|
|
- "class": "1 D LIN"
|
|
|
- }
|
|
|
- },
|
|
|
+{
|
|
|
+ "ID": "fe0a7ee0-f31a-413d-f123-ab5068bcaaaa",
|
|
|
"Name": "Test session",
|
|
|
- "Quizzes": [
|
|
|
- {
|
|
|
- "id": "0610939b-a1a3-4d0e-bbc4-2aae0e8ee4b9",
|
|
|
- "created_at": "2023-11-27T17:51:53.910642221+01:00",
|
|
|
- "updated_at": "0001-01-01T00:00:00Z",
|
|
|
- "hash": "",
|
|
|
- "question": {
|
|
|
- "id": "98c0eec9-677f-464e-9e3e-864a859f29a3",
|
|
|
- "created_at": "0001-01-01T00:00:00Z",
|
|
|
- "updated_at": "0001-01-01T00:00:00Z",
|
|
|
- "text": "Question text with #tag1."
|
|
|
- },
|
|
|
- "answers": [
|
|
|
- {
|
|
|
- "id": "1ab5ff1f-74c8-4efc-abdc-d03a3640f3bc",
|
|
|
- "text": "Answer 1"
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "74547724-b905-476f-8cfc-6ee633f92ef3",
|
|
|
- "text": "Answer 2"
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "96c1a8ee-c50c-4ebc-89e4-9f3ca356adbd",
|
|
|
- "text": "Answer 3"
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "16c4b95e-64ce-4666-8cbe-b66fa59eb23b",
|
|
|
- "text": "Answer 4"
|
|
|
- }
|
|
|
- ],
|
|
|
- "tags": [
|
|
|
- {
|
|
|
- "CreatedAt": "0001-01-01T00:00:00Z",
|
|
|
- "UpdatedAt": "0001-01-01T00:00:00Z",
|
|
|
- "DeletedAt": null,
|
|
|
- "name": "#tag1"
|
|
|
- }
|
|
|
- ],
|
|
|
- "correct": {
|
|
|
- "id": "1ab5ff1f-74c8-4efc-abdc-d03a3640f3bc",
|
|
|
- "text": "Answer 1"
|
|
|
- },
|
|
|
- "CorrectPos": 0,
|
|
|
- "type": 0
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "915818c4-b0ce-4efc-8def-7fc8d5fa7454",
|
|
|
- "created_at": "2023-11-27T17:51:53.91077796+01:00",
|
|
|
- "updated_at": "0001-01-01T00:00:00Z",
|
|
|
- "hash": "",
|
|
|
- "question": {
|
|
|
- "id": "70793f0d-2855-4140-814e-40167464424b",
|
|
|
- "created_at": "0001-01-01T00:00:00Z",
|
|
|
- "updated_at": "0001-01-01T00:00:00Z",
|
|
|
- "text": "Another question text with #tag1."
|
|
|
- },
|
|
|
- "answers": [
|
|
|
- {
|
|
|
- "id": "1ab5ff1f-74c8-4efc-abdc-d03a3640f3bc",
|
|
|
- "text": "Answer 1"
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "74547724-b905-476f-8cfc-6ee633f92ef3",
|
|
|
- "text": "Answer 2"
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "96c1a8ee-c50c-4ebc-89e4-9f3ca356adbd",
|
|
|
- "text": "Answer 3"
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "16c4b95e-64ce-4666-8cbe-b66fa59eb23b",
|
|
|
- "text": "Answer 4"
|
|
|
- }
|
|
|
- ],
|
|
|
- "tags": [
|
|
|
- {
|
|
|
- "CreatedAt": "0001-01-01T00:00:00Z",
|
|
|
- "UpdatedAt": "0001-01-01T00:00:00Z",
|
|
|
- "DeletedAt": null,
|
|
|
- "name": "#tag1"
|
|
|
- }
|
|
|
- ],
|
|
|
- "correct": {
|
|
|
- "id": "1ab5ff1f-74c8-4efc-abdc-d03a3640f3bc",
|
|
|
- "text": "Answer 1"
|
|
|
- },
|
|
|
- "CorrectPos": 0,
|
|
|
- "type": 0
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "12345678-abcd-efgh-ijkl-9876543210ef",
|
|
|
- "created_at": "2023-12-01T12:00:00Z",
|
|
|
- "updated_at": "2023-12-01T12:00:00Z",
|
|
|
- "Participant": {
|
|
|
- "ID": "5678",
|
|
|
- "Firstname": "Jane",
|
|
|
- "Lastname": "Doe",
|
|
|
- "Token": 333444,
|
|
|
- "Attributes": {
|
|
|
- "class": "2 A SCI"
|
|
|
- }
|
|
|
+ "Exams": {
|
|
|
+ "111222": {
|
|
|
+ "id": "fe0a7ee0-f31a-413d-ba81-ab5068bc4c73",
|
|
|
+ "created_at": "0001-01-01T00:00:00Z",
|
|
|
+ "updated_at": "0001-01-01T00:00:00Z",
|
|
|
+ "Participant": {
|
|
|
+ "ID": "1234",
|
|
|
+ "Firstname": "John",
|
|
|
+ "Lastname": "Smith",
|
|
|
+ "Token": "111222",
|
|
|
+ "Attributes": {
|
|
|
+ "class": "1 D LIN"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "Quizzes": [
|
|
|
+ {
|
|
|
+ "id": "0610939b-a1a3-4d0e-bbc4-2aae0e8ee4b9",
|
|
|
+ "created_at": "2023-11-27T17:51:53.910642221+01:00",
|
|
|
+ "updated_at": "0001-01-01T00:00:00Z",
|
|
|
+ "hash": "",
|
|
|
+ "question": {
|
|
|
+ "id": "98c0eec9-677f-464e-9e3e-864a859f29a3",
|
|
|
+ "created_at": "0001-01-01T00:00:00Z",
|
|
|
+ "updated_at": "0001-01-01T00:00:00Z",
|
|
|
+ "text": "Question text with #tag1."
|
|
|
+ },
|
|
|
+ "answers": [
|
|
|
+ {
|
|
|
+ "id": "1ab5ff1f-74c8-4efc-abdc-d03a3640f3bc",
|
|
|
+ "text": "Answer 1"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "id": "74547724-b905-476f-8cfc-6ee633f92ef3",
|
|
|
+ "text": "Answer 2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "id": "96c1a8ee-c50c-4ebc-89e4-9f3ca356adbd",
|
|
|
+ "text": "Answer 3"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "id": "16c4b95e-64ce-4666-8cbe-b66fa59eb23b",
|
|
|
+ "text": "Answer 4"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "tags": [
|
|
|
+ {
|
|
|
+ "CreatedAt": "0001-01-01T00:00:00Z",
|
|
|
+ "UpdatedAt": "0001-01-01T00:00:00Z",
|
|
|
+ "DeletedAt": null,
|
|
|
+ "name": "#tag1"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "correct": {
|
|
|
+ "id": "1ab5ff1f-74c8-4efc-abdc-d03a3640f3bc",
|
|
|
+ "text": "Answer 1"
|
|
|
+ },
|
|
|
+ "CorrectPos": 0,
|
|
|
+ "type": 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "id": "915818c4-b0ce-4efc-8def-7fc8d5fa7454",
|
|
|
+ "created_at": "2023-11-27T17:51:53.91077796+01:00",
|
|
|
+ "updated_at": "0001-01-01T00:00:00Z",
|
|
|
+ "hash": "",
|
|
|
+ "question": {
|
|
|
+ "id": "70793f0d-2855-4140-814e-40167464424b",
|
|
|
+ "created_at": "0001-01-01T00:00:00Z",
|
|
|
+ "updated_at": "0001-01-01T00:00:00Z",
|
|
|
+ "text": "Another question text with #tag1."
|
|
|
+ },
|
|
|
+ "answers": [
|
|
|
+ {
|
|
|
+ "id": "1ab5ff1f-74c8-4efc-abdc-d03a3640f3bc",
|
|
|
+ "text": "Answer 1"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "id": "74547724-b905-476f-8cfc-6ee633f92ef3",
|
|
|
+ "text": "Answer 2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "id": "96c1a8ee-c50c-4ebc-89e4-9f3ca356adbd",
|
|
|
+ "text": "Answer 3"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "id": "16c4b95e-64ce-4666-8cbe-b66fa59eb23b",
|
|
|
+ "text": "Answer 4"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "tags": [
|
|
|
+ {
|
|
|
+ "CreatedAt": "0001-01-01T00:00:00Z",
|
|
|
+ "UpdatedAt": "0001-01-01T00:00:00Z",
|
|
|
+ "DeletedAt": null,
|
|
|
+ "name": "#tag1"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "correct": {
|
|
|
+ "id": "1ab5ff1f-74c8-4efc-abdc-d03a3640f3bc",
|
|
|
+ "text": "Answer 1"
|
|
|
+ },
|
|
|
+ "CorrectPos": 0,
|
|
|
+ "type": 0
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
},
|
|
|
- "Name": "Test session",
|
|
|
- "Quizzes": [
|
|
|
- {
|
|
|
- "id": "22222222-abcd-efgh-ijkl-9876543210ef",
|
|
|
- "created_at": "2023-12-01T12:00:00Z",
|
|
|
- "updated_at": "2023-12-01T12:00:00Z",
|
|
|
- "hash": "",
|
|
|
- "question": {
|
|
|
- "id": "33333333-abcd-efgh-ijkl-9876543210ef",
|
|
|
- "created_at": "2023-12-01T12:00:00Z",
|
|
|
- "updated_at": "2023-12-01T12:00:00Z",
|
|
|
- "text": "Sample question text."
|
|
|
- },
|
|
|
- "answers": [
|
|
|
- {
|
|
|
- "id": "44444444-abcd-efgh-ijkl-9876543210ef",
|
|
|
- "text": "Option 1"
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "55555555-abcd-efgh-ijkl-9876543210ef",
|
|
|
- "text": "Option 2"
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "66666666-abcd-efgh-ijkl-9876543210ef",
|
|
|
- "text": "Option 3"
|
|
|
- },
|
|
|
- {
|
|
|
- "id": "77777777-abcd-efgh-ijkl-9876543210ef",
|
|
|
- "text": "Option 4"
|
|
|
- }
|
|
|
- ],
|
|
|
- "tags": [
|
|
|
- {
|
|
|
- "CreatedAt": "2023-12-01T12:00:00Z",
|
|
|
- "UpdatedAt": "2023-12-01T12:00:00Z",
|
|
|
- "DeletedAt": null,
|
|
|
- "name": "#tag2"
|
|
|
- }
|
|
|
- ],
|
|
|
- "correct": {
|
|
|
- "id": "44444444-abcd-efgh-ijkl-9876543210ef",
|
|
|
- "text": "Option 1"
|
|
|
- },
|
|
|
- "CorrectPos": 0,
|
|
|
- "type": 0
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
-]
|
|
|
+ "333444": {
|
|
|
+ "id": "12345678-abcd-efgh-ijkl-9876543210ef",
|
|
|
+ "created_at": "2023-12-01T12:00:00Z",
|
|
|
+ "updated_at": "2023-12-01T12:00:00Z",
|
|
|
+ "Participant": {
|
|
|
+ "ID": "5678",
|
|
|
+ "Firstname": "Jane",
|
|
|
+ "Lastname": "Doe",
|
|
|
+ "Token": "333444",
|
|
|
+ "Attributes": {
|
|
|
+ "class": "2 A SCI"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "Quizzes": [
|
|
|
+ {
|
|
|
+ "id": "22222222-abcd-efgh-ijkl-9876543210ef",
|
|
|
+ "created_at": "2023-12-01T12:00:00Z",
|
|
|
+ "updated_at": "2023-12-01T12:00:00Z",
|
|
|
+ "hash": "",
|
|
|
+ "question": {
|
|
|
+ "id": "33333333-abcd-efgh-ijkl-9876543210ef",
|
|
|
+ "created_at": "2023-12-01T12:00:00Z",
|
|
|
+ "updated_at": "2023-12-01T12:00:00Z",
|
|
|
+ "text": "Sample question text."
|
|
|
+ },
|
|
|
+ "answers": [
|
|
|
+ {
|
|
|
+ "id": "44444444-abcd-efgh-ijkl-9876543210ef",
|
|
|
+ "text": "Option 1"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "id": "55555555-abcd-efgh-ijkl-9876543210ef",
|
|
|
+ "text": "Option 2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "id": "66666666-abcd-efgh-ijkl-9876543210ef",
|
|
|
+ "text": "Option 3"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "id": "77777777-abcd-efgh-ijkl-9876543210ef",
|
|
|
+ "text": "Option 4"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "tags": [
|
|
|
+ {
|
|
|
+ "CreatedAt": "2023-12-01T12:00:00Z",
|
|
|
+ "UpdatedAt": "2023-12-01T12:00:00Z",
|
|
|
+ "DeletedAt": null,
|
|
|
+ "name": "#tag2"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "correct": {
|
|
|
+ "id": "44444444-abcd-efgh-ijkl-9876543210ef",
|
|
|
+ "text": "Option 1"
|
|
|
+ },
|
|
|
+ "CorrectPos": 0,
|
|
|
+ "type": 0
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+}
|
|
|
`
|
|
|
|
|
|
type serverTestSuite struct {
|
|
@@ -218,16 +220,15 @@ func (t *serverTestSuite) TestCreate() {
|
|
|
err := json.Unmarshal(response.Body.Bytes(), &result)
|
|
|
t.Nil(err)
|
|
|
|
|
|
- path := filepath.Join(GetDefaultSessionDir(), result["id"])
|
|
|
- _, err = os.Stat(path)
|
|
|
- defer os.RemoveAll(path)
|
|
|
+ path := filepath.Join(GetDefaultSessionDir(), "session_fe0a7ee0-f31a-413d-f123-ab5068bcaaaa.json")
|
|
|
|
|
|
- files, err := os.ReadDir(path)
|
|
|
+ _, err = os.Stat(path)
|
|
|
t.Nil(err)
|
|
|
|
|
|
- t.Equal(2, len(files))
|
|
|
+ defer os.Remove(path)
|
|
|
+
|
|
|
+ t.Equal("fe0a7ee0-f31a-413d-f123-ab5068bcaaaa", result["id"])
|
|
|
|
|
|
- t.Nil(err)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -255,7 +256,7 @@ func (t *serverTestSuite) TestRead() {
|
|
|
err := json.Unmarshal(response.Body.Bytes(), &result)
|
|
|
t.Nil(err)
|
|
|
|
|
|
- path := filepath.Join(GetDefaultSessionDir(), result["id"])
|
|
|
+ path := filepath.Join(GetDefaultSessionDir(), "session_fe0a7ee0-f31a-413d-f123-ab5068bcaaaa.json")
|
|
|
_, err = os.Stat(path)
|
|
|
t.Nil(err)
|
|
|
|