-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathquizzes.js
39 lines (35 loc) · 892 Bytes
/
quizzes.js
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
module.exports = function (included = [], type, config) {
if (typeof type === 'object') {
config = type
}
if (type === 'deserialize') {
return {
keyForAttribute: 'camelCase',
questions: {
valueForRelationship (relationship) {
return relationship.id
}
}
}
}
const options = {
attributes: ['title', 'description', 'image', 'duration', 'maxAttempts', 'startDate', 'endDate', 'user', 'questions', 'maxMarks'],
meta: {
pagination: function (record) {
return record.pagination
}
},
user: {
ref: 'id',
attributes: ['firstname', 'lastname', 'email', 'role'],
included: included.includes('user')
},
questions: {
ref: 'id',
...require('./questions')([], 'serialize'),
included: included.includes('questions')
},
...config
}
return options
}