Skip to content

Commit

Permalink
refactor: use individual endpoint to get assessment feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanttV committed Feb 22, 2024
1 parent 6736a65 commit 0080e16
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/containers/ListView/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const messages = defineMessages({
},
problemSteps: {
id: 'ora-grading.ListView.problemSteps',
defaultMessage: 'Problem Steps',
defaultMessage: 'Problem steps',
description: 'problem steps column text for submission response list',
},
problemStepsTraining: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const messages = defineMessages({
},
idAssessmentColumnTitle: {
id: 'ora-grading.ReviewProblemStepsContent.idAssessmentColumnTitle',
defaultMessage: 'ID Assessment',
defaultMessage: 'ID assessment',
description: 'ORA Grading ID Assessment column title',
},
reviewerNameColumnTitle: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export const useFeedbackList = (submissionUUID) => {
if (submissionUUID) {
setIsLoadingFeedbackList(true);
try {
const data = await api.getFeedbackList(submissionUUID, feedbackListType);
let data;
if (feedbackListType === 'received') {
data = await api.getFeedbackFromList(submissionUUID);
} else {
data = await api.getFeedbackToList(submissionUUID);
}
const { assessments } = data;
const formatData = assessmentTableFormat(assessments);
setFeedbackList(formatData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import { v4 as uuidv4 } from 'uuid';
* @returns {Array} - Returns an array of formatted assessment data.
*/
export const assessmentTableFormat = (arr) => arr.map(({
idAssessment, assesmentDate, scorerEmail, scorerName, scorerUsername, feedback, problemStep, assesmentScores,
idAssessment, assessmentDate, scorerEmail, scorerName, scorerUsername, feedback, problemStep, assessmentScores,
}) => {
const newAssesmentScores = assesmentScores.map(({ criterionName, scoreEarned, scoreType }) => ({
const newAssessmentScores = assessmentScores.map(({ criterionName, scoreEarned, scoreType }) => ({
id: uuidv4(), type: criterionName, quality: scoreType, rate: scoreEarned,
}));
return {
idAssessment,
reviewerName: scorerName,
userName: scorerUsername,
email: scorerEmail,
assessmentDate: assesmentDate,
assessmentScores: newAssesmentScores,
assessmentDate,
assessmentScores: newAssessmentScores,
feedback,
problemStep,
};
Expand Down
23 changes: 17 additions & 6 deletions src/data/services/lms/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,24 @@ const updateGrade = (submissionUUID, gradeData) => post(
).then(response => response.data);

/*
* get('api/assessments/feedback', { submissionUUID, assessmentType })
* @param {object} feedbackData - full grading feedback of submission data
* get('api/assessments/feedback/from', { submissionUUID })
* @param {object} feedbackData - full grading feedback received of submission data
*/
const getFeedbackList = (submissionUUID, assessmentType) => get(
stringifyUrl(urls.getFeedbackSubmissionsUrl(), {
const getFeedbackFromList = (submissionUUID) => get(
stringifyUrl(urls.assessmentsFeedbackFromUrl(), {
[paramKeys.oraLocation]: locationId(),
[paramKeys.submissionUUID]: submissionUUID,
}),
).then(response => camelizeKeys(response.data));

/*
* get('api/assessments/feedback/to', { submissionUUID })
* @param {object} feedbackData - full grading feedback given of submission data
*/
const getFeedbackToList = (submissionUUID) => get(
stringifyUrl(urls.assessmentFeedbackToUrl(), {
[paramKeys.oraLocation]: locationId(),
[paramKeys.submissionUUID]: submissionUUID,
[paramKeys.assessmentType]: assessmentType,
}),
).then(response => camelizeKeys(response.data));

Expand All @@ -150,7 +160,8 @@ export default StrictDict({
fetchSubmissionStatus,
lockSubmission,
updateGrade,
getFeedbackList,
getFeedbackFromList,
getFeedbackToList,
unlockSubmission,
batchUnlockSubmissions,
});
1 change: 0 additions & 1 deletion src/data/services/lms/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const fileUploadResponseOptions = StrictDict({
export const paramKeys = StrictDict({
oraLocation: 'oraLocation',
submissionUUID: 'submissionUUID',
assessmentType: 'assessmentType',
});

export const oraTypes = StrictDict({
Expand Down
6 changes: 4 additions & 2 deletions src/data/services/lms/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const fetchSubmissionStatusUrl = () => `${baseEsgUrl()}submission/status`;
const fetchSubmissionLockUrl = () => `${baseEsgUrl()}submission/lock`;
const batchUnlockSubmissionsUrl = () => `${baseEsgUrl()}submission/batch/unlock`;
const updateSubmissionGradeUrl = () => `${baseEsgUrl()}submission/grade`;
const getFeedbackSubmissionsUrl = () => `${baseEsgUrl()}assessments/feedback`;
const assessmentsFeedbackFromUrl = () => `${baseEsgUrl()}assessments/feedback/from/`;
const assessmentFeedbackToUrl = () => `${baseEsgUrl()}assessments/feedback/to/`;

const course = (courseId) => `${baseUrl()}/courses/${courseId}`;

Expand All @@ -35,5 +36,6 @@ export default StrictDict({
course,
openResponse,
ora,
getFeedbackSubmissionsUrl,
assessmentsFeedbackFromUrl,
assessmentFeedbackToUrl,
});

0 comments on commit 0080e16

Please sign in to comment.