From 6dcf86fcad749d5f33f93c37d6bc1695b38d0a5f Mon Sep 17 00:00:00 2001 From: MVA Date: Thu, 26 Jan 2012 16:34:16 +0100 Subject: [PATCH] [ADD]new moodle integration with xmlrpc call bzr revid: mva@openerp.com-20120126153416-xrtyq29b86q5sxb2 --- addons/moodle_integration/__init__.py | 25 ++++++ addons/moodle_integration/__openerp__.py | 41 +++++++++ addons/moodle_integration/moodle.py | 100 ++++++++++++++++++++++ addons/moodle_integration/moodle_view.xml | 20 +++++ 4 files changed, 186 insertions(+) create mode 100644 addons/moodle_integration/__init__.py create mode 100644 addons/moodle_integration/__openerp__.py create mode 100644 addons/moodle_integration/moodle.py create mode 100644 addons/moodle_integration/moodle_view.xml diff --git a/addons/moodle_integration/__init__.py b/addons/moodle_integration/__init__.py new file mode 100644 index 00000000000..d9fdb7d9349 --- /dev/null +++ b/addons/moodle_integration/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import moodle + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/moodle_integration/__openerp__.py b/addons/moodle_integration/__openerp__.py new file mode 100644 index 00000000000..f50da1f1e6f --- /dev/null +++ b/addons/moodle_integration/__openerp__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +{ + 'name': 'moodle integration', + 'version': '0.1', + 'category': 'Tools', + 'complexity': "easy", + 'description': """ + +""", + 'author': 'OpenERP SA', + 'depends': ['event'], + 'init_xml': ['moodle_view.xml'], + 'demo_xml': [], + 'test': [], + 'installable': True, + 'active': False, + 'certificate': '', + 'images': ['images/1_event_type_list.jpeg','images/2_events.jpeg','images/3_registrations.jpeg'], +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/moodle_integration/moodle.py b/addons/moodle_integration/moodle.py new file mode 100644 index 00000000000..5eab7844f8e --- /dev/null +++ b/addons/moodle_integration/moodle.py @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields, osv +import xmlrpclib + + + + +class moodle(osv.osv): + """ Event Type """ + _name = 'moodle' + _inherit = 'event.event' + _columns = { + 'moodle_ok' : fields.boolean('moodle_ok'), + 'moodle_username' : fields.char('Moodle username', 128), + 'moodle_password' : fields.char('Moodle password', 128), + 'moodle_token' : fields.char('Moodle token', 128), + 'serveur_moodle': fields.char('Moodle token', 128), + } + + +def Get_url(): + """ + attr: + serveur_moodle + token + password + username + """ + hostname="127.0.0.1" + password="Administrateur1%2b" + username="admin" + + #if token + token='3ecfb383330044a884b1ee86e0872b47' + url='http://'+hostname+'/moodle/webservice/xmlrpc/server.php?wstoken='+token + #if user connect + url='http://'+hostname+'/moodle/webservice/xmlrpc/simpleserver.php?wsusername='+username+'&wspassword='+password + return url + +def create_moodle_user(): + #user is a list of dictionaries with every required datas for moodle + users=[{ + 'username' : 'efegt(gtrhf', + 'password' : 'Azertyui1+', + 'firstname' : 'res', + 'lastname': 'ezr', + 'email': 'gegtr@ggtr.com' + }] + + #connect to moodle + sock = xmlrpclib.ServerProxy(self.Get_url()) + + #add user un moodle + sock.core_user_create_users(users) + +def create_moodle_courses(): + courses=[{ + 'fullname' :'', + 'shortname' :'', + 'categoryid':'' + }] + #connect to moodle + sock = xmlrpclib.ServerProxy(self.Get_url()) + + #add course un moodle + sock.core_course_create_courses(courses) + +def moodleenrolled(): + enrolled=[{ + 'roleid' :'', + 'userid' :'', + 'courseid' :'' + }] + #connect to moodle + sock = xmlrpclib.ServerProxy(self.Get_url()) + + #add enrolled un moodle + sock.enrol_manual_enrol_users(enrolled) + +moodle() diff --git a/addons/moodle_integration/moodle_view.xml b/addons/moodle_integration/moodle_view.xml new file mode 100644 index 00000000000..ebf8a8e3fae --- /dev/null +++ b/addons/moodle_integration/moodle_view.xml @@ -0,0 +1,20 @@ + + + + + moodle + event.event + form + + + + + + + + + + + + +