add a basic example of a page

This commit is contained in:
Michael Zhang 2021-08-28 05:52:47 -05:00
parent 447e402929
commit cf562b6ec1
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
10 changed files with 117 additions and 20 deletions

View file

@ -3,5 +3,5 @@ root = true
[*] [*]
indent_style = space indent_style = space
[*.{svelte,ts,json}] [*.{svelte,ts,json,rst}]
indent_size = 2 indent_size = 2

1
compile-database/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/test.db

14
compile-database/db.ts Normal file
View file

@ -0,0 +1,14 @@
import { Sequelize, Model, DataTypes } from "sequelize";
class Page extends Model {}
export async function init(path: string) {
let sequelize = new Sequelize(`sqlite:${path}`);
Page.init({
}, { sequelize, modelName: "page" });
await sequelize.sync();
return sequelize;
}

View file

@ -0,0 +1,30 @@
import { readdir, readFile } from "fs/promises";
import { join } from "path";
import * as yaml from "js-yaml";
import { init } from "./db";
class Page {
}
async function main() {
// TODO: configure this thru cmdline or something later
let materials_dir = "../material";
let db_file = "test.db";
let db = await init(db_file);
let names = await readdir(materials_dir);
await Promise.all(names
.filter(name => name.toLowerCase().endsWith(".yml"))
.map(async name => {
let path = join(materials_dir, name);
let rawData = await readFile(path, { encoding: "utf8" });
let parsedData = yaml.load(rawData);
console.log("data", parsedData);
})
);
}
main();

View file

@ -1,6 +1,14 @@
{ {
"name": "compile-database", "name": "compile-database",
"scripts": {
"start": "ts-node index.ts"
},
"devDependencies": { "devDependencies": {
"ts-node": "^10.2.1" "ts-node": "^10.2.1"
},
"dependencies": {
"js-yaml": "^4.1.0",
"sequelize": "^6.6.5",
"sqlite3": "^5.0.2"
} }
} }

View file

@ -0,0 +1,5 @@
{
"compilerOptions": {
"experimentalDecorators": true
}
}

View file

@ -1,19 +1,2 @@
material material
=== ===
This directory contains the material that's used in eduproj. The documents are
all written using restructured text, chosen over markdown for its ability to
specify more structured data while still appearing readable to humans.
Recognized fields
---
General fields:
- `:title:` specifies the title that will be used when rendering it to a page.
- `:summary:` is a paragraph-long description of what the topic being discussed
is, and will be included in hover boxes or info boxes when included in other
pages.

4
material/fp-course.yml Normal file
View file

@ -0,0 +1,4 @@
title: Functional Programming Basics
content: |
This listing contains some of the basics of functional programming.

33
material/fp-function.yml Normal file
View file

@ -0,0 +1,33 @@
title: Functions
summary: |
Functions describe a process of turning *inputs* into *outputs*.
content: |
In a purely mathematical setting, functions typically have one input and one
output, but in functional programming, we can usually get around this either
by using [tuples][1] or by [currying][2].
[1]: page://tuples
[2]: page://currying
exercises:
- description: |
Write a function called `doubleIt` that takes an integer and doubles it.
examples:
ocaml:
- |
grader:
ocaml:
style: studentModule
props:
interface: |
val doubleIt : int -> int
driver: |
open List
let () = List.iter
(fun x -> assert ((doubleIt x) = (x * 2)))
(List.init 100 (fun x -> x + 1));

View file

@ -1,9 +1,11 @@
concepts: concepts:
- learning targets - learning targets
- can relate to other concepts in the following ways: - can relate to other concepts in the following ways:
- concept A "depends" on concept B; explaining concept A requires some information from concept B - concept A "depends" on concept B; explaining concept A requires some
information from concept B
- concept A "optdepends" on concept B - concept A "optdepends" on concept B
- concept A "satisfies" concept B; mastery of concept A implies mastery of concept B - concept A "satisfies" concept B; mastery of concept A implies mastery of
concept B
topics: topics:
- groups of concepts - groups of concepts
@ -15,3 +17,20 @@ each user has a mastery level for each concept
references: references:
- super memo algorithm used by anki: https://en.wikipedia.org/wiki/SuperMemo#Description_of_SM-2_algorithm - super memo algorithm used by anki: https://en.wikipedia.org/wiki/SuperMemo#Description_of_SM-2_algorithm
---
ocaml should have a runner studentModule, which just puts the student code into
a file called student.ml
the material file defines a student.mli, as well as a driver.ml, then they all
get called using:
```
ocamlc -c student.mli # produces student.cmi
ocamlc -c student.ml # produces student.cmo
ocaml student.cmo driver.ml
```
probably should have like $OCAMLCFLAGS in there to be able to customize each
step as well