首页 > 解决方案 > 检查学生是否通过 Moodle 网络服务提交作业

问题描述

我正在尝试使用 Moodle API(网络服务)来获取有关(我的)作业提交的信息。我想知道我是否已经提交了作业尝试。我正在使用该mod_assign_get_assignments函数(没有太多文档),我得到的结果(查看assignments每门课程的部分时)是:

{
  "id": 25960,
  "cmid": 350053,
  "course": 8013502,
  "name": "\u05d4\u05d2\u05e9\u05ea \u05ea\u05e8\u05d2\u05d9\u05dc \u05d1\u05d9\u05ea 1",
  "nosubmissions": 0,
  "submissiondrafts": 0,
  "sendnotifications": 0,
  "sendlatenotifications": 0,
  "sendstudentnotifications": 0,
  "duedate": 1617566400,
  "allowsubmissionsfromdate": 0,
  "grade": 100,
  "timemodified": 1615897679,
  "completionsubmit": 1,
  "cutoffdate": 1617569940,
  "gradingduedate": 0,
  "teamsubmission": 0,
  "requireallteammemberssubmit": 0,
  "teamsubmissiongroupingid": 0,
  "blindmarking": 0,
  "hidegrader": 0,
  "revealidentities": 0,
  "attemptreopenmethod": "manual",
  "maxattempts": 1,
  "markingworkflow": 0,
  "markingallocation": 0,
  "requiresubmissionstatement": 0,
  "preventsubmissionnotingroup": 0
   ...irrelevant configuations
}

以上结果是针对我已经提交的作业。

我没有提交的作业的一个例子是:

{
  "id": 19764,
  "cmid": 268225,
  "course": 8013201,
  "name": "\u05ea\u05d9\u05d1\u05ea \u05d4\u05d2\u05e9\u05d4 14",
  "nosubmissions": 0,
  "submissiondrafts": 0,
  "sendnotifications": 0,
  "sendlatenotifications": 0,
  "sendstudentnotifications": 0,
  "duedate": 1611693000,
  "allowsubmissionsfromdate": 0,
  "grade": 100,
  "timemodified": 1610972842,
  "completionsubmit": 0,
  "cutoffdate": 1611694860,
  "gradingduedate": 0,
  "teamsubmission": 0,
  "requireallteammemberssubmit": 0,
  "teamsubmissiongroupingid": 0,
  "blindmarking": 0,
  "hidegrader": 0,
  "revealidentities": 0,
  "attemptreopenmethod": "manual",
  "maxattempts": 1,
  "markingworkflow": 0,
  "markingallocation": 0,
  "requiresubmissionstatement": 0,
  "preventsubmissionnotingroup": 0
   ...irrelevant configuations
}

这些之间唯一明显的区别(可能指向一种检查我是否提交的方法)是completionsubmit属性,但这不是解决方案,因为我提交的不同分配将其设置为 0(就像那个我没有提交)。

有人知道我该如何解决这个问题吗?

提前致谢!

编辑: mod_assign_get_submissions拒绝我的访问

{"assignments":[],"warnings":[{"item":"assignment","itemid":myitemname,"warningcode":"1","message":"No access rights in module context"}]}

我现在调查了一下mod_assign_get_submission_status,但似乎一次只能解析一个作业,有没有人有办法提高效率?

标签: moodlemoodle-api

解决方案


您可以尝试使用mod_assign_get_submissions来检索对作业的提交。自 Moodle 2.5 起可用

参考

样本响应

{
    "assignments": [
        {
            "assignmentid": 14,
            "submissions": [
                {
                    "id": 7,
                    "userid": 3,
                    "attemptnumber": 0,
                    "timecreated": 1426865031,
                    "timemodified": 1426865062,
                    "status": "submitted",
                    "groupid": 0,
                    "plugins": [
                        {
                            "type": "onlinetext",
                            "name": "Online text",
                            "fileareas": [
                                {
                                    "area": "submissions_onlinetext"
                                }
                            ],
                            "editorfields": [
                                {
                                    "name": "onlinetext",
                                    "description": "Submission comments",
                                    "text": "<p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful.&nbsp;<br></p>",
                                    "format": 1
                                }
                            ]
                        },
                        {
                            "type": "file",
                            "name": "File submissions",
                            "fileareas": [
                                {
                                    "area": "submission_files",
                                    "files": [
                                        {
                                            "filepath": "APDFfile.pdf",
                                            "fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/247/assignsubmission_file/submission_files/12/somefile.pdf"
                                        },
                                        {
                                            "filepath": "anotherfile.docx",
                                            "fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/247/assignsubmission_file/submission_files/12/somefile.pdf"
                                        }
                                    ]
                                }
                            ]
                        },
                        {
                            "type": "comments",
                            "name": "Submission comments"
                        }
                    ]
                },
                {
                    "id": 5,
                    "userid": 4,
                    "attemptnumber": 0,
                    "timecreated": 1426864693,
                    "timemodified": 1426864740,
                    "status": "draft",
                    "groupid": 0,
                    "plugins": [
                        {
                            "type": "onlinetext",
                            "name": "Online text",
                            "fileareas": [
                                {
                                    "area": "submissions_onlinetext",
                                    "files": [
                                        {
                                            "filepath": "/Arte esquemático-Cigüeña.png",
                                            "fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/245/assignsubmission_onlinetext/submissions_onlinetext/5/Arte%20esquem%C3%A1tico-Cig%C3%BCe%C3%B1a.png"
                                        }
                                    ]
                                }
                            ],
                            "editorfields": [
                                {
                                    "name": "onlinetext",
                                    "description": "Submission comments",
                                    "text": "<p>Blah Blah Blah lorem ipsum</p><p><br></p><p><b>Blah Blah Blah lorem ipsum</b><br></p><p><b><br></b></p><p><b><span style=\"font-weight: normal;\"><i>Blah Blah Blah lorem ipsum</i></span><br></b></p><p><b><span style=\"font-weight: normal;\"><i><br></i></span></b></p><p><b><span style=\"font-weight: normal;\"><i><img src=\"@@PLUGINFILE@@/Arte%20esquem%C3%A1tico-Cig%C3%BCe%C3%B1a.png\" alt=\"\" width=\"734\" height=\"844\" role=\"presentation\" style=\"vertical-align:text-bottom; margin: 0 .5em;\" class=\"img-responsive\"><br></i></span></b></p>",
                                    "format": 1
                                }
                            ]
                        },
                        {
                            "type": "file",
                            "name": "File submissions",
                            "fileareas": [
                                {
                                    "area": "submission_files",
                                    "files": [
                                        {
                                            "filepath": "somefile.pdf",
                                            "fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/247/assignsubmission_file/submission_files/12/somefile.pdf"
                                        }
                                    ]
                                }
                            ]
                        },
                        {
                            "type": "comments",
                            "name": "Submission comments"
                        }
                    ]
                }
            ]
        }
    ],
    "warnings": []
}

推荐阅读