Skip to content

Commit

Permalink
Merge branch 'master' into payload_size_limit
Browse files Browse the repository at this point in the history
  • Loading branch information
yiwen101 authored Jan 23, 2025
2 parents 275264b + d84e9ca commit 34c849a
Show file tree
Hide file tree
Showing 38 changed files with 835 additions and 558 deletions.
27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,49 +33,49 @@
"@mantine/hooks": "^7.11.2",
"@octokit/rest": "^20.0.0",
"@reduxjs/toolkit": "^1.9.7",
"@sentry/browser": "^7.57.0",
"@sourceacademy/c-slang": "^1.0.20",
"@sentry/browser": "^8.33.0",
"@sourceacademy/c-slang": "^1.0.21",
"@sourceacademy/sharedb-ace": "^2.0.3",
"@sourceacademy/sling-client": "^0.1.0",
"@szhsin/react-menu": "^4.0.0",
"@tanstack/react-table": "^8.9.3",
"@tremor/react": "^1.8.2",
"ace-builds": "^1.4.14",
"ace-builds": "^1.36.3",
"acorn": "^8.9.0",
"ag-grid-community": "^32.0.2",
"ag-grid-react": "^32.0.2",
"ag-grid-community": "^32.3.1",
"ag-grid-react": "^32.3.1",
"array-move": "^4.0.0",
"browserfs": "^1.4.3",
"classnames": "^2.3.2",
"dayjs": "^1.11.13",
"dompurify": "^3.1.6",
"flexboxgrid": "^6.3.1",
"flexboxgrid-helpers": "^1.1.3",
"hastscript": "^9.0.0",
"i18next": "^23.11.2",
"i18next-browser-languagedetector": "^7.2.1",
"i18next-browser-languagedetector": "^8.0.0",
"java-slang": "^1.0.13",
"js-cookie": "^3.0.5",
"js-slang": "^1.0.76",
"js-slang": "^1.0.79",
"js-yaml": "^4.1.0",
"konva": "^9.2.0",
"lodash": "^4.17.21",
"lz-string": "^1.4.4",
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-to-hast": "^13.0.0",
"moment": "^2.29.4",
"normalize.css": "^8.0.1",
"phaser": "^3.55.2",
"query-string": "^9.0.0",
"re-resizable": "^6.9.9",
"react": "^18.3.1",
"react-ace": "^10.1.0",
"react-ace": "^12.0.0",
"react-copy-to-clipboard": "^5.1.0",
"react-debounce-render": "^8.0.2",
"react-dom": "^18.3.1",
"react-drag-drop-files": "^2.3.10",
"react-draggable": "^4.4.5",
"react-dropzone": "^14.2.3",
"react-i18next": "^14.1.0",
"react-i18next": "^15.0.0",
"react-konva": "^18.2.10",
"react-latex-next": "^3.0.0",
"react-mde": "^11.5.0",
Expand All @@ -94,7 +94,7 @@
"showdown": "^2.1.0",
"sourceror": "^0.8.5",
"unified": "^11.0.0",
"uuid": "^9.0.0",
"uuid": "^11.0.2",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz",
"xml2js": "^0.6.0",
"yareco": "^0.1.5"
Expand All @@ -108,7 +108,7 @@
"@craco/craco": "^7.1.0",
"@svgr/webpack": "^8.0.0",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/react": "^15.0.6",
"@testing-library/user-event": "^14.4.3",
"@types/dompurify": "^3.0.5",
"@types/estree": "^1.0.5",
Expand All @@ -129,7 +129,6 @@
"@types/react-test-renderer": "^18.0.0",
"@types/redux-mock-store": "^1.0.3",
"@types/showdown": "^2.0.1",
"@types/uuid": "^9.0.0",
"@types/xml2js": "^0.4.11",
"babel-jest": "^29.7.0",
"buffer": "^6.0.3",
Expand All @@ -145,7 +144,7 @@
"eslint-plugin-simple-import-sort": "^12.1.1",
"https-browserify": "^1.0.0",
"husky": "^9.0.0",
"npm-run-all2": "^6.0.0",
"npm-run-all2": "^7.0.0",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"prettier": "^3.3.3",
Expand Down
11 changes: 8 additions & 3 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base", ":dependencyDashboard", "group:allNonMajor", ":label(dependencies)"],
"extends": [
"config:recommended",
":dependencyDashboard",
"group:allNonMajor",
":label(dependencies)"
],
"major": {
"dependencyDashboardApproval": true
},
"packageRules": [
{
"matchPackagePatterns": ["*"],
"rangeStrategy": "update-lockfile"
"rangeStrategy": "update-lockfile",
"matchPackageNames": ["*"]
}
],
"enabledManagers": ["npm"]
Expand Down
14 changes: 7 additions & 7 deletions src/commons/achievement/utils/DateHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import moment from 'moment';
import dayjs from 'dayjs';

const now = new Date();

