Skip to content

Commit

Permalink
feat: add hello world assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
tolstenko committed Dec 22, 2023
1 parent 67dddc7 commit f8c31e7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface AssignmentBasev1_0_0 {
format_ver: "1.0.0",
description: string,
initialCode: string,
inputs: string[],
outputs: string[]
}
15 changes: 15 additions & 0 deletions demo-syntax-training/src/assignments/intro-cpp/hello-world.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {AssignmentBasev1_0_0} from "../assignment.base.v1.0.0";

export const HelloWorldCPP: AssignmentBasev1_0_0 = {
format_ver: "1.0.0",
description: `Write a program that prints "Hello World" to the console.`,
initialCode: `#include <iostream>
using namespace std;
int main() {
// Your code goes here
return 0;
}`,
inputs: [""],
outputs: ["Hello World"]
}
20 changes: 8 additions & 12 deletions demo-syntax-training/src/components/SyntaxTraining.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {AssignmentBasev1_0_0} from "../assignments/assignment.base.v1.0.0";

const path = require('path');
import { CopyOutlined, PlayCircleFilled, UndoOutlined } from "@ant-design/icons";
import { Editor } from "@monaco-editor/react";
Expand All @@ -7,6 +9,7 @@ import * as Comlink from "comlink";
import { editor } from "monaco-editor";
import React, { useEffect, useRef } from "react";
import Emception from "./emception";
import { HelloWorldCPP } from "../assignments/intro-cpp/hello-world"

const { Header, Content, Footer } = Layout;

Expand All @@ -29,16 +32,14 @@ const style: React.CSSProperties = {
};

interface SyntaxTrainingPageProps {
content?: string;
initialValue?: string;
assignment?: AssignmentBasev1_0_0 | any; // add other versions here
theme?: string;
language?: string;
height?: string;
}

const SyntaxTrainingPage: React.FC<SyntaxTrainingPageProps> = ({
content = "Syntax Training Title",
initialValue = "// code goes here",
assignment = HelloWorldCPP,
theme = "vs-dark",
language = "cpp",
height = "20vh"
Expand All @@ -56,8 +57,6 @@ const SyntaxTrainingPage: React.FC<SyntaxTrainingPageProps> = ({

emception = Comlink.wrap(emceptionWorker);
await emception.init();
// emception = new Emception();
// await emception.init();
showNotification("Emception loaded");
}

Expand Down Expand Up @@ -130,7 +129,7 @@ const SyntaxTrainingPage: React.FC<SyntaxTrainingPageProps> = ({
}));

const resetCode = () => {
editorRef.current?.setValue(initialValue);
editorRef.current?.setValue(assignment.initialCode);
showNotification('Code reset');
}

Expand Down Expand Up @@ -165,15 +164,12 @@ const SyntaxTrainingPage: React.FC<SyntaxTrainingPageProps> = ({
} }
>
<Space direction="vertical">
<p>{ content }</p>
<p>ouintdaountaoeuntaoe aonhtd aoeunt adoeunthdao naontd aoncdao clado rclao lao drlcao
crldao lrcado ntaod naotd rcaeo daoecgd aonthd aeonthd cgre gaoedahnotd aoenhtd oaendthd
aonthdao ntado nhtadeocraoe gcraeodraeodreoa aogdd aehnot ao</p>
<p>{ assignment.description }</p>
<Editor
height={ height }
defaultLanguage={ language }
theme={ theme }
defaultValue={ initialValue }
defaultValue={ assignment.initialCode }
onChange={ handleEditorChange }
onMount={ handleEditorDidMount }
beforeMount={ handleEditorWillMount }
Expand Down

0 comments on commit f8c31e7

Please sign in to comment.