~openerp-commiter/openobject-addons/stable-sja-branch

« back to all changes in this revision

Viewing changes to training_exam/training_exam.py

  • Committer: sja-axelor
  • Date: 2009-10-13 09:52:57 UTC
  • Revision ID: suniljagyasi@gmail.com-20091013095257-8u26ww0r20z9y6ey
add

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution   
 
5
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
 
6
#    $Id$
 
7
#
 
8
#    This program is free software: you can redistribute it and/or modify
 
9
#    it under the terms of the GNU General Public License as published by
 
10
#    the Free Software Foundation, either version 3 of the License, or
 
11
#    (at your option) any later version.
 
12
#
 
13
#    This program is distributed in the hope that it will be useful,
 
14
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
#    GNU General Public License for more details.
 
17
#
 
18
#    You should have received a copy of the GNU General Public License
 
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
##############################################################################
 
22
 
 
23
from osv import osv, fields
 
24
 
 
25
class training_questionnaire(osv.osv):
 
26
    _name = 'training.questionnaire'
 
27
training_questionnaire()
 
28
 
 
29
class training_course(osv.osv):
 
30
    _inherit = 'training.course'
 
31
 
 
32
    _columns = {
 
33
        'questionnaire_ids' : fields.one2many('training.questionnaire',
 
34
                                              'course_id',
 
35
                                              'Questionnaire'),
 
36
    }
 
37
 
 
38
training_course()
 
39
 
 
40
class training_offer(osv.osv):
 
41
    _inherit = 'training.offer'
 
42
    _columns = {
 
43
        'questionnaire_ids' : fields.many2many('training.questionnaire',
 
44
                                               'training_questionnaire_offer_rel',
 
45
                                               'offer_id',
 
46
                                               'questionnaire_id',
 
47
                                               'Questionnaires'),
 
48
    }
 
49
 
 
50
training_offer()
 
51
 
 
52
class training_question(osv.osv):
 
53
    _name= 'training.question'
 
54
training_question()
 
55
 
 
56
class training_exam_answer(osv.osv):
 
57
    _name = 'training.exam_answer'
 
58
    _description = 'Answer'
 
59
    _columns = {
 
60
        'name' : fields.char('Response', size=128, required=True, select=1),
 
61
        'is_response' : fields.boolean('Correct Answer'),
 
62
        'question_id' : fields.many2one('training.question', 'Question', select=True, required=True),
 
63
    }
 
64
training_exam_answer()
 
65
 
 
66
class training_question(osv.osv):
 
67
    _name = 'training.question'
 
68
    _description = 'Question'
 
69
    _columns = {
 
70
        'name' : fields.text('Question', required=True, select=1),
 
71
        'kind' : fields.selection([('mandatory', 'Mandatory'),
 
72
                                   ('eliminatory', 'Eliminatory'),
 
73
                                   ('normal', 'Normal')
 
74
                                  ],
 
75
                                  'Kind', required=True, select=1),
 
76
        'type' : fields.selection([('plain', 'Plain'),
 
77
                                   ('qcm', 'QCM'),
 
78
                                   ('yesno', 'Yes/No')
 
79
                                  ],
 
80
                                  'Type',
 
81
                                  required=True,
 
82
                                  select=1 ),
 
83
        'response_plain' : fields.text('Response Plain'),
 
84
        'response_yesno' : fields.boolean('Response Yes/No'),
 
85
        'exam_answer_ids' : fields.one2many('training.exam_answer',
 
86
                                              'question_id',
 
87
                                              'Response QCM'),
 
88
        'questionnaire_ids': fields.many2many('training.questionnaire',
 
89
                                              'training_questionnaire_question_rel',
 
90
                                              'question_id',
 
91
                                              'questionnaire_id',
 
92
                                              'Questionnaire'),
 
93
    }
 
94
 
 
95
    _defaults = {
 
96
        'kind' : lambda *a: 'normal',
 
97
        'type' : lambda *a: 'plain',
 
98
        'response_yesno' : lambda *a: False,
 
99
    }
 
100
 
 
101
training_question()
 
102
 
 
103
class training_questionnaire(osv.osv):
 
104
    _name = 'training.questionnaire'
 
105
    _description = 'Questionnaire'
 
