Skip to content

Commit

Permalink
Merge pull request #26 from polyglot-edu/19-openquestionnodetype-impl…
Browse files Browse the repository at this point in the history
…ementation

codingQuestion fix
  • Loading branch information
tmaog authored Feb 22, 2024
2 parents 70add8c + 24ffa5a commit 5c9e147
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/execution/plugins/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export type MultipleChoiceQuestionNodeData = {
isChoiceCorrect: boolean[];
};

export type CodingQuestionNodeData = {
question: string;
codeTemplate: string;
language: string;
};

export type TrueFalseNodeData = {
instructions: string;
questions: string[];
Expand Down
30 changes: 26 additions & 4 deletions src/execution/plugins/vsCodeExecution.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PolyglotNode } from "../../types";
import { ChallengeContent, ChallengeSetup, LessonTextNodeData, MultipleChoiceQuestionNodeData, CloseEndedQuestionNodeData, textLinkNodeData, zip } from "./Node";
import { ChallengeContent, ChallengeSetup, LessonTextNodeData, MultipleChoiceQuestionNodeData, CloseEndedQuestionNodeData, textLinkNodeData, zip, CodingQuestionNodeData } from "./Node";

type vsCodeSpecifics={challengeSetup: ChallengeSetup[], challengeContent:ChallengeContent[]};

Expand Down Expand Up @@ -80,8 +80,6 @@ function multipleChoiceQuestionNodeExecution(node:PolyglotNode){
[] as string[]
),
};
console.log("checkpoint");
console.log(data.correctAnswers);
const challengeSetup: ChallengeSetup[] = [
`
using Polyglot.Interactive;
Expand Down Expand Up @@ -111,6 +109,29 @@ function multipleChoiceQuestionNodeExecution(node:PolyglotNode){
challengeContent,
};
}

function codingQuestionNodeExecution(node:PolyglotNode){
const data = node.data as CodingQuestionNodeData;

const challengeSetup: ChallengeSetup[] = [];
const challengeContent: ChallengeContent[] = [
{
type: 'markdown',
content: data?.question,
priority: 0,
},
{
type: data?.language,
content: data?.codeTemplate,
priority: 1,
},
];

return {
challengeSetup,
challengeContent,
};
}
//notImplementedNode Execution block
function notImplementedNodeExecution(node:PolyglotNode){
const challengeSetup: ChallengeSetup[] = [];
Expand All @@ -134,8 +155,9 @@ export function vsCodeExecution(node:PolyglotNode){
if(node?.type=="lessonTextNode") vsCodeSpecifics=lessonTextNodeExecution(node);
if(node?.type=="closeEndedQuestionNode") vsCodeSpecifics=closeEndedQuestionNodeExecution(node);
if(node?.type=="ReadMaterialNode") vsCodeSpecifics=readMaterialNodeExecution(node);
if(node?.type=="codingQuestionNode") vsCodeSpecifics=codingQuestionNodeExecution(node);
if(node?.type=="TrueFalseNode"||node?.type=="WatchVideoNode"||node?.type=="SummaryNode"||node?.type=="OpenQuestionNode") vsCodeSpecifics = notImplementedNodeExecution(node);

return {...node,
runtimeData: vsCodeSpecifics,
}
Expand Down

0 comments on commit 5c9e147

Please sign in to comment.