在Sakai,我通过网址成功获得了Assignemnt:http://xxx/direct/assignment/ASSIGNMENTID.xml
。但是,在这个实体中,没有详细的背景(我的意思是,老师的任务指导)。 XML中只有一个内容contentReference
元素。
<contentReference>/assignment/c/mercury/b0de53c7-09b6-4ba0-964b-cb0a9e5a028d</contentReference>
当我按照这个链接时,我得到404错误:
尝试访问不存在的实体(/ assignment / c)的实体URL路径(/ assignment / c / mercury / b0de53c7-09b6-4ba0-964b-cb0a9e5a028d)
我在Sakai实体上尝试了Google for API文档,但事实证明它已经过时了(我的Sakai 2.9.3的演示版本有些网址错误)。然后我尝试深入挖掘Sakai的源代码。但是,我发现只有rsmart服务器上的文件:
AssignmentEntityProvider.java:
我发现:
throw new IllegalArgumentException(
"Must include context and assignmentId in the path ("
+ view
+ "): e.g. /assignment/a/{context}/{assignmentId}");
我尝试在我的服务器上使用此URL来获取详细内容(尤其是教师的指示)。还有另外一个404错误与上面相同的内容。
最后,我发现/assignment/a/
可能是/assignment/annc/{context}/{assignmentId}
的错误拼写。所以现在我发了:
http://localhost:8080/direct/assignment/annc/mercury/403d28b4-e152-463d-a615-972db97d34d3.xml
弹出另一个错误:
HTTP状态500 - EntityEncodingException:无法处理此路径的格式xml的输出请求(/assignment/annc/mercury/403d28b4-e152-463d-a615-972db97d34d3.xml)以获取实体的前缀(赋值)(/ assignment) / annc),请求url(/assignment/annc/mercury/403d28b4-e152-463d-a615-972db97d34d3.xml):实体的内部输出编码失败:/ assignment / annc
关于通过RESTful获取教师指导数据的网址的任何想法? THX。
作业的XML数据。
<assignment type='bean' size='29'>
<access type='bean' size='0'>
</access>
<attachments type='collection' size='1'>
<decoratedattachment type='bean' size='2'>
<name>LC Circuit (show name).png</name>
<url>http://localhost:8080/access/content/attachment/mercury/%E4%BD%9C%E4%B8%9A/a11ef34a-0578-433a-ba7e-9c3bad948bf5/1111.png</url>
</decoratedattachment>
</attachments>
<authorLastModified>admin</authorLastModified>
<authors type='collection' size='0'>
</authors>
<closeTime type='bean' size='2'>
<display>2014-9-12 下午5:00</display>
<time type='number'>1410512400000</time>
</closeTime>
<closeTimeString>2014-9-12 下午5:00</closeTimeString>
<content/>
<contentReference>/assignment/c/mercury/b0de53c7-09b6-4ba0-964b-cb0a9e5a028d</contentReference>
<context>mercury</context>
<creator>admin</creator>
<dropDeadTime type='bean' size='2'>
<display>2014-8-12 下午5:00</display>
<time type='number'>1407834000000</time>
</dropDeadTime>
<dropDeadTimeString>2014-8-12 下午5:00</dropDeadTimeString>
<dueTime type='bean' size='2'>
<display>2014-8-12 下午5:00</display>
<time type='number'>1407834000000</time>
</dueTime>
<dueTimeString>2014-8-12 下午5:00</dueTimeString>
<groups type='collection' size='0'>
</groups>
<id>403d28b4-e152-463d-a615-972db97d34d3</id>
<openTime type='bean' size='2'>
<display>2014-5-5 下午12:00</display>
<time type='number'>1399262400000</time>
</openTime>
<openTimeString>2014-5-5 下午12:00</openTimeString>
<position_order type='number'>0</position_order>
<section></section>
<status>开始</status>
<timeCreated type='bean' size='2'>
<display>2014-5-5 上午11:33</display>
<time type='number'>1399260782158</time>
</timeCreated>
<timeLastModified type='bean' size='2'>
<display>2014-5-6 上午8:46</display>
<time type='number'>1399337194163</time>
</timeLastModified>
<title>A test assign</title>
<draft type='boolean'>false</draft>
<entityReference>/assignment/403d28b4-e152-463d-a615-972db97d34d3</entityReference>
<entityURL>http://localhost:8080/direct/assignment/403d28b4-e152-463d-a615-972db97d34d3</entityURL>
<entityId>403d28b4-e152-463d-a615-972db97d34d3</entityId>
<entityTitle>A test assign</entityTitle>
</assignment>
答案 0 :(得分:8)
注意:此答案适用于Sakai 10.如果您使用的是旧版本,则需要手动添加一些在项目Keitai(https://jira.sakaiproject.org/browse/SAK-23358)中添加的新功能。< / p>
使用Sakai 10.x夜间服务器:
http://nightly2.sakaiproject.org:8081/portal
具有以下ID的网站:
61a1ebbd-e507-4ca3-8f88-65abca0803d9
此URL将获取课程中作业的列表:
http://nightly2.sakaiproject.org:8081/direct/assignment/site/61a1ebbd-e507-4ca3-8f88-65abca0803d9.json
(返回JSON,如下所示)
{"entityPrefix": "assignment", "assignment_collection": [
{
"access": {
},
"attachments": [],
"authorLastModified": "admin",
"authors": [],
"closeTime": {
"display": "Jun 11, 2014 5:00 pm",
"time": 1402520400000
},
"closeTimeString": "Jun 11, 2014 5:00 pm",
"content": null,
"contentReference": "\/assignment\/c\/61a1ebbd-e507-4ca3-8f88-65abca0803d9\/1fd9f025-2974-48d1-bcb5-ef47c4e89a30",
"context": "61a1ebbd-e507-4ca3-8f88-65abca0803d9",
"creator": "admin",
"dropDeadTime": {
"display": "Jun 11, 2014 5:00 pm",
"time": 1402520400000
},
"dropDeadTimeString": "Jun 11, 2014 5:00 pm",
"dueTime": {
"display": "Jun 11, 2014 5:00 pm",
"time": 1402520400000
},
"dueTimeString": "Jun 11, 2014 5:00 pm",
"groups": [],
"id": "8d96871c-8dcb-4963-b74a-f478dee53142",
"instructions": "<p>This is an assignment<\/p>",
"openTime": {
"display": "Jun 4, 2014 12:00 pm",
"time": 1401897600000
},
"openTimeString": "Jun 4, 2014 12:00 pm",
"position_order": 0,
"section": "",
"status": "Open",
"timeCreated": {
"display": "Jun 4, 2014 11:30 pm",
"time": 1401939011264
},
"timeLastModified": {
"display": "Jun 4, 2014 11:30 pm",
"time": 1401939011286
},
"title": "AZ assignment",
"draft": false,
"entityReference": "\/assignment\/8d96871c-8dcb-4963-b74a-f478dee53142",
"entityURL": "http:\/\/nightly2.sakaiproject.org:8081\/direct\/assignment\/8d96871c-8dcb-4963-b74a-f478dee53142",
"entityId": "8d96871c-8dcb-4963-b74a-f478dee53142",
"entityTitle": "AZ assignment"
}
]}
从那里你可以在列表中找到一个赋值的id(也可以通过其他方式),然后像这样返回单个赋值的数据:
http://nightly2.sakaiproject.org:8081/direct/assignment/item/8d96871c-8dcb-4963-b74a-f478dee53142.json
(返回JSON,如下所示)
{
"access": {
},
"attachments": [],
"authorLastModified": "admin",
"authors": [],
"closeTime": {
"display": "Jun 11, 2014 5:00 pm",
"time": 1402520400000
},
"closeTimeString": "Jun 11, 2014 5:00 pm",
"content": null,
"contentReference": "\/assignment\/c\/61a1ebbd-e507-4ca3-8f88-65abca0803d9\/1fd9f025-2974-48d1-bcb5-ef47c4e89a30",
"context": "61a1ebbd-e507-4ca3-8f88-65abca0803d9",
"creator": "admin",
"dropDeadTime": {
"display": "Jun 11, 2014 5:00 pm",
"time": 1402520400000
},
"dropDeadTimeString": "Jun 11, 2014 5:00 pm",
"dueTime": {
"display": "Jun 11, 2014 5:00 pm",
"time": 1402520400000
},
"dueTimeString": "Jun 11, 2014 5:00 pm",
"groups": [],
"id": "8d96871c-8dcb-4963-b74a-f478dee53142",
"instructions": "<p>This is an assignment<\/p>",
"openTime": {
"display": "Jun 4, 2014 12:00 pm",
"time": 1401897600000
},
"openTimeString": "Jun 4, 2014 12:00 pm",
"position_order": 0,
"section": "",
"status": "Open",
"timeCreated": {
"display": "Jun 4, 2014 11:30 pm",
"time": 1401939011264
},
"timeLastModified": {
"display": "Jun 4, 2014 11:30 pm",
"time": 1401939011286
},
"title": "AZ assignment",
"draft": false,
"entityReference": "\/assignment\/8d96871c-8dcb-4963-b74a-f478dee53142",
"entityURL": "http:\/\/nightly2.sakaiproject.org:8081\/direct\/assignment\/8d96871c-8dcb-4963-b74a-f478dee53142",
"entityId": "8d96871c-8dcb-4963-b74a-f478dee53142",
"entityTitle": "AZ assignment"
}