Giter VIP home page Giter VIP logo

moodlepy's Introduction

moodlepy

PyPi Package Version Supported Python versions LICENSE Tests codecov pre-commit Mypy

Python wrapper for moodle web service.

Introduction

This library provide a pure Python interface for Moodle Web Service. It's compatible with Python versions 3.8+

Install moodlepy<=0.22.2 for python 3.6 support. Install moodlepy<=0.23.8 for python 3.7 support.

Installing

You can install or upgrade moodlepy with:

pip install moodlepy --upgrade

Or you can install from source with:

git clone https://github.com/hexatester/moodlepy
cd moodlepy
python setup.py install

Usage

Example usage

from moodle import Moodle
url = 'https://my.domain/webservice/rest/server.php'
token = 'super secret token'
moodle = Moodle(url, token)
dict_site_info = moodle('core_webservice_get_site_info')
site_info = moodle.core.webservice.get_site_info()  # return typed site_info

print(dict_site_info)
print(site_info)

# or
from moodle import Mdl
from moodle.core.webservice import BaseWebservice

moodle = Mdl(url, token)
webservice = BaseWebservice(moodle)
site_info2 = webservice.get_site_info()

assert site_info == site_info2

❗️ If the function area does not have a type in the support table, the return value is in accordance with the Moodle web service documentation, wich mostly dict.

In the future all of Web service functions will be covered by moodlepy.

Moodle Web Service support

Area Functions Types Tests Status
auth_email A A
block A A
core_auth A A
core_backup A A
core_badge A A A
core_blog A A A
core_calendar A A
core_cohort A A
core_comment A A
core_competency
core_completion A A
core_course
core_customfield A A
core_enrol
core_fetch
core_files
core_filters
core_form
core_get
core_grades A
core_grading
core_group
core_h5p
core_message A
core_notes A A
core_output
core_question
core_rating
core_role
core_search
core_session
core_tag
core_update
core_user
core_webservice A A A A
enrol_guest A A
enrol_manual A A
enrol_self A A
gradereport_overview
gradereport_user
gradingform_guide
gradingform_rubric
local_mobile
message_airnotifier
message_popup
mod_assign
mod_book
mod_chat A
mod_choice
mod_data A
mod_feedback
mod_folder A A
mod_forum
mod_glossary
mod_imscp
mod_label
mod_lesson
mod_lti
mod_page A A
mod_quiz
mod_resource A A
mod_scorm
mod_survey
mod_url A A
mod_wiki
mod_workshop A
report_competency
report_insights
tool_analytics
tool_lp
tool_mobile A A
tool_templatelibrary
tool_usertours
tool_xmldb

moodlepy's People

Contributors

gaetan1903 avatar hexatester avatar kernicpanel avatar sesostris avatar smehrbrodt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

moodlepy's Issues

[Question] Are all types manually written?

Hey I recently stumbled upon your project and was positively surprised how thoroughly everything was annotated.
I am currently in the process of writing basically the same and wanted to ask if these were all manually written or if you scanned the moodle code (or documentation page)?

[BUG 🐞]

Describe the bug
I want to understand this error

To Reproduce
Steps to reproduce the behavior:

from moodle import Moodle
url = 'https://my.domain/webservice/rest/server.php'
token = 'super secret token'
moodle = Moodle(url, token)
dict_site_info = moodle('mod_assign_view_assign', assignid=10')

Expected behavior

 File "/home/gaetan/.local/lib/python3.8/site-packages/moodle/moodle.py", line 20, in __call__
    return self.post(wsfunction, moodlewsrestformat, **kwargs)
  File "/home/gaetan/.local/lib/python3.8/site-packages/moodle/mdl.py", line 65, in post
    return self.process_response(data)
  File "/home/gaetan/.local/lib/python3.8/site-packages/moodle/mdl.py", line 74, in process_response
    raise MoodleException(**data)  # type: ignore
TypeError: __init__() got an unexpected keyword argument 'debuginfo'

The documentation info
image

mod_page_view_page

Please,
Can you incorporate mod_page_view_page?
I have tried:
arguments3 = {
"pageid": 11
}
contents = moodle ('mod_page_view_page', ** arguments3)

And it returned: "moodle.exception.MoodleException"

Thank you

[Doc Request ✨]

Hi, very good moodle python 🥇

I don't know how send parametre on a function with your module,

Can you show me ?

How to use get_users

Trying to get an existing user by id.

user_service = BaseUser(...)
user = user_service.get_users({id: submission['userid']})

This fails with:
moodle.exception.MoodleException: Ungültiger Parameterwert

How should the parameters be formatted for the get_users function?

Kudos for this nice project btw, very helpful in working with the cumbersome moodle api.

[BUG 🐞] add_cohort_members parameters result in invalid_parameter_exception

Hey,

I'm trying to add a member to a cohort using the AddCohortMember, CohortType and UserType classes but keep failing. What am I doing wrong?

member = AddCohortMember(CohortType(type = 'id', value = '299'),
                             UserType(type = 'id', value = '9'))
members = [member]
moodle.core.cohort.add_cohort_members(members)

"exception": "invalid_parameter_exception"

moodlepy v1 Roadmap!

Moodlepy version 1 means all functions and arguments must be implemented, but it is not mandatory for tests, documentation and types.

Area list:

  • core_course
  • core_enrol
  • mod_assign
  • mod_forum
  • mod_quiz
  • mod_lesson
  • mod_label
  • core_files
  • gradereport_user
  • core_competency
  • core_fetch
  • core_filters
  • core_form
  • core_get
  • core_grading
  • core_group
  • core_h5p
  • core_output
  • core_question
  • core_rating
  • core_role
  • core_search
  • core_session
  • core_tag
  • core_update
  • core_user
  • gradereport_overview
  • gradingform_guide
  • gradingform_rubric
  • local_mobile
  • message_airnotifier
  • message_popup
  • mod_book
  • mod_choice
  • mod_feedback
  • mod_glossary
  • mod_imscp
  • mod_lti
  • mod_scorm
  • mod_survey
  • mod_wiki
  • report_competency
  • report_insights
  • tool_analytics
  • tool_lp
  • tool_templatelibrary
  • tool_usertours
  • tool_xmldb
  • core_comment
  • core_grades

core.cohort.add_cohort_members

Hi! Can you please give me a example of what kind of dict/array structure i need to give for this function. I've been stuck for hours now since i can't figure out how many nested arrays the function wants. Other fuctions such as create user work fine but this is a pain in the ass.

Thanks in advance!

[Feature Request ✨] User enrolment

Dear Hexatester,

I'm very glad you're developing this library! I have a moodle website and I tested your lib and it worked well. I'm not a very experienced developer and I'd love to have the function of enrolling students thought the web service.
Could you provide me some help?

Thanks a lot!

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.