Coder Social home page Coder Social logo

moodleteacher's Introduction

The moodleteacher library

This Python library is intended for teachers with courses in the Moodle learning management system. They can easily automate their grading or course management procedures, so that clicking around on the web page is no longer neccessary.

Getting Started

These instructions will get you the library up and running on your local machine.

Installation

The library demands Python 3. Install the software with

pip3 install moodleteacher

Start an interactive Python session and load the library:

(venv) shaw:moodleteacher ptroeger$ python
Python 3.6.5 (default, Apr 25 2018, 14:23:58) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import moodleteacher as mt

First, you need to provide the neccessary connection information. The host name is the web server where your Moodle installation lives. The token can be retrieved from your Moodle user settings (Preferences -> User account -> Security keys -> Service "Moodle mobile web service"):

>>> conn=mt.MoodleConnection(moodle_host="https://lms.beuth-hochschule.de", token="aaaaabbbbbcccccdddddeeeee12345")

You can now fetch the list of assignments that are accesssible for you:

>>> assignments=mt.MoodleAssignments(conn)
>>> for assign in assignments:
...     print(assign)
... 

You can filter for particular assignments or courses, based on the Moodle IDs for them:

>>> assignments=mt.MoodleAssignments(conn, course_filter=[4711], assignment_filter=[1234])
>>> for assign in assignments:
...     print(assign)
... 

Assignment objects provide a list of submissions. Each submission object provides the files (or text) submitted by the student:

>>> for assignment in assignments:
...     for submission in assignment.submissions():
...         print("User {0} submitted {1} files.".format(submission.userid, len(submission.files)))

Student file uploads can be downloaded with the MoodleSubmissionFile class and previewed with a small integrated GUI application. The preview supports:

  • HTML text
  • PDF files
  • Images
  • Any other content, just shown in text form
  • ZIP files of any of the above
>>> for assignment in assignments:
...     for submission in assignment.submissions():
...             for file_url in submission.files:
...                     print(file_url)
... 
https://lms.beuth-hochschule.de/webservice/pluginfile.php/725647/assignsubmission_file/submission_files/32245/task03_ft.pdf
https://lms.beuth-hochschule.de/webservice/pluginfile.php/725647/assignsubmission_file/submission_files/75356/Fehlerbaum.jpg
https://lms.beuth-hochschule.de/webservice/pluginfile.php/725647/assignsubmission_file/submission_files/23454/Faultchar%2B-fertig.png
>>> stud_upload=mt.MoodleSubmissionFile(conn=conn, url="https://lms.beuth-hochschule.de/webservice/pluginfile.php/725647/assignsubmission_file/submission_files/75356/Fehlerbaum.jpg")
>>> stud_upload.is_pdf
False
>>> stud_upload.is_image
True
>>> from moodleteacher import preview
>>> mt.preview.show_preview("Preview Window", [stud_upload])

Submissions can be trivially graded:

>>> for assignment in assignments:
...     for submission in assignment.submissions:
...         submission.save_grade(0.0, "Everybody fails in this assignment. You too.")

There is also support for:

  • Running submitted files locally as shell script, for testing purposes.
  • Running submitted files remotely on another machine, for testing purposes.

Take a look at the complex usage example in the grader.py script, which shows nearly all features of the library in action.

Real documentation is planned.

License

This project is licensed under the GPL3 License - see the LICENSE file for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.