106
 
 
107
    _columns = {
 
108
        'name' : fields.char( 'Name', size=32, required=True, select=1 ),
 
109
        'course_id' : fields.many2one('training.course', 'Course'),
 
110
        'state' : fields.selection([('draft', 'Draft'),
 
111
                                    ('validated', 'Validated'),
 
112
                                    ('pending', 'Pending'),
 
113
                                    ('inprogress', 'In Progress'),
 
114
                                    ('deprecated', 'Deprecated')
 
115
                                   ],
 
116
                                   'State', required=True, readonly=True, select=1),
 
117
        'objective' : fields.text('Objective'),
 
118
        'description' : fields.text('Description'),
 
119
        'question_ids' : fields.many2many('training.question',
 
120
                                          'training_questionnaire_question_rel',
 
121
                                          'questionnaire_id',
 
122
                                          'question_id', 'Questions'),
 
123
    }
 
124
 
 
125
    _defaults = {
 
126
        'state' : lambda *a: 'draft',
 
127
    }
 
128
 
 
129
training_questionnaire()
 
130
 
 
131
class training_planned_exam(osv.osv):
 
132
    _name = 'training.planned_exam'
 
133
    _description = 'Planned Exam'
 
134
    _columns = {
 
135
        'name' : fields.char('Name', size=64, select=1, required=True),
 
136
        'date' : fields.datetime('Date', required=False, select=1),
 
137
        'duration' : fields.float('Duration', required=False, select=1),
 
138
        # 'location_id' : fields.many2one('training.location', 
 
139
        'state' : fields.selection([('draft', 'Draft'),
 
140
                                    ('opened', 'Opened'),
 
141
                                    ('opened_confirmed', 'Opened Confirmed'),
 
142
                                    ('closed_confirmed', 'Closed Confirmed'),
 
143
                                    ('inprogress', 'In Progress'),
 
144
                                    ('closed', 'Closed'),
 
145
                                    ('cancelled', 'Cancelled')],
 
146
                                   'State',
 
147
                                   required=True,
 
148
                                   readonly=True,
 
149
                                   select=1
 
150
                                  ),
 
151
        'participant_ids' : fields.many2many('training.subscription',
 
152
                                             'training_participation',
 
153
                                             'seance_id',
 
154
                                             'subscription_id',
 
155
                                             'Participants',
 
156
                                             domain="[('group_id', '=', group_id)]" ),
 
157
        'group_id' : fields.many2one('training.group', 'Group'),
 
158
        'contact_ids' : fields.many2many('res.partner.contact', 'planned_exam_contact_rel',
 
159
                                         'planned_exam_id', 'contact_id',
 
160
                                         'StakeHolder'),
 
161
        'questionnaire_id' : fields.many2one('training.questionnaire',
 
162
                                             'Questionnaire',
 
163
                                             required=True),
 
164
        'subscription_line_id' : fields.many2one('training.subscription.line', 'Subscription'),
 
165
    }
 
166
 
 
167
    _defaults = {
 
168
        'state' : lambda *a: 'draft',
 
169
    }
 
170
 
 
171
training_planned_exam()
 
172
 
 
173
class training_subscription_line(osv.osv):
 
174
    _inherit = 'training.subscription.line'
 
175
    _columns = {
 
176
        'with_exam' : fields.boolean('With Exam'),
 
177
        'exam_id' : fields.one2many('training.planned_exam', 'Planned Exam'),
 
178
    }
 
179
    _defaults = {
 
180
        'with_exam' : lambda *a: 0,
 
181
    }
 
182
 
 
183
training_subscription_line()
 
184
 
 
185
class training_exam_result(osv.osv):
 
186
    _name = 'training.exam.result'
 
187
    _description = 'exam Result'
 
188
    _columns = {
 
189
        'participation_id' : fields.many2one('training.participation', 'Participation',
 
190
                                             required=True),
 
191
        'exam_id' : fields.many2one('training.planned_exam', 'Exam',
 
192
                                    required=True),
 
193
    }
 
194
 
 
195
training_exam_result()
 
196
 
 
197
#class training_exam_result_line(osv.osv):
 
198
#    _name = 'training.exam.result.line'
 
199
#    _columns = {
 
200
#        'question_id' : fields.many2one('training.question', 'Question', required=True),
 
201
#    }
 
202
#
 
203
#training_exam_result_line()
 
204
 
 
205
 
 
206
 
 
207
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: