# 课程任务

步骤是课程的基本组成部分，每个步骤都对应一个`index.yml`文件，每个课程步骤中可以包含多个任务。任务由事件触发，并执行相应的操作。

![课程步骤](../../img/course-step-status.png)
## 步骤配置

步骤由以下字段组成：

|类型|是否必须|说明|
|:--|:--:|:--|
|link|✓|任务地点，当点击对应任务的继续学习按钮时跳转的 Url|
|transitions|✓|当前任务涉及的事务单元集合，由events、actions组成|
|description|✓|任务名称，该步骤中预期动作的详细说明。显示在步骤标题下方，可用于标识课程学习进度|
|events|✓|webhook事件名称，用于触发步骤|
|action|✓|触发步骤时将执行的操作的列表。将任务标记为完成需要完成任务中的所有动作。|
|to|✓|任务完成后的后续步骤|

## 参考示例

以下是《Markdown 入门课程》中第六章：列表 的`index.yml`示例：

```yaml
before: 
  link: '{{chapter_6_issue}}'
  transitions:
    action:
      - type: issue_comment.created
        with: first.md
    to: step1

# Task 列表
step1:
  link: '{{chapter_6_issue}}'
  description: "无序列表"
  transitions:
    events: ['note_events']
    action:
      - type: issue_comment.created
        with: 006_2_ul_list.md
      - type: choice
        with: next.md
    to: step2

step2:
  link: '{{chapter_6_issue}}'
  description: "有序列表"
  transitions:
    events: ['note_events']
    action:
      - type: issue_comment.created
        with: 006_3_ol_list.md
      - type: choice
        with: next.md
    to: step3

step3:
  link: '{{chapter_6_issue}}'
#  description: "Markdown 转义"
  transitions:
    events: ['note_events']
    action:
      - type: issue_comment.created
        with: 006_4_markdown_transfer.md
      - type: issue_comment.created
        with: 006_5_list_nest.md
      - type: choice
        with: next.md
    to: step4

step4:
  link: '{{chapter_6_issue}}'
  description: "任务列表"
  transitions:
    events: ['note_events']
    action:
      - type: issue_comment.created
        with: 006_6_todo_list.md
      - type: issue_comment.created
        with: 006_7_todo_list_nest.md
      - type: choice
        with: exam.md
    to: step5

step5:
  link: '{{chapter_6_issue}}'
#  description: "任务列表"
  transitions:
    events: ['note_events']
    action:
      - type: choice
        with: 006_8_ul_list_exam.md
    to: step6

step6:
  link: '{{chapter_6_issue}}'
#  description: "创建一个无序列表"
  transitions:
    - events: ['note_events']
      left: '/(?:\*|-|\+)\s.+/'
      operator: regexp
      right: '{{object_attributes.note}}'
      action:
        - type: issue_comment.created
          with: 006_8_done.md
        - type: choice
          with: 006_8_ol_list_exam.md
      to: step7
    - events: ['note_events']
      else: true
      action: 
        - type: issue_comment.created
          with: 006_8_ul_error.md
      to: step6

step7:
  link: '{{chapter_6_issue}}'
#  description: "创建一个有序列表"
  transitions:
    - events: ['note_events']
      left: '/(?:\d\.)\s.+/'
      operator: regexp
      right: '{{object_attributes.note}}'
      action:
        - type: issue_comment.created
          with: 006_8_done.md
        - type: choice
          with: 006_8_todo_list_exam.md
      to: step8
    - events: ['note_events']
      else: true
      action: 
        - type: issue_comment.created
          with: 006_8_ol_error.md
      to: step7

step8:
  link: '{{chapter_6_issue}}'
#  description: "创建一个任务列表"
  transitions:
    - events: ['note_events']
      left: '/(-|\*)\s+\[[x|X|\s]\]\s+.+/'
      operator: regexp
      right: '{{object_attributes.note}}'
      action:
        - type: issue_comment.created
          with: 006_8_done.md
        - type: issue_comment.created
          with: 006_9_end_1.md
      to: step9
    - events: ['note_events']
      else: true
      action: 
        - type: issue_comment.created
          with: 006_8_todo_error.md
      to: step8

step9:
  link: '{{chapter_6_issue}}'
#  description: "完成当前章节学习"
  transitions:
    events: ['close_issue']
    action:
      - type: create_issue
        title: "Markdown ：分隔线及引用"
        with: 007_1_horizon_basic.md
        store:
          chapter_7_issue: '{{result.data.html_url}}'
      - type: issue_comment.created
        with: 006_9_end_2.md
    to: end
```