forked from rage/java-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquizzes.js
More file actions
36 lines (29 loc) · 1.07 KB
/
Copy pathquizzes.js
File metadata and controls
36 lines (29 loc) · 1.07 KB
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
import axios from "axios"
import { accessToken, getCourseVariant } from "./moocfi"
import CourseSettings from "../../course-settings"
// const id = CourseSettings.quizzesId
const language = CourseSettings.default.language
const quizzesLanguage = language === "en" ? "en_US" : "fi_FI"
export async function fetchQuizzesProgress() {
let id = CourseSettings.default.quizzesId
const courseVariant = await getCourseVariant()
if (courseVariant === "ii") {
id = "7d32559c-5b3d-4c30-bd8e-11e8408359fd"
}
const response = await axios.get(
`https://quizzes.mooc.fi/api/v1/courses/${id}/users/current/progress`,
{ headers: { Authorization: `Bearer ${accessToken()}` } },
)
return response.data?.points_by_group
}
export async function fetchQuizNames() {
let id = CourseSettings.default.quizzesId
const courseVariant = await getCourseVariant()
if (courseVariant === "ii") {
id = "7d32559c-5b3d-4c30-bd8e-11e8408359fd"
}
const response = await axios.get(
`https://quizzes.mooc.fi/api/v1/quizzes/${id}/titles/${quizzesLanguage}`,
)
return response.data
}