Skip to content

Commit

Permalink
Merge pull request #323 from France-ioi/task-grader-new-format
Browse files Browse the repository at this point in the history
Task grader new format
  • Loading branch information
SebastienTainon authored Jul 26, 2023
2 parents b4dea48 + a50f49c commit 1245756
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions frontend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ declare global {
task: any, // task object defined to receive data from platform
platform: any, // platform object defined to send data to platform
json: any, // object that contains the data of a task, defined in the index.html of such task
PEMTaskMetaData: any, // same usage, bue for task grader tasks
task_token: any, // instance that can generate a task token
options: any, // this is used to store default data about task
Blockly: any,
Expand Down Expand Up @@ -156,6 +157,7 @@ declare global {
quickAlgoLanguageStrings: any,
taskStrings?: any,
SmartContractConfig?: SmartContractConfigType,
taskData?: any,
}
}

Expand Down
16 changes: 16 additions & 0 deletions frontend/submission/task_platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,22 @@ export function* getTaskFromId(taskId: string): Generator<any, TaskServer|null>
}

export function convertServerTaskToCodecastFormat(task: TaskServer): Task {
// task.scriptAnimation = "\n window.taskData = subTask = {};\n subTask.gridInfos = {\n context: 'smart_contract',\n importModules: ['smart_contract_config'],\n showLabels: true,\n conceptViewer: true,\n includeBlocks: {\n groupByCategory: true,\n standardBlocks: {\n wholeCategories: ['smart_contract_main_blocks', 'smart_contract_types'],\n },\n },\n expectedStorage: \"(string %names)\",\n taskStrings: {\n \"storageDescription\": {\n \"names\": \"it should contain its initial value then the list of names of the callers, all separated with commas\",\n },\n },\n // expectedStorage: \"(Pair (string %names) (nat %nb_calls))\",\n };\n ";
if (task.scriptAnimation) {
try {
eval(task.scriptAnimation);
} catch (ex) {
console.error("Couldn't execute script animation", ex);
}

if (window.taskData?.gridInfos) {
return {
...task,
gridInfos: window.taskData.gridInfos,
};
}
}

// Use this for now to check if it's a Smart Contract task. Change this in the future
if (smartContractPlatforms.find(platform => -1 !== task.supportedLanguages.indexOf(platform))) {
return {
Expand Down
2 changes: 1 addition & 1 deletion frontend/task/libs/smart_contract/SmartContractStorage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function SmartContractStorage() {
</p>
<ul>
{storageVariables.map(({name, type}) =>
<li key={name}><code>{name}</code> should be a {type}{window?.taskStrings?.storageDescription[name] ? ': ' + window?.taskStrings?.storageDescription[name] : ''}</li>
<li key={name}><code>{name}</code> should be a {type}{task.gridInfos.taskStrings?.storageDescription[name] ? ': ' + task.gridInfos.taskStrings?.storageDescription[name] : ''}</li>
)}
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/task/platform/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function* getTaskAnswerAggregated () {
}

export function getTaskMetadata() {
const metadata = window.json ? window.json : {
const metadata = window.json ?? window.PEMTaskMetaData ?? {
fullFeedback: true,
minWidth: "auto",
};
Expand Down
1 change: 1 addition & 0 deletions frontend/task/task_slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export interface QuickalgoTaskGridInfosNotLevelDependent {
expectedStorage?: string,
initActionDelay?: number,
hints?: TaskHint[],
taskStrings?: any,
}

export interface QuickalgoTaskGridInfos extends QuickalgoTaskGridInfosNotLevelDependent {
Expand Down

0 comments on commit 1245756

Please sign in to comment.