提交 d8823734 创建 作者: 宋海霞's avatar 宋海霞

modify

上级 e0d39189
流水线 #156793 已通过 于阶段
用时 1 分 27 秒
# ҪɾĴļ
# 不要删除或更改此文件
*.exe
*.o
*.bak
*.out
*.html
user_output*.txt
user_writefile*
user_*
*.pyc
__pycache__
......@@ -24,7 +24,6 @@ case1:
stage: case1
<<: *codecode-runner
script:
- python3 --version
- python3 .vscode/test.py ./app.exe ci
only:
- master
......@@ -37,6 +36,7 @@ teacher-check1:
- git clone ${CODECODE_PROTOCOL}gitlab-ci-token:${CI_JOB_TOKEN}@${CODECODE_DOMAIN}/${CI_PROJECT_FORKSOURCE} template
- cd template && git checkout -b fork_position ${CI_PROJECT_FORKPOS} && cd ..
- diff template/.gitlab-ci.yml .gitlab-ci.yml -b -B -y -i --suppress-common-lines
- diff template/.vscode/comtool.py .vscode/comtool.py -b -B -y -i --suppress-common-lines
- diff template/.vscode/test.py .vscode/test.py -b -B -y -i --suppress-common-lines
- diff template/.vscode/teacher-check.py .vscode/teacher-check.py -b -B -y -i --suppress-common-lines
- python3 .vscode/teacher-check.py ./app.exe "${TEACHERCHECK_REPO}" "${CODECODE_PROTOCOL}gitlab-ci-token:${CI_JOB_TOKEN}@${CODECODE_DOMAIN}/${TEACHERCHECK_REPO}"
......
......@@ -5,16 +5,15 @@
"label": "生成项目(make)",
"type": "shell",
"windows": {
"command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在使用makefile文件生成项目 ; cat \"${execPath}.tips\\make_tip.txt\" ; make"
"command": "cmd.exe /c type \"'${execPath}.tips\\env_tip.txt'\" ; echo \"`\" ; cmd.exe /c echo VSCode安装路径-${execPath} ; echo 正在使用makefile文件生成项目 ; cmd.exe /c type \"'${execPath}.tips\\make_tip.txt'\" ; echo \"`\" ; make"
},
"linux": {
"command": "echo 正在使用makefile文件生成项目 && echo VSCode安装路径-${execPath} ; echo 正在使用makefile文件生成项目 && echo \"如果报告 ld.exe: cannot open output file app.exe: Permission denied 错误,可以 重启 vscode 或者 重启计算机\" && make && echo 生成项目成功"
"command": "echo 更多帮助请参考 https://www.codecode.net/engintime/codecode/publicmanual/blob/master/VSCodeFAQ.md && echo 正在使用makefile文件生成项目 && echo VSCode安装路径-${execPath} ; echo 正在使用makefile文件生成项目 && echo \"如果报告 ld.exe: cannot open output file ***.exe: Permission denied 错误,可以 重启 vscode 或者 重启计算机\" && make && echo 生成项目成功"
},
"args": [],
"group": "build",
"presentation": {
"reveal": "always",
"focus": true,
"group": "make"
},
"problemMatcher": "$gcc"
......@@ -23,10 +22,10 @@
"label": "安装python包",
"type": "shell",
"windows": {
"command": "pip install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt"
"command": "echo 更多帮助请参考https://www.codecode.net/engintime/codecode/publicmanual/blob/master/VSCodeFAQ.md ; pip install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt"
},
"linux": {
"command": "pip3 install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt"
"command": "echo 更多帮助请参考 https://www.codecode.net/engintime/codecode/publicmanual/blob/master/VSCodeFAQ.md && pip3 install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt"
},
"args": [],
"group": "build",
......@@ -40,10 +39,10 @@
"label": "测试(test)",
"type": "shell",
"windows": {
"command": "cat \"${execPath}.tips\\python_tip.txt\" ; python .vscode\\test.py .\\app.exe"
"command": "cmd.exe /c type \"'${execPath}.tips\\python_tip.txt'\" ; echo \"`\" ; python .vscode\\test.py .\\app.exe"
},
"linux": {
"command": "python3 .vscode/test.py ./app.exe"
"command": "echo 更多帮助请参考 https://www.codecode.net/engintime/codecode/publicmanual/blob/master/VSCodeFAQ.md && python3 .vscode/test.py ./app.exe"
},
"args": [],
"group": "build",
......@@ -57,10 +56,10 @@
"label": "清理项目(make clean)",
"type": "shell",
"windows": {
"command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在使用makefile文件清理项目 ; make clean"
"command": "cmd.exe /c type \"'${execPath}.tips\\env_tip.txt'\" ; echo \"`\" ; cmd.exe /c echo VSCode安装路径-${execPath} ; echo \"`\" ; echo 正在使用makefile文件清理项目 ; make clean"
},
"linux": {
"command": "echo 正在使用makefile文件清理项目 && make clean && echo 清理项目成功"
"command": "echo 更多帮助请参考 https://www.codecode.net/engintime/codecode/publicmanual/blob/master/VSCodeFAQ.md && echo 正在使用makefile文件清理项目 && make clean && echo 清理项目成功"
},
"args": [],
"group": "build",
......@@ -74,10 +73,10 @@
"label": "提交作业(git push)",
"type": "shell",
"windows": {
"command": "cat \"${execPath}.tips\\python_tip.txt\" ; python .vscode\\gitpush.py"
"command": "cmd.exe /c type \"'${execPath}.tips\\python_tip.txt'\" ; echo \"`\" ; python .vscode\\gitpush.py"
},
"linux": {
"command": "python3 .vscode/gitpush.py"
"command": "echo 更多帮助请参考 https://www.codecode.net/engintime/codecode/publicmanual/blob/master/VSCodeFAQ.md && python3 .vscode/gitpush.py"
},
"args": [],
"group": "build",
......@@ -91,27 +90,10 @@
"label": "内存检测",
"type": "shell",
"windows": {
"command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在使用Dr.Memory检测内存 ; make ; cmd.exe /c \"drmemory -ignore_kernel -leaks_only -brief -batch -- .\\app.exe '<' input1.txt\""
"command": "cmd.exe /c type \"'${execPath}.tips\\env_tip.txt'\" ; echo \"`\" ; cmd.exe /c echo VSCode安装路径-${execPath} ; echo \"`\" ; echo 正在使用Dr.Memory检测内存 ; python .vscode/memorycheck.py .\\app.exe"
},
"linux": {
"command": "echo 正在使用 Valgrind 检测内存 && make && echo ***如果提示 /bin/bash: valgrind: command not found 可使用终端命令 sudo apt install valgrind 安装(需要连接互联网)*** && valgrind --leak-check=full ./app.exe < input1.txt"
},
"args": [],
"group": "build",
"presentation": {
"reveal": "always",
"group": "test"
},
"problemMatcher": "$gcc"
},
{
"label": "内存检测2",
"type": "shell",
"windows": {
"command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在使用Dr.Memory检测内存 ; python .vscode/memorycheck.py .\\app.exe"
},
"linux": {
"command": "echo 正在使用 Valgrind 检测内存 && make && echo ***如果提示 /bin/bash: valgrind: command not found 可使用终端命令 sudo apt install valgrind 安装(需要连接互联网)*** && python3 .vscode/memorycheck.py ./app.exe"
"command": "echo 更多帮助请参考 https://www.codecode.net/engintime/codecode/publicmanual/blob/master/VSCodeFAQ.md && echo 正在使用 Valgrind 检测内存 && make && echo ***如果提示 /bin/bash: valgrind: command not found 可使用终端命令 sudo apt install valgrind 安装(需要连接互联网)*** && python3 .vscode/memorycheck.py ./app.exe"
},
"args": [],
"group": "build",
......
......@@ -64,10 +64,12 @@ def compare_file(file1, file2, type):
comResult = advanced_file_compare(file1, file2)
if comResult == 1:
print("文件相同")
print()
sys.stdout.flush()
returnVal = 1
else:
print("文件不同")
print()
sys.stdout.flush()
return returnVal
......@@ -107,6 +109,7 @@ if __name__ == "__main__":
runCmpCommand = "diff template/{0} {0} -b -B -y -i --suppress-common-lines".format(resultFile)
runCmd(runCmpCommand)
exit(1)
# 执行完成文件完整性检查
os.system("fileidentity.sh")
......
......@@ -73,6 +73,8 @@ def compare_file(file1, file2, seqNum, caseCount, bCI, resultFileType, dsType):
promptInfo = "Case{0} 验证成功".format(seqNum)
outputPromptInfo(bCI, promptInfo, Color.green)
print("exec-score", int(score))
print()
sys.stdout.flush()
else:
promptInfo = "Case{0} 验证成功, 分数: {1}".format(seqNum, int(score))
outputPromptInfo(bCI, promptInfo, Color.green)
......@@ -158,6 +160,8 @@ if __name__ == "__main__":
outputPromptInfo(bCI, promptInfo, Color.green)
promptInfo = "exec-score {0}".format(score)
print(promptInfo)
print()
sys.stdout.flush()
else:
promptInfo = "生成项目成功, 分数 {0}".format(score)
outputPromptInfo(bCI, promptInfo, Color.green)
......@@ -176,6 +180,13 @@ if __name__ == "__main__":
break
caseCount += 1
if caseCount > 0:
if bCI :
print(yellow("标准答案结果文件和用户输出结果文件的比较原则是:比较时忽略行尾空白字符和文件末尾的空白行。"))
else:
print(Fore.YELLOW + "标准答案结果文件和用户输出结果文件的比较原则是:比较时忽略行尾空白字符和文件末尾的空白行。", file = stream, end='')
print(Fore.WHITE, file = stream)
seqNum = 1
while 1:
dsFile = dsFileStr.format(seqNum)
......@@ -191,12 +202,6 @@ if __name__ == "__main__":
break
if not os.path.isfile(resultFile):
break
if bCI :
print(yellow("标准答案结果文件和用户输出结果文件的比较原则是:比较时忽略行尾空白字符和文件末尾的空白行。"))
else:
print(Fore.YELLOW + "标准答案结果文件和用户输出结果文件的比较原则是:比较时忽略行尾空白字符和文件末尾的空白行。", file = stream, end='')
print(Fore.WHITE, file = stream)
if dsType == DataSourceFileType.noinput:
print("正在验证 case{0}".format(seqNum))
......
......@@ -34,4 +34,4 @@ else
endif
clean:
$(RM) *.exe *.o result_comparation.html user_output* user_writefile*
\ No newline at end of file
$(RM) *.exe *.o result_comparation.html user_*
\ No newline at end of file
# 求分段函数
\ No newline at end of file
# 说明
一个模板中可以包含一个或多个测试算例,主要用于读者自行检查编写的程序是否符合实验题目的要求,同时,教师还可以通过附加算例检查学生是否作弊。每个测试算例中需要包含数据源文件和结果文件,数据源文件可以是重定向的标准输入文件,也可以是通过命令行提供的文本文件和二进制文件,结果文件可以是重定向的标准输出文件,也可以是通过命令行提供的文本文件和二进制文件。根据数据源文件和结果文件的不同,可以分为以下几种情况:
## 标准输入和标准输出
数据源文件是通过输入重定向提供的,文件名:input1.txt。结果文件是通过重定向输出提供的,文件名:output1.txt。数据源文件和结果文件可以是以下组合:
(1)数据源文件:input1.txt,结果文件:output1.txt。
(2)数据源文件:无,结果文件:output1.txt。
`注意`:如果包含多个测试算例以此类推,测试算例2使用的是 input2.txt 和 output2.txt。
## 读文件和写文件
数据源文件是通过命令行参数提供的,如果读取的是二进制文件,文件名:readfile1.dat,如果读取的是文本文件,文件名:readfile1.txt。结果文件也是通过命令行参数提供的,如果写入的是二进制文件,文件名:writefile1.dat,如果写入的是文本文件,文件名:writefile1.txt。数据源文件和结果文件可以是以下组合:
(1)数据源文件:readfile1.txt,结果文件:writefile1.dat。
(2)数据源文件:readfile1.txt,结果文件:writefile1.txt。
(3)数据源文件:readfile1.dat,结果文件:writefile1.dat。
(4)数据源文件:readfile1.dat,结果文件:writefile1.txt。
## 读文件和标准输出
数据源文件是通过命令行参数提供的,如果读取的是二进制文件,文件名:readfile1.dat,如果读取的是文本文件,文件名:readfile1.txt。结果文件是通过重定向输出提供的,文件名:output1.txt。
数据源文件和结果文件可以是以下组合:
(1)数据源文件:readfile1.txt,结果文件:output1.txt。
(2)数据源文件:readfile1.dat,结果文件:output1.txt。
## 标准输入和写文件
数据源文件是通过输入重定向提供的,文件名:input1.txt。结果文件也是通过命令行参数提供的,如果写入的是二进制文件,文件名:writefile1.dat,如果写入的是文本文件,文件名:writefile1.txt。数据源文件和结果文件可以是以下组合:
(1)数据源文件:input1.txt,结果文件:writefile1.dat。
(2)数据源文件:input1.txt,结果文件:writefile1.txt。
## 读取指定文件和输出
如果在编写程序直接将文件名称写入到程序中,该文件如果是二进制文件,文件名为:specifyfile.dat,如果是文本文件,文件名:specifyfile.txt。结果文件是通过命令行参数提供的,如果写入的是二进制文件,文件名:writefile1.dat,如果写入的是文本文件,文件名:writefile1.txt; 结果文件是通过重定向输出提供的,文件名:output1.txt。数据源文件和结果文件可以是以下组合:
(1)数据源文件:无,结果文件:writefile1.dat。
(2)数据源文件:无,结果文件:writefile1.txt。
(3)数据源文件:无,结果文件:output1.txt。
# 使用方法
为学生布置任务前,要先使用此模板创建一个任务模板。方法如下:
1. 在自己的群组中新建一个项目,新建项目时,不要创建空白项目,选择右侧的“导入项目”,然后选择“Repo by URL”作为导入源。将本项目的Git URL复制到“Git仓库URL”中。其他的控件按照自己的要求填入后,点击最下方的“创建项目”按钮,完成新建项目。这个新建的项目会用于给学生创建任务。
2. 打开 VSCode,将新建的项目克隆到本地。
3. 编辑数据源文件和结果文件。写入实验要求的输入输出内容。
4. 编辑 readme.md 文件的内容,通常在此文件中写明实验的要求,让学生依据要求完成实验。推荐将输入输出样例写入 readme.md 文件中方便学生查看。
5. 如果有必要,也可以修改 main.c 文件,提供一个合适的代码基。或者在项目中加入其它的头文件和C文件。
6. 推送项目到 Git 远程库。
7. 如果有答案源代码的话,最好能做一个测试,确保学生能够顺利完成实验。方法是:新建一个课程,使用刚刚制作的模板项目新建一个任务,将学生添加到课程中,发布课程和任务后,使用学生账号领取任务,打开VSCode,然后在克隆任务的项目时根据提示输入学生账号,将源代码答案填入main.c文件后提交作业。如果线上的流水线成功,并得到了100分。说明模板制作成功了。否则需要按照上面的步骤继续修改模板。
  • Developer

    代码质量分析发现了 7 个问题。

    • 0 blocker
    • 🚫 0 critical
    • 0 major
    • 🔽 4 minor
    • 3 info

    注意: 存在下列问题的代码行在本次提交中没有发生变更,无法使用代码行评论的方式进行报告。所以将下列问题汇总显示在这里(点击问题链接可以转到对应的源代码行):

    1. 🔽 Cppcheck cannot find all the include files. Cppcheck can check the code without the include files found. But the results will probably be more accurate if all the include files are found. Please check your project's include directories and add all of them as include directories for Cppcheck. To see what files Cppcheck cannot find use --check-config. (ProjectKey-176961) 📘
    2. 🔽 Variable 'b' is assigned a value that is never used. 📘
    3. 🔽 Either the condition 'fp2!=0' is redundant or there is possible null pointer dereference: fp2. 📘
    4. 🔽 Either the condition 'fp!=0' is redundant or there is possible null pointer dereference: fp. 📘
    5. keyword 'if' not followed by a single space 📘
    6. closing curly bracket not in the same line or column 📘
    7. closing curly bracket not in the same line or column 📘
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论