Skip to content

Commit

Permalink
Lesson7 of tutorial finished
Browse files Browse the repository at this point in the history
  • Loading branch information
annekekleppe committed Nov 18, 2024
1 parent 71d4402 commit f7d0fad
Show file tree
Hide file tree
Showing 43 changed files with 7,755 additions and 161 deletions.
3 changes: 3 additions & 0 deletions packages/samples/EduTutorialNew/lesson6-defs/edu.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scoper EducationScoper for language Education

isnamespace { Page }
2 changes: 1 addition & 1 deletion packages/samples/EduTutorialNew/lesson7-defs/edu-flow.ast
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language Education

modelunit Flow {
reference main: MainTopic;
reference main: SiteGroup;
rules: FlowRule[];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/samples/EduTutorialNew/lesson7-defs/edu-flow.edit
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
editor default

Flow {[
Flow ${self.name} for MainTopic ${self.main}
Flow ${self.name} for SiteGroup ${self.main}

${self.rules vertical}
]}
Expand Down
4 changes: 2 additions & 2 deletions packages/samples/EduTutorialNew/lesson7-defs/edu-main.ast
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ model Education /* Computer Aided Learning */ {
topic: Topic[];
flow: Flow[];
tests: Test[];
overviews: MainTopic[];
overviews: SiteGroup[];
}

modelunit MainTopic {
modelunit SiteGroup {
name: identifier;
description: string; /* e.g. Mathematics, fractions for students age 10 */
reference topics: Topic[];
Expand Down
4 changes: 2 additions & 2 deletions packages/samples/EduTutorialNew/lesson7-defs/edu-main.edit
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

editor default

MainTopic {[
MainTopic Overview
SiteGroup {[
SiteGroup Overview

Name: ${self.name}

Expand Down
11 changes: 5 additions & 6 deletions packages/samples/EduTutorialNew/lesson7-defs/edu-tests.ast
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language Education
modelunit Test {
name: identifier;
scenarios: Scenario[];
reference main: MainTopic;
reference main: SiteGroup;
reference flow: Flow;
}

Expand All @@ -12,18 +12,17 @@ concept Scenario {
testFlow: TestFlow[];
steps: Step[]; /* Note that the order is of importance */
}

concept TestFlow {
steps: Step[]; /* Note that the order is of importance */
}

concept Step {
reference expectedPage: Page;
reference fromPage: Page;
answerSeries: Answer[];
}

concept StartStep base Step {
reference fromPage: Page;
reference expectedPage: Page;
answerSeries: Answer[];
concept LastStep base Step {
}

concept Answer {
Expand Down
8 changes: 4 additions & 4 deletions packages/samples/EduTutorialNew/lesson7-defs/edu-tests.edit
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ Scenario {[
]}

TestFlow {[
${self.steps horizontal}
${self.steps horizontal separator[===>]}
]}

Step {[
=> ${self.answerSeries table rows} => ${self.expectedPage}
${self.fromPage} => ${self.answerSeries table rows}
]}

StartStep {[
${self.fromPage} => ${self.answerSeries table rows} => ${self.expectedPage}
LastStep {[
${self.fromPage}
]}

Answer { table [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language Education

modelunit Topic {
name: identifier;
reference main: MainTopic;
reference main: SiteGroup;
description: string;
pages: Page[];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
editor default

Topic {[
MainTopic: ${self.main}
SiteGroup: ${self.main}
Topic: ${self.name}
Topic description: ${self.description}

Expand Down
7 changes: 7 additions & 0 deletions packages/samples/EduTutorialNew/lesson7-defs/edu.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
scoper EducationScoper for language Education

isnamespace { Page, Step }

Step {
namespace_addition = self.fromPage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ editor footing

Page {[
Questions:
${self.questions vertical terminator [END]}
${self.questions vertical}

Score
${self.grading vertical}
Expand Down
17 changes: 17 additions & 0 deletions packages/samples/EduTutorialNew/lesson8-defs/edu-flow-table.edit
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* This file contains the rules-as-tables editor definition. */

editor rules_as_table

FlowRule {[
-------------------------------------
Name: ${name}
Description: ${self.description}
For page ${page}

${self.transitions table rows}
]}

PageTransition { table [
Condition | Goto Page
${self.condition} | ${self.toPage}
]}
27 changes: 27 additions & 0 deletions packages/samples/EduTutorialNew/lesson8-defs/edu-flow.ast
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language Education

modelunit Flow {
reference main: SiteGroup;
rules: FlowRule[];
}

concept FlowRule {
name: identifier;
description: string;
reference page: Page;
transitions: PageTransition[];
}

concept PageTransition { /* E.g. Grade A => show pageA, Grade F => show pageC */
condition: Grade; /* Note: will be changed into an expression later in the tutorial. */
reference toPage: Page;
}

limited Grade {
gradeA;
gradeB;
gradeC;
gradeD;
gradeE;
gradeF;
}
22 changes: 22 additions & 0 deletions packages/samples/EduTutorialNew/lesson8-defs/edu-flow.edit
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* This file contains the default editor definition. */

editor default

Flow {[
Flow ${self.name} for SiteGroup ${self.main}

${self.rules vertical}
]}

FlowRule {[
-------------------------------------
Name: ${self.name}
Description: ${self.description}
From page ${self.page}

${self.transitions}
]}

PageTransition {[
when ${self.condition} goto page ${self.toPage}
]}
17 changes: 17 additions & 0 deletions packages/samples/EduTutorialNew/lesson8-defs/edu-main.ast
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language Education

model Education /* Computer Aided Learning */ {
name: identifier;
topic: Topic[];
flow: Flow[];
tests: Test[];
overviews: SiteGroup[];
}

modelunit SiteGroup {
name: identifier;
description: string; /* e.g. Mathematics, fractions for students age 10 */
reference topics: Topic[];
reference flows: Flow[];
reference tests: Test[];
}
15 changes: 15 additions & 0 deletions packages/samples/EduTutorialNew/lesson8-defs/edu-main.edit
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* This file contains the default editor definition. */

editor default

SiteGroup {[
SiteGroup Overview

Name: ${self.name}

Description: ${self.description}

Topics: ${self.topics}

Flows: ${self.flows}
]}
70 changes: 70 additions & 0 deletions packages/samples/EduTutorialNew/lesson8-defs/edu-scoring.ast
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
language Education

concept GradeScore {
grade: Grade;
expr: ScoreExpression;
}

///////////////////////////////////
/// Expressions
//////////////////////////////////
abstract expression ScoreExpression {
}

/* The value of a question reference is the answer given to the
given question */
expression QuestionReference base ScoreExpression {
reference question: Question;
}

/* The value of NrOfCorrectAnswers is the total number of correct
answers on a page. */
expression NrOfCorrectAnswers base ScoreExpression {
}

/* The value of a NumberLiteralExpression is simply a number, like '24' */
expression NumberLiteralExpression base ScoreExpression {
value: number;
}

///////////////////////////////////
/// Boolean AND and OR
//////////////////////////////////
abstract binary expression BinaryExpression base ScoreExpression {
left: ScoreExpression;
right: ScoreExpression;
}

binary expression AndExpression base BinaryExpression {
priority = 1;
}

binary expression OrExpression base BinaryExpression {
priority = 1;
}

///////////////////////////////////
/// Comparisons: <=, >=, >, <, ===
//////////////////////////////////
abstract binary expression ComparisonExpression base BinaryExpression {
}

binary expression LessOrEqualsExpression base ComparisonExpression {
priority = 2;
}

binary expression GreaterOrEqualsExpression base ComparisonExpression {
priority = 2;
}

binary expression LessThenExpression base ComparisonExpression {
priority = 2;
}

binary expression GreaterThenExpression base ComparisonExpression {
priority = 2;
}

binary expression EqualsExpression base ComparisonExpression {
priority = 2;
}
54 changes: 54 additions & 0 deletions packages/samples/EduTutorialNew/lesson8-defs/edu-scoring.edit
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
editor default

GradeScore {[
${self.grade} : ${self.expr}
]}

///////////////////////////////////
/// Expressions
//////////////////////////////////

QuestionReference {
[ Answer to ${self.question} is correct ]
trigger = "question"
referenceShortcut = ${self.question}
}

NrOfCorrectAnswers {
[Number Of Correct Answers]
}

NumberLiteralExpression {
[${value}]
}

///////////////////////////////////
/// Boolean AND and OR
//////////////////////////////////

OrExpression {
symbol = "or"
}
AndExpression {
symbol = "and"
}

///////////////////////////////////
/// Comparisons: <=, >=, >, <, ===
//////////////////////////////////

LessOrEqualsExpression {
symbol = "<="
}
GreaterOrEqualsExpression {
symbol = ">="
}
LessThenExpression {
symbol = "<"
}
GreaterThenExpression {
symbol = ">"
}
EqualsExpression {
symbol = "=="
}
31 changes: 31 additions & 0 deletions packages/samples/EduTutorialNew/lesson8-defs/edu-tests.ast
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
language Education

modelunit Test {
name: identifier;
scenarios: Scenario[];
reference main: SiteGroup;
reference flow: Flow;
}

concept Scenario {
description: string;
testFlow: TestFlow[];
steps: Step[]; /* Note that the order is of importance */
}

concept TestFlow {
steps: Step[]; /* Note that the order is of importance */
}

concept Step {
reference fromPage: Page;
answerSeries: Answer[];
}

concept LastStep base Step {
}

concept Answer {
reference question: Question;
value: NumberConcept;
}
Loading

0 comments on commit f7d0fad

Please sign in to comment.