Skip to content

Commit

Permalink
feature(codaveri-live-feedback): frontend tweaks
Browse files Browse the repository at this point in the history
- tweaked live feedback component styling
- live feedback drawer now closes only when all feedback is deleted
- added toast messages for successful feedback / no feedback generated
  • Loading branch information
adi-herwana-nus committed Jul 4, 2024
1 parent c108b59 commit e349de0
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ export function generateLiveFeedback(submissionId, answerId, questionId) {
});
}

// TODO should each answer/question store its own feedback array?
export function fetchLiveFeedback(
answerId,
questionId,
Expand All @@ -278,17 +277,31 @@ export function fetchLiveFeedback(
CourseAPI.assessment.submissions
.fetchLiveFeedback(feedbackUrl, feedbackToken)
.then((response) => {
// if 200, go straight to LIVE_FEEDBACK_SUCCESS
// if 200, populate feedback array if has feedback, otherwise return error
if (response.status === 200) {
dispatch({
type: actionTypes.LIVE_FEEDBACK_SUCCESS,
payload: {
questionId,
answerId,
feedbackFiles: response.data?.data?.feedbackFiles ?? {},
},
});
const feedbackFiles = response.data?.data?.feedbackFiles ?? [];
const success = response.data?.success;
if (success && feedbackFiles.length) {
dispatch({
type: actionTypes.LIVE_FEEDBACK_SUCCESS,
payload: {
questionId,
answerId,
feedbackFiles,
},
});
dispatch(setNotification(translations.liveFeedbackSuccess));
} else {
dispatch({
type: actionTypes.LIVE_FEEDBACK_FAILURE,
payload: {
questionId,
},
});
dispatch(setNotification(translations.liveFeedbackNoneGenerated));
}
}
return response;
})
.catch(() => {
dispatch({
Expand Down
Loading

0 comments on commit e349de0

Please sign in to comment.