therealsujitk / android-vtop-chennai

An android application for the students of VIT Chennai.
http://vtopchennai.therealsuji.tk
GNU General Public License v3.0
153 stars 32 forks source link

Add Moodle integration for the v4.0 release #4

Closed therealsujitk closed 2 years ago

therealsujitk commented 2 years ago

The AssignmentsFragment.java class needs to display the assignments from https://lms.vit.ac.in (A Moodle platform).

Web Services API: https://docs.moodle.org/dev/Web_service_API_functions

therealsujitk commented 2 years ago

Getting a login token

[GET] /login/token.php

Parameters

Response

{
    "token": "9859148a89546f0efe716a58e340849b",
    "privatetoken": "8RpHJevJ42W7QN23OMkeYcdOYw3YfWgWGKsak7WB3Z88wcApSCVZ9TgY6M5fEO1m"
}
therealsujitk commented 2 years ago

Getting a list of enrolled courses

[GET] /webservice/rest/server.php

Parameters

Response

{
    "courses": [
        {
            "id": 1137,
            "fullname": "Database Management Systems(CSE2004)",
            "shortname": "CSE2004_WI20F",
            "idnumber": "CSE2004_WI20F",
            "summary": "Database Management Systems",
            "summaryformat": 1,
            "startdate": 1614858420,
            "enddate": 1642081620,
            "visible": true,
            "fullnamedisplay": "Database Management Systems(CSE2004)",
            "viewurl": "https://lms.vit.ac.in/course/view.php?id=1137",
            "courseimage": "data:image/svg+xml;base64,...",
            "progress": 3,
            "hasprogress": true,
            "isfavourite": false,
            "hidden": false,
            "showshortname": false,
            "coursecategory": "SCOPE"
        }
    ],
    "nextoffset": 27
}
therealsujitk commented 2 years ago

Getting a list of assignments

[GET] /webservice/rest/server.php

Parameters

Response

