作者已经说明外部的评分系统很适合程序设计实践类课程,OpenEdx的LMS可以让学院提交作业的代码,外部评分系统可以测试并返回学生提交的代码的得分。
OpenEdx本身通过XQueue与外部的一些评分系统交互,例如用户提交一个C语言代码,OpenEdx将这个代码以字符串或者文件的方式提交给XQueue,然后Garder(外部评分系统)将定期从XQueue拉取数据,即检查是否有任务,然后并对获得到的代码进行评分。Garder与XQueue使用JSON格式来通信,在文档中,作者列出了一个Garder和XQueue的通信样例,内容如下。
Garder获取到的数据类似于:
{
“xqueue_header”: {
“submission_id”: 12,
“submission_key”: “280587728458c29e1e66ae0c54a806f4”
}
“xqueue_files”: {
“helloworld.c”: “http://download.location.com/helloworld.c”;;
}
“xqueue_body”:
“{
“student_info”: {
“anonymous_student_id”: “106ecd878f4148a5cabb6bbb0979b730”,
“submission_time”: “20160324104521”,
“random_seed”: 334
},
“student_response”: “def double(x):\n return 2*x\n”,
“grader_payload”: “problem_2”
}”
}
Garder返回给XQueue的数据类似于:
{
“correct”: true,
“score”: 1,
“msg”: “<p>The code passed all tests.</p>”
}
在OpenEdx有一个外部评分系统的简单实践,相关实现的项目:https://github.com/edx/xqueue-watcher。
在文档中,作者提到了以下几点,外部测评系统要注意到安全性、并发行、和可靠性,因为大量用户可能在短时间内提交代码,甚至有些代码可能含有恶意代码。同时外部测评系统要足够可靠,只有这样才能给用户良好的使用体验。因此对外部评分系统的测试是不可避免的。
现在看看如何创建一个代码提交类型的问题,在文档里说到,先使用Studio来添加一个“Blank Advanced Problem(空白的高级问题)”,然后使用高级编辑器并输入以下的内容,如下的这种格式成为OLX规范。
<problem>
<coderesponse queuename=”my_course_queue”>
<label>Write a program that prints “hello world”.</label>
<textbox rows=”10″ cols=”80″ mode=”python” tabsize=”4″/>
<codeparam>
<initial_display>
# students please write your program here
print “”
</initial_display>
<answer_display>
print “hello world”
</answer_display>
<grader_payload>
{“output”: “hello world”, “max_length”: 2}
</grader_payload>
</codeparam>
</coderesponse>
</problem>