提交 9780cc57 编写于 作者: M Mars Liu

add readme

上级 7d090cd8
......@@ -16,17 +16,17 @@ pip install -r requirement.txt
* 位置:`data/config.json`
* 说明:可编辑配置关键词等字段,其中 `node_id` 字段是生成的,请勿编辑
* 技能树`难度节点`
* 位置:`data/xxx`,例如: `data/1.Java初阶`
* 位置:`data/xxx`,例如: `data/1.Oceanbase初阶`
* 说明:
* 每个技能树有 3 个等级,目录前的序号是必要的,用来保持文件夹目录的顺序
* 每个目录下有一个 `config.json` 可配置关键词信息,其中 `node_id` 字段是生成的,请勿编辑
* 技能树`章节点`
* 位置:`data/xxx/xxx`,例如:`data/1.Java初阶/1.Java概述`
* 位置:`data/xxx/xxx`,例如:`data/1.OceanBase初阶/1.快速入门`
* 说明:
* 每个技能树的每个难度等级有 n 个章节,目录前的序号是必要的,用来保持文件夹目录的顺序
* 每个目录下有一个 `config.json` 可配置关键词信息,其中 `node_id` 字段是生成的,请勿编辑
* 技能树`知识节点`
* 位置:`data/xxx/xxx/xxx`,例如:`data/1.Java初阶/1.Java概述/1.什么是Java`
* 位置:`data/xxx/xxx/xxx`,例如:`data/1.OceanBase初阶/1.快速入门/1.安装OBD`
* 说明:
* 每个技能树的每章有 `n` 个知识节点,目录前的序号是必要的,用来保持文件夹目录的顺序
* 每个目录下有一个 `config.json`
......@@ -38,9 +38,8 @@ pip install -r requirement.txt
## `知识节点` 子树信息结构
例如 `data/1.Java初阶/1.Java概述/1.什么是Java/config.json` 里配置对该知识节点子树信息结构:
例如 `data/1.OceanBase初阶/7.查询数据/config.json` 里配置对该知识节点子树信息结构:
```json
{
// ...
"children": [
......@@ -53,21 +52,18 @@ pip install -r requirement.txt
## `知识节点` 的导出习题编辑
例如 `data/1.Java初阶/1.Java概述/1.什么是Java/config.json` 里配置对该知识节点导出的习题
例如 `data/1.OceanBase初阶/7.查询数据/config.json` 里配置对该知识节点导出的习题
```json
{
// ...
"export": [
// TODO ...
"hello.json"
]
}
```
格式说明:
* `file`: 指定该目录下的习题源文件
* `variants`: 指定习题同名的json选项配置文件,参考下一节
* `depends`: 如果习题依赖同目录下的其他习题源代码,则在此字段里配置依赖的其他习题源文件名
每个文件名,指向对应的习题定义 json 。
## `知识节点` 的导出习题选项配置编辑
......@@ -78,16 +74,30 @@ pip install -r requirement.txt
### 使用替换规则编写习题
首先,在知识节点下增加一个习题代码,例如在 `data/1.Java初阶/1.Java概述/1.什么是Java` 下增加一个`HelloWorld.java`代码
首先,在知识节点下增加一个习题定义文件,例如 hello.json
```java
public class App {
public static void main(String[] args){
System.out.println("Hello world!")
}
```json
{
"type": "code_options",
"author": "刘鑫",
"source": "hello.sql",
}
```
其中
* 类型现在仅支持 `code_options` 一种,保持不变即可
* author 是题目作者
* source 指题目定义,题目可以是源代码 + 替换规则的形式,也可以用 markdown 编写
我们先讨论使用替换规则定义题目的方式。
例如在 `data/1.OceanBase初阶/7.查询数据` 下增加一个`hello.sql`代码文件:
```sql
select 'hello';
```
其次,增加一个同名的选项配置文件`HelloWorld.json`,目前有三种配置规则
#### 单行替换规则
......@@ -100,36 +110,24 @@ public class App {
```json
{
"one_line": {
"println": ["printf", "print", "fprint"]
"select": ["print", "log", "echo"]
}
}
```
上面的替换规则会将代码替换成 3 个变种的代码:
```java
public class App {
public static void main(String[] args){
System.out.print("Hello world!")
}
}
```sql
print 'hello';
```
```java
public class App {
public static void main(String[] args){
System.out.printf("Hello world!")
}
}
log 'hello';
```
```java
public class App {
public static void main(String[] args){
System.out.sprint("Hello world!")
}
}
echo 'hello';
```
这些变种代码将会作为技能树该知识点该代码选择题的选项。
......@@ -141,46 +139,63 @@ public class App {
例如:
假设我们有习题代码:
```sql
begin
update parent set children = children + $child
insert child(c select $child;
commit;
end
```
和变形规则
```json
{
"mulitiline": [{
"public class": "public interface",
"main(": "Main("
"begin": "{",
"end": "}"
},
{
"public class": "interface",
"void main": "int main"
"commit": "save",
"begin": "try{",
"commit;": "",
"end": "}finally{\n\tsave;\n}"
},
{
"public static void main": "public void main"
"begin": "begin:",
"commit;": "",
"end": "finally: \tcommit;"
}]
```
上面的替换规则会将代码替换成 3 个变种的代码:
```java
public interface App {
public static void Main(String[] args){
System.out.println("Hello world!")
}
```sql
{
update parent set children = children + $child
insert child(c select $child;
commit;
}
```
```java
public interface App {
public static int main(String[] args){
System.out.println("Hello world!")
}
}
```sql
try{
update parent set children = children + $child
insert child(c select $child;
}finally{
save;
}
```
```java
public class App {
public void main(String[] args){
System.out.print("Hello world!")
}
}
```sql
begin:
update parent set children = children + $child
insert child(c select $child;
finally:
commit;
```
这些变种代码将会作为技能树该知识点该代码选择题的选项。
......@@ -196,38 +211,31 @@ public class App {
```json
{
"prepared": [
"HelloWord.1.java",
"HelloWord.2.java",
"HelloWord.3.java"]
"hello.1.sql",
"hello.2.sql",
"hello.3.sql"]
}
```
同样,该配置将支持将源代码生成3个变种代码
```java
// HelloWord.1.java
public interface App {
default void Main(String[] args){
System.out.println("Hello world!")
}
}
```
```sql
try{
update parent set children = children + $child
insert child(c select $child;
```java
public interface App {
public static void main(String[] args){
System.out.println("Hello world!")
}
}finally{
save;
}
```
```java
class App {
void main(String[] args){
System.out.print("Hello world!")
}
}
```sql
begin:
update parent set children = children + $child
insert child(c select $child;
finally:
commit;
```
### 使用 markdown 编写习题
......@@ -253,62 +261,38 @@ class App {
## 答案
```java
```sql
public class App {
public static void main(String[] args){
System.out.println("Hello World");
}
}
select 'hello';
```
## 选项
### A
```java
public class App {
public int main(){
System.out.printf("Hello World");
return 0;
}
}
```sql
print 'hello';
```
### B
```java
public class App {
public static void main(String[] args){
println("Hello World");
}
}
```sql
echo 'hello';
```
### C
```java
import stdout
public class App {
public int main(){
print("Hello World\n");
return 0;
}
}
```sql
log 'hello';
```
````
这是一个最基本的习题结构,它包含标题、答案、选项,注意这几个一级和二级标题必须填写正确,解释器会读取这几个标题。而选项的标题会被直接忽略掉,在
最终生成的习题中不包含选项的三级标题,所以这个标题可以用来标注一些编辑信息,例如“此选项没有关闭文件连接”,“类型错误”等等。
这是一个最基本的习题结构,它包含标题、答案、选项,注意这几个一级和二级标题必须填写正确,解释器会读取这几个标题。而选项的标题会被直接忽略掉,在最终生成的习题中不包含选项的三级标题,所以这个标题可以用来标注一些编辑信息,例如“此选项没有关闭文件连接”,“类型错误”等等。
### 增强信息
为了编写习题和生成 notebook 的需要,markdown 解释器支持两种模板能力,如果我们在答案之前,有一个名为 aop 的二级标题:
为了编写习题和生成 notebook 的需要,markdown 解释器支持两种模板能力,具体到 oceanbase ,现在还没有对应的 notebook 支持,所以这部分内容仅供参考,未来如果支持了 oceanbase notebook,就按照下文规范。
````markdown
......@@ -316,14 +300,14 @@ public class App {
### before
```java
System.out.print("hello world");
```sql
create table test(id integer primary key, content varchar(256));
```
### after
```java
App.main(new String[]{});
drop table test;
```
````
......@@ -335,13 +319,11 @@ App.main(new String[]{});
## template
```java
public class App {
public static void main(String[] args){
// 下面的 code 占位符会被替换成答案和选项代码
$code
}
}
```sql
begin
$code
end;
```
````
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册