{
    "courses": [
        {
            "id": 1137,
            "fullname": "Database Management Systems(CSE2004)",
            "shortname": "CSE2004_WI20F",
            "timemodified": 1614772066,
            "assignments": [
                {
                    "id": 10922,
                    "cmid": 23258,
                    "course": 1137,
                    "name": "Digital Assignment1",
                    "nosubmissions": 0,
                    "submissiondrafts": 1,
                    "sendnotifications": 0,
                    "sendlatenotifications": 0,
                    "sendstudentnotifications": 1,
                    "duedate": 1618939800,
                    "allowsubmissionsfromdate": 1616524200,
                    "grade": 100,
                    "timemodified": 1618632150,
                    "completionsubmit": 1,
                    "cutoffdate": 0,
                    "gradingduedate": 0,
                    "teamsubmission": 0,
                    "requireallteammemberssubmit": 0,
                    "teamsubmissiongroupingid": 0,
                    "blindmarking": 0,
                    "hidegrader": 0,
                    "revealidentities": 0,
                    "attemptreopenmethod": "none",
                    "maxattempts": -1,
                    "markingworkflow": 0,
                    "markingallocation": 0,
                    "requiresubmissionstatement": 1,
                    "preventsubmissionnotingroup": 0,
                    "submissionstatement": "This submission is my own work, except where I have acknowledged the use of the works of other people.",
                    "submissionstatementformat": 1,
                    "configs": [
                        {
                            "plugin": "file",
                            "subtype": "assignsubmission",
                            "name": "enabled",
                            "value": "1"
                        },
                        {
                            "plugin": "file",
                            "subtype": "assignsubmission",
                            "name": "maxfilesubmissions",
                            "value": "20"
                        },
                        {
                            "plugin": "file",
                            "subtype": "assignsubmission",
                            "name": "maxsubmissionsizebytes",
                            "value": "41943040"
                        },
                        {
                            "plugin": "file",
                            "subtype": "assignsubmission",
                            "name": "filetypeslist",
                            "value": ""
                        },
                        {
                            "plugin": "comments",
                            "subtype": "assignsubmission",
                            "name": "enabled",
                            "value": "1"
                        },
                        {
                            "plugin": "comments",
                            "subtype": "assignfeedback",
                            "name": "enabled",
                            "value": "1"
                        },
                        {
                            "plugin": "comments",
                            "subtype": "assignfeedback",
                            "name": "commentinline",
                            "value": "0"
                        },
                        {
                            "plugin": "editpdf",
                            "subtype": "assignfeedback",
                            "name": "enabled",
                            "value": "1"
                        }
                    ],
                    "intro": "",
                    "introformat": 1,
                    "introfiles": [],
                    "introattachments": [
                        {
                            "filename": "Assignment 1 - ER DIAGRAM EXERCISES _ Dr.Sivabala Krishnan.doc",
                            "filepath": "/",
                            "filesize": 102400,
                            "fileurl": "https://lms.vit.ac.in/webservice/pluginfile.php/133798/mod_assign/introattachment/0/Assignment%201%20-%20ER%20DIAGRAM%20EXERCISES%20_%20Dr.Sivabala%20Krishnan.doc",
                            "timemodified": 1616566904,
                            "mimetype": "application/msword",
                            "isexternalfile": false
                        }
                    ]
                }
            ]
        },
        {
            "id": 1419,
            "fullname": "Software Engineering(CSE3001)",
            "shortname": "CSE3001_F21",
            "timemodified": 1630210709,
            "assignments": [
                {
                    "id": 16888,
                    "cmid": 33887,
                    "course": 1419,
                    "name": "EX1_SRS_L27_28_PMS",
                    "nosubmissions": 0,
                    "submissiondrafts": 1,
                    "sendnotifications": 0,
                    "sendlatenotifications": 0,
                    "sendstudentnotifications": 1,
                    "duedate": 1630593000,
                    "allowsubmissionsfromdate": 1630135800,
                    "grade": 100,
                    "timemodified": 1630139363,
                    "completionsubmit": 1,
                    "cutoffdate": 0,
                    "gradingduedate": 0,
                    "teamsubmission": 0,
                    "requireallteammemberssubmit": 0,
                    "teamsubmissiongroupingid": 0,
                    "blindmarking": 0,
                    "hidegrader": 0,
                    "revealidentities": 0,
                    "attemptreopenmethod": "none",
                    "maxattempts": -1,
                    "markingworkflow": 0,
                    "markingallocation": 0,
                    "requiresubmissionstatement": 1,
                    "preventsubmissionnotingroup": 0,
                    "submissionstatement": "This submission is my own work, except where I have acknowledged the use of the works of other people.",
                    "submissionstatementformat": 1,
                    "configs": [
                        {
                            "plugin": "file",
                            "subtype": "assignsubmission",
                            "name": "enabled",
                            "value": "1"
                        },
                        {
                            "plugin": "file",
                            "subtype": "assignsubmission",
                            "name": "maxfilesubmissions",
                            "value": "2"
                        },
                        {
                            "plugin": "file",
                            "subtype": "assignsubmission",
                            "name": "maxsubmissionsizebytes",
                            "value": "41943040"
                        },
                        {
                            "plugin": "file",
                            "subtype": "assignsubmission",
                            "name": "filetypeslist",
                            "value": ""
                        },
                        {
                            "plugin": "comments",
                            "subtype": "assignsubmission",
                            "name": "enabled",
                            "value": "1"
                        },
                        {
                            "plugin": "comments",
                            "subtype": "assignfeedback",
                            "name": "enabled",
                            "value": "1"
                        },
                        {
                            "plugin": "comments",
                            "subtype": "assignfeedback",
                            "name": "commentinline",
                            "value": "0"
                        },
                        {
                            "plugin": "editpdf",
                            "subtype": "assignfeedback",
                            "name": "enabled",
                            "value": "1"
                        }
                    ],
                    "intro": "<p dir=\"ltr\"><span style=\"font-size: 0.9375rem;\">Write Software Requirements Specification document (SRS) for Passport Management System (PMS).&nbsp;</span><br></p><p dir=\"ltr\">(Note:&nbsp; you’re free to make further assumptions in the scenario if required.)</p>",
                    "introformat": 1,
                    "introfiles": [],
                    "introattachments": [
                        {
                            "filename": "SRS_template-IEEE.doc",
                            "filepath": "/",
                            "filesize": 59904,
                            "fileurl": "https://lms.vit.ac.in/webservice/pluginfile.php/147605/mod_assign/introattachment/0/SRS_template-IEEE.doc",
                            "timemodified": 1630139307,
                            "mimetype": "application/msword",
                            "isexternalfile": false
                        }
                    ]
                }
            ]
        }
    ],
    "warnings": [
        {
            "item": "module",
            "itemid": 21754,
            "warningcode": "1",
            "message": "No access rights in module context"
        }
    ]
}
therealsujitk commented 2 years ago

Get the site and user info

[GET] /webservice/rest/server.php

Parameters

Response

