-
Notifications
You must be signed in to change notification settings - Fork 0
/
getQuizRubric.js
48 lines (43 loc) · 1.51 KB
/
getQuizRubric.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
40
41
42
43
44
45
46
47
48
const { flatten } = require('ramda')
const canvasAPI = require('node-canvas-api')
// const writeQuizRubricToCSV = require('./writeQuizRubricToCSV')
async function getQuizRubric (courseId, quizId, rubricId) {
const [quizSubmissions, rubric, sections] = await Promise.all([
canvasAPI.getQuizSubmissions(courseId, quizId)
.then(submissions =>
flatten(submissions.map(x => x.quiz_submissions))
),
canvasAPI.getRubric(courseId, rubricId),
canvasAPI.getSections(courseId, canvasAPI.getOptions.users.include.students)
.then(sections => flatten(
sections
.map(({ name, students }) => students
.map(student => ({ ...student, section: name }))
)
))
])
return rubric.assessments.map(assessment => {
// get student info
const submissionId = assessment.artifact_id
const submission = quizSubmissions
.find(submission => submission.submission_id === submissionId) || {}
const studentId = submission.user_id || ''
const student = sections
.find(student => student.id === studentId) || {}
const studentName = student.name || ''
const studentNumber = student.sis_user_id || ''
const section = student.section || ''
// get rubric info
const totalGrade = assessment.score
const rubricData = assessment.data
.map(({ points, comments }) => ({ points, comments }))
return {
studentName,
studentNumber,
totalGrade,
rubricData,
section
}
})
}
module.exports = getQuizRubric