【问题标题】:How to post grade on an assignment using canvas LMS API and UnityWeb Request or similar?如何使用画布 LMS API 和 UnityWeb 请求或类似工具发布作业成绩?
【发布时间】:2021-07-09 11:28:33
【问题描述】:

我正在从事一个游戏化项目,其目标是使用 Unity 构建 WebGL 游戏,并使用 canvas LMS API 将最终分数作为作业成绩发布。我需要知道两件事:现在如何使用不记名令牌进行身份验证(我已经知道如何创建令牌,以后需要使用 auth 2.0)以及如何使用 UnityWeb 请求或类似方法发布作业成绩。我尝试使用restsharp,vs代码识别它,但Unity没有。还尝试与node.js建立连接,Unity和node.js连接成功,但是我使用的节点包装器不起作用。

在最糟糕的情况下,我希望能够对作业发表评论(我会以字符串形式通过最终成绩)。

这是我用 httpWebRequest 尝试过的:

string api_token = "bearer token here";
    //initializing HttpWebRequest object   
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("domain here");
    IWebProxy theProxy = request.Proxy;
    if (theProxy != null)
    {
        theProxy.Credentials = CredentialCache.DefaultCredentials;
    }
    CookieContainer cookies = new CookieContainer();
    request.UseDefaultCredentials = true;
    request.CookieContainer = cookies;
    request.ContentType = "application/json";
    request.CookieContainer = cookies;
    // write the "Authorization" header  
    request.Headers.Add("Authorization", "Basic " + api_token);
    request.Method = "POST";
    // get the response  
    //WebResponse response = request.GetResponse();  
    using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
    {
        StreamReader reader = new StreamReader(response.GetResponseStream());
        Debug.Log(reader.ReadToEnd());
    }

我需要节点包装器来进行身份验证和发布请求。 节点包装器:c10. I've tried with this one a lotnode-canvas-api

我可以访问 api 并使用邮递员发帖。

【问题讨论】:

  • 你能分享你尝试过的例子吗?如果 Unity 和节点连接成功,您还需要哪些节点包装器?他们需要什么?如果是 API 访问,既然你已经熟悉了 api,可以不访问吗?
  • 我已经更新了我的问题,因为评论部分无法处理这么多。
  • 有用的更新,谢谢。你可以拦截和检查请求吗?比较线路上的内容,因为它应该都是可读的(一旦 TLS 解包)。

标签: unity3d httpwebrequest unity-webgl canvas-lms unitywebrequest


【解决方案1】:

我发现我可以在邮递员上使用代码 sn-ps 以某种语言检索请求。有了这个,我不再需要 python API,因为我可以直接获取代码。我还是不知道Unity为什么不识别restSharp,但是python解决了我的问题。 由于我很难找到如何在 Canvas lms 上发布成绩和 cmets,因此我将把 PATH 留给遇到相同问题的任何人:

PUT /api/v1/courses/:course_id/assignments/:assignment_id/submissions/:user_id

查询参数为: 评论[text_comment] 和提交[posted_grade]。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-08
    • 1970-01-01
    • 2022-06-16
    • 1970-01-01
    • 1970-01-01
    • 2013-01-30
    • 2017-01-26
    相关资源
    最近更新 更多