Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Commit

Permalink
修复单元测&更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Dec 14, 2019
1 parent fa12256 commit cf6c860
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
server/server
config.yaml
.idea
node_modules
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@
[![Build Status](https://www.travis-ci.org/CodFrm/cxmooc-tools.svg?branch=master)](https://www.travis-ci.org/CodFrm/cxmooc-tools)
![GitHub All Releases](https://img.shields.io/github/downloads/codfrm/cxmooc-tools/total.svg)
![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/codfrm/cxmooc-tools.svg?label=version)
![[Chrome](https://chrome.google.com/webstore/detail/%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7/kkicgcijebblepmephnfganiiochecfl?hl=zh-CN)](https://img.shields.io/badge/chrome-success-brightgreen)
![[FireFox](https://addons.mozilla.org/zh-CN/firefox/addon/%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7/)](https://img.shields.io/badge/firefox-success-brightgreen)
![[tampermonkey](https://greasyfork.org/zh-CN/scripts/376190-%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7)](https://img.shields.io/badge/tampermonkey-success-yellowgreen)


## 关于超星慕课小工具
> **[使用文档](https://cx-doc.xloli.top/)**
一个超星(学习通)和智慧树(知到)刷课工具,火狐,谷歌,油猴支持.全自动任务,视频倍速秒过,作业考试题库,验证码自动打码(੧ᐛ੭挂科模式,启动)

### 应用商店
[Chrome商店](https://chrome.google.com/webstore/detail/%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7/kkicgcijebblepmephnfganiiochecfl?hl=zh-CN)
[FireFox商店](https://addons.mozilla.org/zh-CN/firefox/addon/%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7/)
[greasyfork](https://greasyfork.org/zh-CN/scripts/376190-%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7)

### 浏览器适配列表
* [x] Chrome for PC
* [x] Firefox for PC
Expand Down Expand Up @@ -88,6 +97,8 @@ Blog地址:[http://blog.icodef.com/2018/01/25/1304](http://blog.icodef.com/2018/
## 赞助
微信扫一扫,赏个鸡腿?

[赞助列表](https://cx-doc.xloli.top/4-Reward/)

![](docs/.vuepress/public/img/reward.png)

## 免责声明
Expand Down
10 changes: 9 additions & 1 deletion docs/1-UserGuide/1-0-developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ title: 开发者
### 环境:
* Node.js
* webpack
* Yarn

### Build
```bash
Expand Down Expand Up @@ -34,4 +35,11 @@ yarn run server
1. 执行`yarn run build`,此时会在`build/cxmooc-tools`目录下生成插件文件。
2. 打开Chrome浏览器的更多工具选项,打开扩展程序页面并启用开发者模式。
3. 加载已解压的扩展程序,路径选择`build/cxmooc-tools`
3. 加载已解压的扩展程序,路径选择`build/cxmooc-tools`

## 其它
你也可以加入tg群组或者qq群或者在github上发送issue来交流:

[telegram群组](https://t.me/joinchat/MHU8Gg2fP3Q51HLY2wqmQA)

[QQ群790774208](https://jq.qq.com/?_wv=1027&k=5e10NSV)
3 changes: 3 additions & 0 deletions docs/1-UserGuide/1-1-chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
title: Chrome(内核)浏览器安装
---

**chrome商店:[超星慕课小工具](https://chrome.google.com/webstore/detail/%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7/kkicgcijebblepmephnfganiiochecfl?hl=zh-CN)**

如果觉得步骤过于复杂或者繁琐,进直接下载[releases页面](https://github.com/CodFrm/cxmooc-tools/releases)的打包版本,适合小白用户(但是版本更新可能较慢)

## Chrome扩展
> 如果你可以进入chrome商店,那么推荐你直接使用上面的chrome商店链接安装
下载发布的版本[cxmooc-tools.crx](https://github.com/CodFrm/cxmooc-tools/releases)无需安装环境,下载即可使用。

Expand Down
2 changes: 2 additions & 0 deletions docs/1-UserGuide/1-2-firefox.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ title: FireFox插件

本插件上传至了火狐浏览器,可以直接在火狐浏览器的扩展商店进行下载

[FireFox商店](https://addons.mozilla.org/zh-CN/firefox/addon/%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7/)

## 火狐浏览器扩展

如果你是火狐浏览器用户,请直接前往
Expand Down
1 change: 1 addition & 0 deletions docs/1-UserGuide/1-3-tampermonkey.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Tampermonkey,以下都称为油猴

油猴脚本使用需要去安装另外一个**Tampermonkey**插件,然后在 **[Greasy Fork/376190-cxmooc-tools](https://greasyfork.org/zh-CN/scripts/376190-cxmooc-tools)** 页面获取本插件

- [超星慕课小工具](https://greasyfork.org/zh-CN/scripts/376190-%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7)
- [智慧树小工具](https://greasyfork.org/zh-CN/scripts/382037-%E6%99%BA%E6%85%A7%E6%A0%91%E5%B0%8F%E5%B7%A5%E5%85%B7)

### 配置修改
Expand Down
8 changes: 8 additions & 0 deletions docs/1-UserGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ title: 快速开始
本插件提供多种使用方式,暂时只**支持`超星/学习通``智慧树/知到`**,请按照需求查阅相应的文档支持,**遇到问题请优先查看文档/常见问题**,如果文档没有说明/无法解决问题再qq群询问或者发issue.

## 安装

### 应用市场
[Chrome商店](https://chrome.google.com/webstore/detail/%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7/kkicgcijebblepmephnfganiiochecfl?hl=zh-CN)
[FireFox商店](https://addons.mozilla.org/zh-CN/firefox/addon/%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7/)
[greasyfork](https://greasyfork.org/zh-CN/scripts/376190-%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7)

### 小白(推荐)
小白用户使用已经打包好了的浏览器版本使用:[**打包版浏览器**](/1-UserGuide/1-1-chrome.html#打包版浏览器),但是这个更新速度较慢,也可以自己手动更新

或者使用FireFox浏览器,前往FireFox商店下载更新:[**FireFox**](/1-UserGuide/1-2-firefox.html)

[FireFox商店](https://addons.mozilla.org/zh-CN/firefox/addon/%E8%B6%85%E6%98%9F%E6%85%95%E8%AF%BE%E5%B0%8F%E5%B7%A5%E5%85%B7/)

## 刷课

直接进入相对于的刷课平台(超星:[http://mooc.chaoxing.com/](http://mooc.chaoxing.com/),智慧树:[https://passport.zhihuishu.com/login](https://passport.zhihuishu.com/login)),直接打开课程即可.
Expand Down
2 changes: 1 addition & 1 deletion docs/4-Reward/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ title: 捐赠
|金额|渠道|捐赠者|备注|
|----|----|----|----|
|¥ 10.00|微信赞赏码|地瓜|一之大帅比|
|¥ 66.00|支付宝转账|StʌrunneR|解决了工具人给女神刷网课的难题*3|
|¥ 66.00|支付宝转账|StʌrunneR|解决了失去女神的工具人刷网课的难题*3|
|¥ 10.00|微信赞赏码|自律|感谢|
|¥ 10.00|微信赞赏码|蠢黑通行|解决了工具人给女神刷网课的难题*2|
|¥ 10.00|微信赞赏码|深梦||
Expand Down
10 changes: 5 additions & 5 deletions server/application/service/topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ func TestTopic_SubmitTopic(t *testing.T) {
integral: domain.NewIntegralService(mocki),
}

topic1 := dto.SubmitTopic{Answers: []map[string]interface{}{
topic1 := &dto.SubmitTopic{Answers: []map[string]interface{}{
{"option": "A", "content": "选项A"}, {"option": "B", "content": "选项B"}, {"option": "C", "content": "选项C"},
}, Correct: []map[string]interface{}{
{"option": "A", "content": "选项A"}, {"option": "B", "content": "选项B"},
}, Topic: "多选,中文标点。()", Type: 2}

topic2 := dto.SubmitTopic{Answers: []map[string]interface{}{
topic2 := &dto.SubmitTopic{Answers: []map[string]interface{}{
{"option": true, "content": true},
}, Correct: []map[string]interface{}{
{"option": true, "content": true},
Expand All @@ -128,7 +128,7 @@ func TestTopic_SubmitTopic(t *testing.T) {
et.SetTopic("多选,中文标点.()")
mock.On("FindByHash", "05d901980b216c5f8c6b8d6e1f6820b6").Return(et, nil)

hash, add, err := topic.SubmitTopic([]dto.SubmitTopic{topic1, topic2}, "localhost", "cx", "tk")
hash, add, err := topic.SubmitTopic([]*dto.SubmitTopic{topic1, topic2}, "localhost", "cx", "tk")
assert.Nil(t, err)

assert.Equal(t, utils.Md5("多选,中文标点.()2"), hash[0].Hash)
Expand All @@ -137,13 +137,13 @@ func TestTopic_SubmitTopic(t *testing.T) {

topic2.Topic = "error"
mock.On("Exist", "error").Return(false, errors.New("error"))
_, _, err = topic.SubmitTopic([]dto.SubmitTopic{topic1, topic2}, "localhost", "cx", "tk")
_, _, err = topic.SubmitTopic([]*dto.SubmitTopic{topic1, topic2}, "localhost", "cx", "tk")
assert.Error(t, err)

topic2.Topic = "save error"
mock.On("Exist", "save error").Return(false, nil)
mock.On("Save", "save error").Return(errors.New("error"))
_, _, err = topic.SubmitTopic([]dto.SubmitTopic{topic1, topic2}, "localhost", "cx", "tk")
_, _, err = topic.SubmitTopic([]*dto.SubmitTopic{topic1, topic2}, "localhost", "cx", "tk")
assert.Error(t, err)

}
Expand Down
4 changes: 2 additions & 2 deletions server/application/service/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func TestUser_CheckIn(t *testing.T) {
Token: "tk",
Num: 20,
}, nil)
mockt.On("Commit").Return()
mockt.On("Close").Return()
mockt.On("Commit").Return(nil)
mockt.On("Close").Return(nil)

token, err := user.CheckIn("qq")
assert.Nil(t, err)
Expand Down
39 changes: 33 additions & 6 deletions server/domain/repository/mocks/IntegerTransactionRepository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/interface/handler/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (t *topic) excelToTopic(line int, row []string) (*dto.ImportTopic, error) {
if row[0] != "超星" {
// 检测是否有答案内容
for _, val := range ret.Correct {
if v, ok := val["Content"].(string); ok && v == "" {
if v, ok := val["content"].(string); ok && v == "" {
return nil, errs.New(200, -1, strconv.Itoa(line)+"行错误,超星考试和智慧树要求必须有选项内容")
}
}
Expand Down
24 changes: 12 additions & 12 deletions server/interface/handler/topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ func Test_topic_excelToTopic(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, int32(2), topic.Type)
assert.Equal(t, 3, len(topic.Correct))
assert.Equal(t, "A", topic.Correct[0]["Option"])
assert.Equal(t, "", topic.Correct[0]["Content"])
assert.Equal(t, "A", topic.Correct[0]["option"])
assert.Equal(t, "", topic.Correct[0]["content"])

topic, err = tp.excelToTopic(1, []string{
"超星", "红楼梦的艺术价值体现在以下哪几项?", "选择", "C",
})
assert.Nil(t, err)
assert.Equal(t, int32(1), topic.Type)
assert.Equal(t, 1, len(topic.Correct))
assert.Equal(t, "C", topic.Correct[0]["Option"])
assert.Equal(t, "", topic.Correct[0]["Content"])
assert.Equal(t, "C", topic.Correct[0]["option"])
assert.Equal(t, "", topic.Correct[0]["content"])

topic, err = tp.excelToTopic(1, []string{
"超星", "红楼梦的艺术价值体现在以下哪几项?", "选择", "问群",
})
assert.Nil(t, err)
assert.Equal(t, int32(1), topic.Type)
assert.Equal(t, 1, len(topic.Correct))
assert.Equal(t, "A", topic.Correct[0]["Option"])
assert.Equal(t, "问群", topic.Correct[0]["Content"])
assert.Equal(t, "A", topic.Correct[0]["option"])
assert.Equal(t, "问群", topic.Correct[0]["content"])

topic, err = tp.excelToTopic(1, []string{
"超星", "红楼梦的艺术价值体现在以下哪几项?", "选择", "ABC", "",
Expand All @@ -56,21 +56,21 @@ func Test_topic_excelToTopic(t *testing.T) {
"超星考试", "西游记团队中,为什么只有唐僧适合当领导.()", "选择", "唐僧有坚定的信仰与信念。", "唐僧有坚定的目标。",
})
assert.Nil(t, err)
assert.Equal(t, "B", topic.Correct[1]["Option"])
assert.Equal(t, "唐僧有坚定的目标。", topic.Correct[1]["Content"])
assert.Equal(t, "B", topic.Correct[1]["option"])
assert.Equal(t, "唐僧有坚定的目标。", topic.Correct[1]["content"])

topic, err = tp.excelToTopic(1, []string{
"超星考试", "超星慕课小工具文档地址和开源地址", "填空", "https://cx-doc.xloli.top/", "https://github.com/CodFrm/cxmooc-tools", "",
})
assert.Nil(t, err)
assert.Equal(t, "一", topic.Correct[0]["Option"])
assert.Equal(t, "https://cx-doc.xloli.top/", topic.Correct[0]["Content"])
assert.Equal(t, "一", topic.Correct[0]["option"])
assert.Equal(t, "https://cx-doc.xloli.top/", topic.Correct[0]["content"])

topic, err = tp.excelToTopic(1, []string{
"超星考试", "红楼梦是清代世情小说的代表之作.", "判断", "1", "",
})
assert.Nil(t, err)
assert.Equal(t, true, topic.Correct[0]["Option"])
assert.Equal(t, true, topic.Correct[0]["Content"])
assert.Equal(t, true, topic.Correct[0]["option"])
assert.Equal(t, true, topic.Correct[0]["content"])

}

0 comments on commit cf6c860

Please sign in to comment.