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
- fixed autograded assessment button alignment
  • Loading branch information
adi-herwana-nus committed Jul 4, 2024
1 parent 9d26998 commit 6877616
Show file tree
Hide file tree
Showing 7 changed files with 318 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,57 @@ export function initializeLiveFeedback(questionId) {
});
}

export function generateLiveFeedback(submissionId, answerId, questionId) {
// if status returned 200, populate feedback array if has feedback, otherwise return error
const handleFeedbackOKResponse = ({
dispatch,
response,
answerId,
questionId,
successMessage,
noFeedbackMessage,
}) => {
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(successMessage));
} else {
dispatch({
type: actionTypes.LIVE_FEEDBACK_FAILURE,
payload: {
questionId,
},
});
dispatch(setNotification(noFeedbackMessage));
}
};

export function generateLiveFeedback({
submissionId,
answerId,
questionId,
successMessage,
noFeedbackMessage,
}) {
return (dispatch) =>
CourseAPI.assessment.submissions
.generateLiveFeedback(submissionId, { answer_id: answerId })
.then((response) => {
if (response.status === 200) {
dispatch({
type: actionTypes.LIVE_FEEDBACK_SUCCESS,
payload: {
questionId,
answerId,
feedbackFiles: response.data?.data?.feedbackFiles ?? {},
},
handleFeedbackOKResponse({
dispatch,
response,
answerId,
questionId,
successMessage,
noFeedbackMessage,
});
} else {
// 201, save feedback signed token
Expand All @@ -267,26 +305,26 @@ export function generateLiveFeedback(submissionId, answerId, questionId) {
});
}

// TODO should each answer/question store its own feedback array?
export function fetchLiveFeedback(
export function fetchLiveFeedback({
answerId,
questionId,
feedbackUrl,
feedbackToken,
) {
successMessage,
noFeedbackMessage,
}) {
return (dispatch) =>
CourseAPI.assessment.submissions
.fetchLiveFeedback(feedbackUrl, feedbackToken)
.then((response) => {
// if 200, go straight to LIVE_FEEDBACK_SUCCESS
if (response.status === 200) {
dispatch({
type: actionTypes.LIVE_FEEDBACK_SUCCESS,
payload: {
questionId,
answerId,
feedbackFiles: response.data?.data?.feedbackFiles ?? {},
},
handleFeedbackOKResponse({
dispatch,
response,
answerId,
questionId,
successMessage,
noFeedbackMessage,
});
}
})
Expand Down
Loading

0 comments on commit 6877616

Please sign in to comment.