[ADD]new moodle integration with xmlrpc call

bzr revid: mva@openerp.com-20120126153416-xrtyq29b86q5sxb2
This commit is contained in:
MVA 2012-01-26 16:34:16 +01:00
parent d700a107eb
commit 6dcf86fcad
4 changed files with 186 additions and 0 deletions

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import moodle
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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:

View File

@ -0,0 +1,100 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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()

View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="moodle_configuration">
<field name="name">moodle</field>
<field name="model">event.event</field>
<field name="type">form</field>
<field name="inherit_id" ref="event.view_event_form" />
<field name="arch" type="xml">
<xpath expr="/form/notebook/page[@string='Extra Info']" position="after">
<page string="Moodle">
<field name="name"/>
<field name="event_id"/>
</page>
</xpath>
</field>
</record>
</data>
</openerp>