2021-09-04 22:27:00 +03:00
|
|
|
import { ROUTES } from './constants';
|
2021-07-01 09:31:26 +03:00
|
|
|
|
2021-09-11 21:52:46 +03:00
|
|
|
export function getGroupMemberId(people, profileId) {
|
|
|
|
|
const groupMember = people.find((person) => person.profile_id === profileId);
|
|
|
|
|
|
|
|
|
|
return groupMember ? groupMember.id : null;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-01 09:31:26 +03:00
|
|
|
export function getNavItemRoute(courseId, routeId) {
|
|
|
|
|
const path = `/${ROUTES.COURSES}/${courseId}`;
|
|
|
|
|
|
|
|
|
|
if (!routeId) {
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return `${path}/${routeId}`;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 05:55:57 +03:00
|
|
|
export function getLessonsRoute(courseId, lessonId) {
|
|
|
|
|
const path = getNavItemRoute(courseId, ROUTES.LESSONS);
|
2021-07-01 09:31:26 +03:00
|
|
|
|
2021-07-12 05:55:57 +03:00
|
|
|
if (!lessonId) {
|
2021-07-01 09:31:26 +03:00
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 05:55:57 +03:00
|
|
|
return `${path}/${lessonId}`;
|
2021-07-01 09:31:26 +03:00
|
|
|
}
|
|
|
|
|
|
2023-08-03 02:51:02 +01:00
|
|
|
export function getLectureNo(index, initNo = '0') {
|
2021-11-07 13:44:33 +02:00
|
|
|
if (index <= 9) {
|
2022-12-30 13:08:54 +01:00
|
|
|
return `${initNo}${index}`;
|
2021-07-01 09:31:26 +03:00
|
|
|
}
|
|
|
|
|
|
2023-08-03 02:51:02 +01:00
|
|
|
return index;
|
2021-07-01 09:31:26 +03:00
|
|
|
}
|
2021-09-04 22:27:00 +03:00
|
|
|
|
|
|
|
|
export function formatAnswers(data) {
|
|
|
|
|
const answers = {};
|
|
|
|
|
const questionByIdAndName = {};
|
|
|
|
|
|
|
|
|
|
for (const question of data.questions) {
|
|
|
|
|
questionByIdAndName[question.id] = question.name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const answer of data.answers) {
|
|
|
|
|
const questionName = questionByIdAndName[answer.question_id];
|
|
|
|
|
|
|
|
|
|
answers[questionName] =
|
2023-08-03 02:51:02 +01:00
|
|
|
Array.isArray(answer.answers) && answer.answers.length ? answer.answers : answer.open_answer;
|
2021-09-04 22:27:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return answers;
|
|
|
|
|
}
|