{
    "sitename": "Moodle Site",
    "username": "username",
    "firstname": "John",
    "lastname": "Doe",
    "fullname": "John Doe",
    "lang": "en",
    "userid": 12345,
    "siteurl": "https://example.moodle.com",
    "userpictureurl": "https://secure.gravatar.com/avatar/36441ac19a2ea2cad8382cc8029f64b3?s=100&d=mm",
    "functions": [
        {
            "name": "core_badges_get_user_badges",
            "version": "2020061500.01"
        },
        {
            "name": "core_blog_get_entries",
            "version": "2020061500.01"
        }
    ],
    "downloadfiles": 1,
    "uploadfiles": 1,
    "release": "3.9+ (Build: 20200618)",
    "version": "2020061500.01",
    "mobilecssurl": "",
    "advancedfeatures": [
        {
            "name": "usecomments",
            "value": 1
        },
        {
            "name": "usetags",
            "value": 1
        },
        {
            "name": "enablenotes",
            "value": 1
        },
        {
            "name": "messaging",
            "value": 1
        },
        {
            "name": "enableblogs",
            "value": 1
        },
        {
            "name": "enablecompletion",
            "value": 1
        },
        {
            "name": "enablebadges",
            "value": 1
        },
        {
            "name": "messagingallusers",
            "value": 0
        },
        {
            "name": "mnet_dispatcher_mode",
            "value": 0
        }
    ],
    "usercanmanageownfiles": true,
    "userquota": 100,
    "usermaxuploadfilesize": 41943040,
    "userhomepage": 1,
    "userprivateaccesskey": "aecb4601196985077a20ec221a042b69",
    "siteid": 1,
    "sitecalendartype": "gregorian",
    "usercalendartype": "gregorian",
    "userissiteadmin": false,
    "theme": "boost"
}
therealsujitk commented 2 years ago

Get the completion statuses of activities

[GET] /webservice/rest/server.php

Parameters

Response

{
    "statuses": [
        {
            "cmid": 32682,
            "modname": "resource",
            "instance": 7665,
            "state": 0,
            "timecompleted": 0,
            "tracking": 1,
            "overrideby": null,
            "valueused": false
        },
        {
            "cmid": 36709,
            "modname": "assign",
            "instance": 8519,
            "state": 1,
            "timecompleted": 1637841666,
            "tracking": 1,
            "overrideby": null,
            "valueused": false
        }
    ],
    "warnings": []
}
therealsujitk commented 2 years ago

Get the submission status of an assignment

[GET] /webservice/rest/server.php

Parameters

Response

{
    "lastattempt": {
        "submission": {
            "id": 128,
            "userid": 56,
            "attemptnumber": 0,
            "timecreated": 1643884542,
            "timemodified": 1643884542,
            "status": "new",
            "groupid": 0,
            "assignment": 119,
            "latest": 1,
            "plugins": [
                {
                    "type": "onlinetext",
                    "name": "Online text",
                    "fileareas": [
                        {
                            "area": "submissions_onlinetext",
                            "files": []
                        }
                    ],
                    "editorfields": [
                        {
                            "name": "onlinetext",
                            "description": "Online text submissions",
                            "text": "",
                            "format": 1
                        }
                    ]
                },
                {
                    "type": "file",
                    "name": "File submissions",
                    "fileareas": [
                        {
                            "area": "submission_files",
                            "files": []
                        }
                    ]
                },
                {
                    "type": "comments",
                    "name": "Submission comments"
                }
            ]
        },
        "submissiongroupmemberswhoneedtosubmit": [],
        "submissionsenabled": true,
        "locked": false,
        "graded": false,
        "canedit": true,
        "caneditowner": true,
        "cansubmit": false,
        "extensionduedate": null,
        "blindmarking": false,
        "gradingstatus": "notgraded",
        "usergroups": [
            44
        ]
    },
    "warnings": []
}
therealsujitk commented 2 years ago

Upload files to the draft area

[POST] /webservice/upload.php

Parameters

Body

Response

[
    {
        "component": "user",
        "contextid": 411,
        "userid": "56",
        "filearea": "draft",
        "filename": "file1.txt",
        "filepath": "/",
        "itemid": 419959062,
        "license": "allrightsreserved",
        "author": "Barbara Gardner",
        "source": "O:8:\"stdClass\":1:{s:6:\"source\";s:10:\"file1.txt\";}"
    },
    {
        "component": "user",
        "contextid": 411,
        "userid": "56",
        "filearea": "draft",
        "filename": "file2.txt",
        "filepath": "/",
        "itemid": 419959062,
        "license": "allrightsreserved",
        "author": "Barbara Gardner",
        "source": "O:8:\"stdClass\":1:{s:6:\"source\";s:8:\"file2.txt\";}"
    }
]
therealsujitk commented 2 years ago

Add uploaded files to an assignment

[POST] /webservice/rest/server.php

⚠️ Warning: This function removes previous uploads to an assignment. The only current work around is to download the previous attempt, and upload them to the draft area before uploading the new files.

Parameters

Response

[]
therealsujitk commented 2 years ago

Submit an assignment for grading

[POST] /webservice/rest/server.php

Parameters

Response

[]