[IMP]:Survey:Ref.YSA

* Improved the code and changes in view,fix bug in report and response wizard.

bzr revid: apa@tinyerp.com-20100201133110-de1jvtbom7t06iks
This commit is contained in:
apa-tiny 2010-02-01 19:01:10 +05:30
parent 286479e7ef
commit 489aea8520
4 changed files with 43 additions and 34 deletions

View File

@ -257,6 +257,8 @@ class survey_analysis(report_rml):
sqc.question_id = sr.question_id and sra.answer_id = %d and sqc.title ='%s'\
group by sra.answer_id,sqc.rating_weight" % (ans.id,matrix_ans[mat_col]))
col_weight = cr.fetchone()
if not col_weight :
col_weight= (0,0)
res_count = col_weight[0]
if tot_res:
rating_weight_sum += col_weight[1] * tot_res

View File

@ -268,7 +268,7 @@ class survey_browse_response(report_rml):
</blockTable>"""
elif que.type in ['matrix_of_choices_only_one_ans','matrix_of_choices_only_multi_ans','rating_scale','matrix_of_drop_down_menus']:
if len(answer) and answer[0].state == "done":
if que.comment_column:
if que.type in ['matrix_of_choices_only_one_ans','rating_scale'] and que.comment_column:
pass
cols_widhts = []
cols_widhts.append(200)
@ -278,7 +278,7 @@ class survey_browse_response(report_rml):
tmp=0.0
sum = 0.0
i = 0
if que.comment_column:
if que.type in ['matrix_of_choices_only_one_ans','rating_scale'] and que.comment_column:
for col in cols_widhts:
if i==0:
cols_widhts[i] = cols_widhts[i]/2.0
@ -292,7 +292,7 @@ class survey_browse_response(report_rml):
if col.title not in matrix_ans:
matrix_ans.append(col.title)
len_matrix = len(matrix_ans)
if que.comment_column:
if que.type in ['matrix_of_choices_only_one_ans','rating_scale'] and que.comment_column:
matrix_ans.append(que.column_name)
rml+="""<blockTable colWidths=" """ + colWidths + """ " style="Table1"><tr>"""
for mat_col in matrix_ans:
@ -342,14 +342,14 @@ class survey_browse_response(report_rml):
<rect x="0.1cm" y="-0.45cm" width="0.5 cm" height="0.5cm" fill="yes" stroke="yes" round="0.1cm"/>
</illustration>"""
rml+= """<td>""" + value + """</td>"""
if que.comment_column:
if que.type in ['matrix_of_choices_only_one_ans','rating_scale'] and que.comment_column:
if comment_value=='False':
comment_value = ''
rml+= """<td><para style="response">"""+ to_xml(tools.ustr(comment_value)) + """</para></td>"""
rml+=""" </tr></blockTable>"""
if que.comment_field_type:
if que.is_comment_require:
rml+="""<blockTable colWidths="500" style="Table1"><tr>
<td><para style="answer">""" + to_xml(tools.ustr(answer[0].comment)) + """</para></td></tr></blockTable>"""
<td><para style="answer">""" + to_xml(tools.ustr(answer[0].comment or '')) + """</para></td></tr></blockTable>"""
else:
rml +="""<blockTable colWidths="500" style="Table1">
<tr> <td> <para style="response">No Response</para></td> </tr>

View File

@ -331,9 +331,9 @@ class survey_question(osv.osv):
raise osv.except_osv(_('Error !'),_("Maximum Required Answer is greater than Minimum Required Answer"))
if question['type'] == 'matrix_of_drop_down_menus' and vals.has_key('column_heading_ids'):
for col in vals['column_heading_ids']:
if col[2].has_key('menu_choice') and not col[2]['menu_choice']:
if col[2] and col[2].has_key('menu_choice') and not col[2]['menu_choice']:
raise osv.except_osv(_('Error !'),_("You must enter one or more menu choices in column heading"))
elif col[2].has_key('menu_choice') and col[2]['menu_choice'].strip() == '':
elif col[2] and col[2].has_key('menu_choice') and col[2]['menu_choice'].strip() == '':
raise osv.except_osv(_('Error !'),_("You must enter one or more menu choices in column heading (white spaces not allowed)"))
return super(survey_question, self).write(cr, uid, ids, vals, context=context)
@ -740,24 +740,28 @@ class survey_question_wiz(osv.osv_memory):
fields[tools.ustr(que) + "_commentcolumn_"+tools.ustr(row['id']) + "_field"] = {'type':'char', 'size' : 255, 'string':tools.ustr(que_rec['column_name']), 'views':{}}
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_commentcolumn_"+tools.ustr(row['id'])+ "_field"})
elif que_rec['type'] == 'matrix_of_choices_only_multi_ans':
xml_group = etree.SubElement(xml_group, 'group', {'col': '2', 'colspan': '2'})
xml_group = etree.SubElement(xml_group, 'group', {'col': str(len(que_rec['column_heading_ids']) + 1), 'colspan': '4'})
etree.SubElement(xml_group, 'separator', {'string': '.','colspan': '1'})
for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']):
etree.SubElement(xml_group, 'separator', {'string': tools.ustr(col['title']),'colspan': '1'})
for row in ans_ids:
etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(row['answer'])) +' :-', 'align': '0.0'})
etree.SubElement(xml_group, 'newline')
for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']):
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title'])})
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title']), 'nolabel':"1"})
fields[tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title'])] = {'type':'boolean', 'string': col['title']}
elif que_rec['type'] == 'matrix_of_drop_down_menus':
xml_group = etree.SubElement(xml_group, 'group', {'col': '2', 'colspan': '2'})
xml_group = etree.SubElement(xml_group, 'group', {'col': str(len(que_rec['column_heading_ids']) + 1), 'colspan': '4'})
etree.SubElement(xml_group, 'separator', {'string': '.','colspan': '1'})
for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']):
etree.SubElement(xml_group, 'separator', {'string': tools.ustr(col['title']),'colspan': '1'})
for row in ans_ids:
etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(row['answer']))+' :-', 'align': '0.0'})
etree.SubElement(xml_group, 'newline')
for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']):
selection = []
if col['menu_choice']:
for item in col['menu_choice'].split('\n'):
if item and not item.strip() == '': selection.append((item ,item))
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title'])})
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title']),'nolabel':'1'})
fields[tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title'])] = {'type':'selection', 'string': col['title'], 'selection':selection}
elif que_rec['type'] == 'multiple_textboxes':
xml_group = etree.SubElement(xml_group, 'group', {'col': '1', 'colspan': '4'})
@ -1238,7 +1242,7 @@ class survey_question_wiz(osv.osv_memory):
numeric_sum += int(val)
elif val and len(key.split('_')) == 3:
resp_obj.write(cr, uid, update, {'state': 'done'})
if type(val) == type(''):
if type(val) == type('') or type(val) == type(u''):
ans_create_id = res_ans_obj.create(cr, uid, {'response_id':update, 'answer_id':ans_id_len[1], 'answer' : ans_id_len[2], 'value_choice' : val})
sur_name_read['store_ans'][update].update({key:val})
else:

View File

@ -30,7 +30,7 @@
<button name="%(action_view_survey_name)d" states="open,draft,close,cancel"
string="Answer Survey" type="action" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'readonly':[('state','!=','open')]}"/>
<button name="%(action_view_survey_name)d" states="open,draft,close,cancel"
string="Edit Survey" type="action" icon="gtk-edit" context="{'active':True,'edit' : True,'survey_id': active_id}" attrs="{'readonly':[('state','!=','draft')]}"/>
string="Edit Survey" type="action" icon="gtk-edit" context="{'active':True,'edit' : True,'survey_id': active_id}"/>
</group>
<notebook colspan="4">
<page string="Survey">
@ -93,15 +93,16 @@
<field name="comment_valid_err_msg" nolabel="1" colspan="4"/>
</group>
</group>
<group attrs="{'invisible':[('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale')]}">
<field name="comment_column"/>
<group colspan="2" attrs="{'invisible':[('comment_column','!=',True)]}">
<field name="column_name" colspan="2"/>
</group>
</group>
</group>
</group>
<newline/>
<group attrs="{'invisible':[('type','!=','matrix_of_choices_only_one_ans'),('type','!=','rating_scale')]}">
<field name="comment_column"/>
<group colspan="2" attrs="{'invisible':[('comment_column','!=',True)]}">
<field name="column_name" colspan="2"/>
</group>
</group>
<newline/>
<group attrs="{'invisible':[('type','!=','single_textbox'), ('type','!=','multiple_textboxes')]}">
<separator string="Validation" colspan="4"/>
<group colspan="4">
@ -351,15 +352,16 @@
<field name="comment_valid_err_msg" nolabel="1" colspan="4"/>
</group>
</group>
<group attrs="{'invisible':[('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale')]}">
<field name="comment_column"/>
<group colspan="2" attrs="{'invisible':[('comment_column','!=',True)]}">
<field name="column_name" colspan="2"/>
</group>
</group>
</group>
</group>
<newline/>
<group attrs="{'invisible':[('type','!=','matrix_of_choices_only_one_ans'),('type','!=','rating_scale')]}">
<field name="comment_column"/>
<group colspan="2" attrs="{'invisible':[('comment_column','!=',True)]}">
<field name="column_name" colspan="2"/>
</group>
</group>
<newline/>
<group attrs="{'invisible':[('type','!=','single_textbox'), ('type','!=','multiple_textboxes')]}">
<separator string="Validation" colspan="4"/>
<group colspan="4">
@ -544,15 +546,16 @@
<field name="comment_valid_err_msg" nolabel="1" colspan="4"/>
</group>
</group>
<group attrs="{'invisible':[('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale')]}">
<field name="comment_column"/>
<group colspan="2" attrs="{'invisible':[('comment_column','!=',True)]}">
<field name="column_name" colspan="2"/>
</group>
</group>
</group>
</group>
<newline/>
<group attrs="{'invisible':[('type','!=','matrix_of_choices_only_one_ans'),('type','!=','rating_scale')]}">
<field name="comment_column"/>
<group colspan="2" attrs="{'invisible':[('comment_column','!=',True)]}">
<field name="column_name" colspan="2"/>
</group>
</group>
<newline/>
<group attrs="{'invisible':[('type','!=','single_textbox'), ('type','!=','multiple_textboxes')]}">
<separator string="Validation" colspan="4"/>
<group colspan="4">