Skip to content

Commit d52a402

Browse files
committed
Merge branch 'sourceMaster'
2 parents c37f834 + 761deb3 commit d52a402

25 files changed

+571
-65
lines changed

craco.config.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// eslint-disable-next-line @typescript-eslint/no-var-requires
1+
/* eslint-disable @typescript-eslint/no-var-requires */
22
const webpack = require('webpack');
33

4-
const cracoConfig = (module.exports = {
4+
const cracoConfig = {
55
webpack: {
66
configure: webpackConfig => {
77
// avoid the entire process.env being inserted into the service worker
@@ -62,11 +62,16 @@ const cracoConfig = (module.exports = {
6262
},
6363
});
6464

65-
// Ignore warnings for dependencies that do not ship with a source map.
66-
// This is because we cannot do anything about our dependencies.
67-
webpackConfig.ignoreWarnings = [{
65+
webpackConfig.ignoreWarnings = [{
66+
// Ignore warnings for dependencies that do not ship with a source map.
67+
// This is because we cannot do anything about our dependencies.
6868
module: /node_modules/,
6969
message: /Failed to parse source map/
70+
}, {
71+
// Ignore the warnings that occur because js-slang uses dynamic imports
72+
// to load Source modules
73+
module: /js-slang\/dist\/modules\/loader\/loaders.js/,
74+
message: /Critical dependency: the request of a dependency is an expression/
7075
}];
7176

7277
webpackConfig.plugins = [
@@ -78,7 +83,7 @@ const cracoConfig = (module.exports = {
7883
// Make the 'buffer' Node.js module available in the browser.
7984
new webpack.ProvidePlugin({
8085
Buffer: ['buffer', 'Buffer'],
81-
})
86+
}),
8287
];
8388

8489
// Workaround to suppress warnings caused by ts-morph in js-slang
@@ -153,7 +158,7 @@ const cracoConfig = (module.exports = {
153158
['@babel/preset-typescript']
154159
]
155160
}
156-
});
161+
}
157162

158163
const ignoreModulePaths = (...paths) => {
159164
const moduleRoot = replaceSlashes('/node_modules/');
@@ -166,3 +171,5 @@ const ignoreModulePaths = (...paths) => {
166171
const replaceSlashes = target => {
167172
return target.replaceAll('/', '[/\\\\]');
168173
};
174+
175+
module.exports = cracoConfig

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"flexboxgrid": "^6.3.1",
5151
"flexboxgrid-helpers": "^1.1.3",
5252
"hastscript": "^9.0.0",
53-
"js-slang": "^1.0.60",
53+
"java-slang": "^1.0.3",
54+
"js-slang": "^1.0.62",
5455
"js-yaml": "^4.1.0",
5556
"konva": "^9.2.0",
5657
"lodash": "^4.17.21",

src/commons/application/ApplicationTypes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,15 @@ export enum SupportedLanguage {
122122
JAVASCRIPT = 'JavaScript',
123123
SCHEME = 'Scheme',
124124
PYTHON = 'Python',
125+
JAVA = 'Java',
125126
C = 'C'
126127
}
127128

128129
export const SUPPORTED_LANGUAGES = [
129130
SupportedLanguage.JAVASCRIPT,
130131
SupportedLanguage.SCHEME,
131132
SupportedLanguage.PYTHON,
133+
SupportedLanguage.JAVA,
132134
SupportedLanguage.C
133135
];
134136

@@ -225,6 +227,15 @@ export const pyLanguages: SALanguage[] = pySubLanguages.map(sublang => {
225227
return { ...sublang, mainLanguage: SupportedLanguage.PYTHON, supports: { repl: true } };
226228
});
227229

230+
export const javaLanguages: SALanguage[] = [
231+
{
232+
chapter: Chapter.FULL_JAVA,
233+
variant: Variant.DEFAULT,
234+
displayName: 'Java',
235+
mainLanguage: SupportedLanguage.JAVA,
236+
supports: {}
237+
}
238+
];
228239
export const cLanguages: SALanguage[] = [
229240
{
230241
chapter: Chapter.FULL_C,
@@ -304,6 +315,7 @@ export const ALL_LANGUAGES: readonly SALanguage[] = [
304315
htmlLanguage,
305316
...schemeLanguages,
306317
...pyLanguages,
318+
...javaLanguages,
307319
...cLanguages
308320
];
309321
// TODO: Remove this function once logic has been fully migrated

src/commons/assessment/AssessmentTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export type AssessmentOverview = {
6464
isPublished?: boolean;
6565
hasVotingFeatures: boolean;
6666
hasTokenCounter?: boolean;
67+
isVotingPublished?: boolean;
6768
maxXp: number;
6869
earlySubmissionXp: number;
6970
number?: string; // For mission control

src/commons/editor/Editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,8 @@ const EditorBase = React.memo((props: EditorProps & LocalStateProps) => {
435435
session.on('changeAnnotation' as any, makeHandleAnnotationChange(session));
436436

437437
// Start autocompletion
438-
if (props.sourceChapter === Chapter.FULL_C) {
439-
// for C language, use the default autocomplete provided by ace editor
438+
if (props.sourceChapter === Chapter.FULL_C || props.sourceChapter === Chapter.FULL_JAVA) {
439+
// for C, Java language, use the default autocomplete provided by ace editor
440440
const { textCompleter, keyWordCompleter, setCompleters } = acequire('ace/ext/language_tools');
441441
setCompleters([textCompleter, keyWordCompleter]);
442442
} else {

src/commons/navigationBar/subcomponents/NavigationBarLangSelectButton.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useDispatch } from 'react-redux';
44
import {
55
cLanguages,
66
getLanguageConfig,
7+
javaLanguages,
78
pyLanguages,
89
SALanguage,
910
schemeLanguages,
@@ -23,6 +24,7 @@ const defaultSublanguages: {
2324
[SupportedLanguage.JAVASCRIPT]: sourceLanguages[0],
2425
[SupportedLanguage.PYTHON]: pyLanguages[0],
2526
[SupportedLanguage.SCHEME]: schemeLanguages[0],
27+
[SupportedLanguage.JAVA]: javaLanguages[0],
2628
[SupportedLanguage.C]: cLanguages[0]
2729
};
2830

src/commons/sagas/BackendSaga.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
GradingQuestion
1717
} from '../../features/grading/GradingTypes';
1818
import {
19+
ASSIGN_ENTRIES_FOR_VOTING,
1920
CHANGE_DATE_ASSESSMENT,
2021
CHANGE_TEAM_SIZE_ASSESSMENT,
2122
CONFIGURE_ASSESSMENT,
@@ -1386,6 +1387,28 @@ function* BackendSaga(): SagaIterator {
13861387
yield call(showSuccessMessage, 'Updated successfully!', 1000);
13871388
}
13881389
);
1390+
1391+
yield takeEvery(
1392+
ASSIGN_ENTRIES_FOR_VOTING,
1393+
function* (action: ReturnType<typeof actions.assignEntriesForVoting>): any {
1394+
const tokens: Tokens = yield selectTokens();
1395+
const id = action.payload.id;
1396+
1397+
const resp: Response | null = yield updateAssessment(
1398+
id,
1399+
{
1400+
assignEntriesForVoting: true
1401+
},
1402+
tokens
1403+
);
1404+
if (!resp || !resp.ok) {
1405+
return yield handleResponseError(resp);
1406+
}
1407+
1408+
yield put(actions.fetchAssessmentOverviews());
1409+
yield call(showSuccessMessage, 'Updated successfully!', 1000);
1410+
}
1411+
);
13891412
}
13901413

13911414
function* handleReautogradeResponse(resp: Response | null): any {

src/commons/sagas/RequestsSaga.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,48 @@ export const deleteSourcecastEntry = async (
11281128
return resp;
11291129
};
11301130

1131+
/**
1132+
* GET /courses/{courseId}/admin/assessments/{assessmentId}/scoreLeaderboard
1133+
*/
1134+
export const getScoreLeaderboard = async (
1135+
assessmentId: number,
1136+
tokens: Tokens
1137+
): Promise<ContestEntry[] | null> => {
1138+
const resp = await request(
1139+
`${courseId()}/admin/assessments/${assessmentId}/scoreLeaderboard`,
1140+
'GET',
1141+
{
1142+
...tokens
1143+
}
1144+
);
1145+
if (!resp || !resp.ok) {
1146+
return null; // invalid accessToken _and_ refreshToken
1147+
}
1148+
const scoreLeaderboard = await resp.json();
1149+
return scoreLeaderboard as ContestEntry[];
1150+
};
1151+
1152+
/**
1153+
* GET /courses/{courseId}/admin/assessments/{assessmentId}/popularVoteLeaderboard
1154+
*/
1155+
export const getPopularVoteLeaderboard = async (
1156+
assessmentId: number,
1157+
tokens: Tokens
1158+
): Promise<ContestEntry[] | null> => {
1159+
const resp = await request(
1160+
`${courseId()}/admin/assessments/${assessmentId}/popularVoteLeaderboard`,
1161+
'GET',
1162+
{
1163+
...tokens
1164+
}
1165+
);
1166+
if (!resp || !resp.ok) {
1167+
return null; // invalid accessToken _and_ refreshToken
1168+
}
1169+
const popularVoteLeaderboard = await resp.json();
1170+
return popularVoteLeaderboard as ContestEntry[];
1171+
};
1172+
11311173
/**
11321174
* POST /courses/{courseId}/admin/assessments/{assessmentId}
11331175
*/
@@ -1140,6 +1182,7 @@ export const updateAssessment = async (
11401182
maxTeamSize?: number;
11411183
hasTokenCounter?: boolean;
11421184
hasVotingFeatures?: boolean;
1185+
assignEntriesForVoting?: boolean;
11431186
},
11441187
tokens: Tokens
11451188
): Promise<Response | null> => {

src/commons/sagas/WorkspaceSaga/helpers/evalCode.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { SagaIterator } from 'redux-saga';
99
import { call, put, race, select, take } from 'redux-saga/effects';
1010
import * as Sourceror from 'sourceror';
1111
import { makeCCompilerConfig, specialCReturnObject } from 'src/commons/utils/CToWasmHelper';
12+
import { javaRun } from 'src/commons/utils/JavaHelper';
1213
import { notifyStoriesEvaluated } from 'src/features/stories/StoriesActions';
1314
import { EVAL_STORY } from 'src/features/stories/StoriesTypes';
1415

@@ -245,6 +246,7 @@ export function* evalCode(
245246
const isLazy: boolean = context.variant === Variant.LAZY;
246247
const isWasm: boolean = context.variant === Variant.WASM;
247248
const isC: boolean = context.chapter === Chapter.FULL_C;
249+
const isJava: boolean = context.chapter === Chapter.FULL_JAVA;
248250

249251
let lastDebuggerResult = yield select(
250252
(state: OverallState) => state.workspaces[workspaceLocation].lastDebuggerResult
@@ -264,6 +266,8 @@ export function* evalCode(
264266
? call_variant(context.variant)
265267
: isC
266268
? call(cCompileAndRun, entrypointCode, context)
269+
: isJava
270+
? call(javaRun, entrypointCode, context)
267271
: call(
268272
runFilesInContext,
269273
isFolderModeEnabled

src/commons/utils/AceHelper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export const getModeString = (chapter: Chapter, variant: Variant, library: strin
5050
case Chapter.SCHEME_4:
5151
case Chapter.FULL_SCHEME:
5252
return 'scheme';
53+
case Chapter.FULL_JAVA:
54+
return 'java';
5355
case Chapter.FULL_C:
5456
return 'c_cpp';
5557
default:

0 commit comments

Comments
 (0)