update api and docs

This commit is contained in:
Ben Warzeski
2021-09-13 12:09:39 -04:00
parent 071bbf6875
commit 1367e7b7c9

View File

@@ -11,26 +11,103 @@ import fakeData from './fakeData';
* GET Actions
*********************************************************************************/
const mockGet = (returnValFn) => (...args) => (
const mockSuccess = (returnValFn) => (...args) => (
new Promise((resolve) => resolve(returnValFn(...args)))
);
// eslint-disable-next-line no-unused-vars
const initializeApp = mockGet(() => ({
const mockFailure = (returnValFn) => (...args) => (
new Promise((resolve, reject) => reject(returnValFn(...args)))
);
/**
* get('/api/initialize')
* @return {
* oraMetadata: { name, prompt },
* submissions: {
* [learnerId]: {
* id: <submissionId>, (not currently used)
* username,
* learnerId,
* dateSubmitted, (timestamp)
* status, ['ungraded', 'graded', 'locked', 'locked_by_you'?]
* grade, (number)
* },
* ...
* },
* }
*/
const initializeApp = mockSuccess(() => ({
oraMetadata: fakeData.oraMetadata,
submissions: fakeData.submissions,
}));
const fetchSubmission = mockGet((learnerId) => ({
/**
* get('/api/submission', { learnerId })
* @return {
* submision: {
* grade,
* learnerId,
* response: { files: [], text: <html> },
* rubric: {
* name,
* comments (optional),
* criteria: [
* {
* name,
* description,
* points,
* grade,
* comments,
* }
* ],
* },
* },
* }
*/
const fetchSubmission = mockSuccess((learnerId) => ({
submission: fakeData.mockSubmission(learnerId),
}));
const fetchSubmissionStatus = mockGet((learnerId) => ({
status: fakeData.mockSubmission(learnerId).status,
}));
/* I assume this is the "Start Grading" call, even for if a
* submission is already graded and we are attempting re-lock.
* Assuming the check for if allowed would happen locally first.
* post('api/lockSubmission', { learnerId });
*/
const lockSubmission = mockSuccess((learnerId) => {
console.log({ lockSubmission: { learnerId } });
});
/*
* Assuming we do not care who has locked it or why, as there
* is no design around communicating that info
* post('api/lockSubmission', { learnerId });
*/
const lockSubmissionFail = mockFailure((learnerId) => {
console.log({ lockSubmissionFail: learnerId });
});
/*
* post('api/updateGrade', { learnerId, gradeData })
* @param {object} gradeData - full grading submission data
* {
* rubricComments: '', (optional)
* criteria: [
* {
* comments: '', (optional)
* grade: '',
* },
* ...
* ],
* }
*/
const updateGrade = mockSuccess((learnerId, gradeData) => {
console.log({ updateGrade: { learnerId, gradeData } });
});
export default StrictDict({
initializeApp,
fetchSubmission,
fetchSubmissionStatus,
lockSubmission,
lockSubmissionFail,
updateGrade,
});