Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review Quiz Params #148

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const routes = [
...route.params,
userId: route.query.userId,
apiKey: route.query.apiKey,
review: route.query.review || null,
omrMode: route.query.omrMode
}),
// lazy-loading: https://router.vuejs.org/guide/advanced/lazy-loading.html
Expand Down
1 change: 1 addition & 0 deletions src/services/API/Endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const quizEndpoint = "/quiz/";
export const reviewQuizEndpoint = "/quiz/review/";
export const sessionsEndpoint = "/sessions/";
export const sessionAnswersEndpoint = "/session_answers/";
export const questionsEndpoint = "/questions/";
Expand Down
7 changes: 6 additions & 1 deletion src/services/API/Quiz.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { apiClient } from "./RootClient";
import { quizEndpoint } from "./Endpoints";
import { quizEndpoint, reviewQuizEndpoint } from "./Endpoints";
import { QuizAPIResponse } from "@/types";

export default {
Expand All @@ -15,4 +15,9 @@ export default {
});
return response.data;
},

async getReviewQuiz(quizId: string): Promise<QuizAPIResponse> {
const response = await apiClient().get(reviewQuizEndpoint + quizId);
return response.data;
}
};
19 changes: 15 additions & 4 deletions src/views/Player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ export default defineComponent({
default: null,
type: String,
},
review: {
default: null,
type: Boolean
},
omrMode: {
default: false,
type: Boolean
Expand Down Expand Up @@ -483,10 +487,17 @@ export default defineComponent({
}

async function getQuiz() {
const quizDetails : QuizAPIResponse = await QuizAPIService.getQuiz({
quizId: props.quizId,
omrMode: isOmrMode.value ?? false
});
let quizDetails : QuizAPIResponse;
if (props.review != null) {
// review quiz mode
quizDetails = await QuizAPIService.getReviewQuiz(props.quizId);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to check if props.review == true?

} else {
quizDetails = await QuizAPIService.getQuiz({
quizId: props.quizId,
omrMode: isOmrMode.value ?? false
});
}

// since we know that there is going to be only one
// question set for now
state.questionSets = quizDetails.question_sets;
Expand Down
Loading