Expand Down Expand Up @@ -38,12 +38,12 @@ export const timeFromExpired = (deadline?: Date) =>
export const prettifyDate = (deadline?: Date) => {
if (deadline === undefined) return '';

return moment(deadline).format('D MMMM YYYY HH:mm');
return dayjs(deadline).format('D MMMM YYYY HH:mm');
};

export const prettifyTime = (time?: Date) => {
if (time === undefined) return '';
return moment(time).format('HH:mm');
return dayjs(time).format('HH:mm');
};

// Converts Date to deadline countdown
Expand All @@ -54,11 +54,11 @@ export const prettifyDeadline = (deadline?: Date) => {
return 'Expired';
}

const now = moment();
const now = dayjs();

const weeksAway = Math.ceil(moment(deadline).diff(now, 'weeks', true));
const daysAway = Math.ceil(moment(deadline).diff(now, 'days', true));
const hoursAway = Math.ceil(moment(deadline).diff(now, 'hours', true));
const weeksAway = Math.ceil(dayjs(deadline).diff(now, 'weeks', true));
const daysAway = Math.ceil(dayjs(deadline).diff(now, 'days', true));
const hoursAway = Math.ceil(dayjs(deadline).diff(now, 'hours', true));

let prettifiedDeadline = '';
if (weeksAway > 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/commons/achievement/utils/InsertFakeAchievements.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import moment from 'moment';
import dayjs from 'dayjs';

import {
cardBackgroundUrl,
Expand All @@ -23,7 +23,7 @@ function insertFakeAchievements(
inferencer: AchievementInferencer
) {
const sortedOverviews = [...assessmentOverviews].sort((overview1, overview2) =>
moment(overview1.closeAt).diff(moment(overview2.closeAt))
dayjs(overview1.closeAt).diff(dayjs(overview2.closeAt))
);
const length = assessmentOverviews.length;

Expand Down
4 changes: 4 additions & 0 deletions src/commons/application/ApplicationTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ export function isSchemeLanguage(chapter: Chapter): boolean {
].includes(chapter);
}

export function isCseVariant(variant: Variant): boolean {
return variant == Variant.EXPLICIT_CONTROL;
}

const pySubLanguages: Array<Pick<SALanguage, 'chapter' | 'variant' | 'displayName'>> = [
{ chapter: Chapter.PYTHON_1, variant: Variant.DEFAULT, displayName: 'Python \xa71' }
//{ chapter: Chapter.PYTHON_2, variant: Variant.DEFAULT, displayName: 'Python \xa72' },
Expand Down
7 changes: 4 additions & 3 deletions src/commons/assessmentWorkspace/AssessmentWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
}, []);

useEffect(() => {
handleTeamOverviewFetch(props.assessmentId);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
if (assessmentOverview && assessmentOverview.maxTeamSize > 1) {
handleTeamOverviewFetch(props.assessmentId);
}
}, [assessmentOverview, handleTeamOverviewFetch, props.assessmentId]);

/**
* After mounting (either an older copy of the assessment
Expand Down
101 changes: 60 additions & 41 deletions src/commons/sagas/RequestsSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,47 +640,22 @@ export const getGradingOverviews = async (
}
const gradingOverviews = await resp.json();

return {
count: gradingOverviews.count,
data: gradingOverviews.data.map((overview: any) => {
const gradingOverview: GradingOverview = {
assessmentId: overview.assessment.id,
assessmentNumber: overview.assessment.assessmentNumber,
assessmentName: overview.assessment.title,
assessmentType: overview.assessment.type,
studentId: overview.student ? overview.student.id : -1,
studentName: overview.student ? overview.student.name : undefined,
studentNames: overview.team
? overview.team.team_members.map((member: { name: any }) => member.name)
: undefined,
studentUsername: overview.student ? overview.student.username : undefined,
studentUsernames: overview.team
? overview.team.team_members.map((member: { username: any }) => member.username)
: undefined,
submissionId: overview.id,
submissionStatus: overview.status,
groupName: overview.student ? overview.student.groupName : '-',
groupLeaderId: overview.student ? overview.student.groupLeaderId : undefined,
isGradingPublished: overview.isGradingPublished,
progress: backendParamsToProgressStatus(
overview.assessment.isManuallyGraded,
overview.isGradingPublished,
overview.status,
overview.gradedCount,
overview.assessment.questionCount
),
questionCount: overview.assessment.questionCount,
gradedCount: overview.gradedCount,
// XP
initialXp: overview.xp,
xpAdjustment: overview.xpAdjustment,
currentXp: overview.xp + overview.xpAdjustment,
maxXp: overview.assessment.maxXp,
xpBonus: overview.xpBonus
};
return gradingOverview;
})
};
return respToGradingOverviews(gradingOverviews);
};

/*
* GET /courses/{courseId}/admin/grading/all_submissions
*/
export const getAllGradingOverviews = async (tokens: Tokens): Promise<GradingOverviews | null> => {
const resp = await request(`${courseId()}/admin/grading/all_submissions`, 'GET', {
...tokens
});
if (!resp) {
return null; // invalid accessToken _and_ refreshToken
}
const gradingOverviews = await resp.json();

return respToGradingOverviews(gradingOverviews);
};

/*
Expand Down Expand Up @@ -1556,6 +1531,50 @@ export function* handleResponseError(resp: Response | null): any {
yield call(showWarningMessage, respText);
}

const respToGradingOverviews = (gradingOverviews: any): GradingOverviews => {
return {
count: gradingOverviews.count,
data: gradingOverviews.data.map((overview: any) => {
const gradingOverview: GradingOverview = {
assessmentId: overview.assessment.id,
assessmentNumber: overview.assessment.assessmentNumber,
assessmentName: overview.assessment.title,
assessmentType: overview.assessment.type,
studentId: overview.student ? overview.student.id : -1,
studentName: overview.student ? overview.student.name : undefined,
studentNames: overview.team
? overview.team.team_members.map((member: { name: any }) => member.name)
: undefined,
studentUsername: overview.student ? overview.student.username : undefined,
studentUsernames: overview.team
? overview.team.team_members.map((member: { username: any }) => member.username)
: undefined,
submissionId: overview.id,
submissionStatus: overview.status,
groupName: overview.student ? overview.student.groupName : '-',
groupLeaderId: overview.student ? overview.student.groupLeaderId : undefined,
isGradingPublished: overview.isGradingPublished,
progress: backendParamsToProgressStatus(
overview.assessment.isManuallyGraded,
overview.isGradingPublished,
overview.status,
overview.gradedCount,
overview.assessment.questionCount
),
questionCount: overview.assessment.questionCount,
gradedCount: overview.gradedCount,
// XP
initialXp: overview.xp,
xpAdjustment: overview.xpAdjustment,
currentXp: overview.xp + overview.xpAdjustment,
maxXp: overview.assessment.maxXp,
xpBonus: overview.xpBonus
};
return gradingOverview;
})
};
};

const courseId: () => string = () => {
const id = store.getState().session.courseId;
if (id) {
Expand Down
9 changes: 9 additions & 0 deletions src/commons/utils/AceHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ export const selectMode = (chapter: Chapter, variant: Variant, library: string)
ModeSelector(chapter, variant, library);
};

import 'ace-builds/src-noconflict/mode-c_cpp';
import 'ace-builds/src-noconflict/mode-html';
import 'ace-builds/src-noconflict/mode-java';
import 'ace-builds/src-noconflict/mode-javascript';
import 'ace-builds/src-noconflict/mode-python';
import 'ace-builds/src-noconflict/mode-scheme';
import 'ace-builds/src-noconflict/mode-typescript';
import 'js-slang/dist/editors/ace/theme/source';

export const getModeString = (chapter: Chapter, variant: Variant, library: string) => {
// TODO: Create our own highlighting rules for the different sublanguages
switch (chapter) {
Expand Down
19 changes: 12 additions & 7 deletions src/commons/utils/DateHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import moment from 'moment';
import dayjs from 'dayjs';
import advancedFormat from 'dayjs/plugin/advancedFormat';
import relativeTime from 'dayjs/plugin/relativeTime';

dayjs.extend(advancedFormat);
dayjs.extend(relativeTime);

/**
* Checks if a date is before or at the current time.
Expand All @@ -9,8 +14,8 @@ import moment from 'moment';
* is before the time of execution of this function.
*/
export const beforeNow = (dateString: string): boolean => {
const date = moment(dateString);
const now = moment();
const date = dayjs(dateString);
const now = dayjs();
return date.isBefore(now);
};

Expand All @@ -25,25 +30,25 @@ export const beforeNow = (dateString: string): boolean => {
* e.g 7th June, 20:09
*/
export const getPrettyDate = (dateString: string): string => {
const date = moment(dateString);
const date = dayjs(dateString);
const prettyDate = date.format('Do MMMM, HH:mm');
return prettyDate;
};

export const getStandardDateTime = (dateString: string): string => {
const date = moment(dateString);
const date = dayjs(dateString);
const prettyDate = date.format('MMMM Do YYYY, HH:mm');
return prettyDate;
};

export const getStandardDate = (dateString: string): string => {
const date = moment(dateString);
const date = dayjs(dateString);
const prettyDate = date.format('MMMM Do YYYY');
return prettyDate;
};

export const getPrettyDateAfterHours = (dateString: string, hours: number): string => {
const date = moment(dateString).add(hours, 'hours');
const date = dayjs(dateString).add(hours, 'hours');
const absolutePrettyDate = date.format('Do MMMM, HH:mm');
const relativePrettyDate = date.fromNow();
return `${absolutePrettyDate} (${relativePrettyDate})`;
Expand Down
Loading

0 comments on commit 34c849a

Please sign in to comment.