From fd6e04ba7e8582df56bf4b7ce79779023e06001c Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Thu, 21 Jan 2010 18:41:07 +0530 Subject: [PATCH] [IMP]:survey:improved the survey analysis and browse report.(Ref:YSA). bzr revid: apa@tinyerp.com-20100121131107-zj38q1kjvzpvq6y0 --- .../survey/report/survey_analysis_report.py | 96 +++++++++++++------ .../survey/report/survey_browse_response.py | 54 +++++++++-- addons/survey/survey.py | 2 +- addons/survey/wizard/wizard_survey.py | 3 +- 4 files changed, 112 insertions(+), 43 deletions(-) diff --git a/addons/survey/report/survey_analysis_report.py b/addons/survey/report/survey_analysis_report.py index b246ebfcaae..4df20cbe319 100755 --- a/addons/survey/report/survey_analysis_report.py +++ b/addons/survey/report/survey_analysis_report.py @@ -58,6 +58,22 @@ class survey_analysis(report_rml): + + + + + + + + + + + + + + + + @@ -71,31 +87,49 @@ class survey_analysis(report_rml): + + + Response Summary - """ + + + + """ surv_obj = pooler.get_pool(cr.dbname).get('survey') for survey in surv_obj.browse(cr, uid, ids): if survey.question_prefix: prefix = survey.question_prefix + " : " else: prefix = '' - rml += """ - - Survey Title :- - """ + to_xml(survey.title) + """ - Total Started Survey :- - """ + tools.ustr(survey.tot_start_survey) + """ - - - - - Total Completed Survey :- - """ + tools.ustr(survey.tot_comp_survey) + """ - - """ + rml += """ + + + Survey Title + + + Total Started Survey + + + Total Completed Survey + + + + + + + """ + to_xml(survey.title) + """ + + + """ + str(survey.tot_start_survey) + """ + + + """ + str(survey.tot_comp_survey) + """ + + + """ for page in survey.page_ids: rml += """ # @@ -137,7 +171,7 @@ class survey_analysis(report_rml): if cal['answer'] == matrix_ans[mat_col]: cal_count = cal['count'] if tot_res: - percantage = float(cal_count)*100 / tot_res + percantage = float(cal_count)*100 / tot_res if percantage: rml += """""" + tools.ustr(percantage) +"% (" + tools.ustr(cal_count) + """)""" else: @@ -150,13 +184,13 @@ class survey_analysis(report_rml): tot_res = cr.fetchone()[0] rml+="""""" + to_xml(que.comment_label) + """ """ + tools.ustr(tot_res) + """""" - + elif que.type in['multiple_choice_only_one_ans', 'multiple_choice_multiple_ans', 'multiple_textboxes','date_and_time','date']: rml +="""""" - rml += """ - + rml += """ + Response Percentage - Response Count + Response Count """ for ans in que.answer_choice_ids: rml+="""""" + to_xml(ans.answer) + """ @@ -178,13 +212,13 @@ class survey_analysis(report_rml): tot_res = cr.fetchone()[0] rml+="""""" + to_xml(que.comment_label) + """ """ + tools.ustr(tot_res) + """""" - + elif que.type in['single_textbox']: cr.execute("select count(id) from survey_response_line where question_id = %d and single_text!=''" % que.id) rml +=""" - - - Response Count + + + Response Count """ + tools.ustr(cr.fetchone()[0]) + """ @@ -192,9 +226,9 @@ class survey_analysis(report_rml): elif que.type in['comment']: cr.execute("select count(id) from survey_response_line where question_id = %d and comment !=''" % que.id) rml +=""" - - - Response Count + + + Response Count """ + tools.ustr(cr.fetchone()[0]) + """ @@ -249,7 +283,7 @@ class survey_analysis(report_rml): rml += """ """ + to_xml(column.title) + """""" menu_choices = column.menu_choice.split('\n') - cols_widhts = [] + cols_widhts = [] cols_widhts.append(200) for col in range(0, len(menu_choices) + 1): cols_widhts.append(float(300 / (len(menu_choices) + 1))) @@ -289,12 +323,12 @@ class survey_analysis(report_rml): rml += """""" elif que.type in['numerical_textboxes']: rml +=""" - - + + Response Average Response Total - Response Count + Response Count """ for ans in que.answer_choice_ids: cr.execute("select answer from survey_response_answer where answer_id=%d group by answer" % ans.id) diff --git a/addons/survey/report/survey_browse_response.py b/addons/survey/report/survey_browse_response.py index f6f5600cbb6..17aab33e38e 100644 --- a/addons/survey/report/survey_browse_response.py +++ b/addons/survey/report/survey_browse_response.py @@ -83,6 +83,22 @@ class survey_browse_response(report_rml): + + + + + + + + + + + + + + + + @@ -102,11 +118,17 @@ class survey_browse_response(report_rml): + + Browse Responses - """ + + + + + """ surv_resp_obj = pooler.get_pool(cr.dbname).get('survey.response') surv_resp_line_obj = pooler.get_pool(cr.dbname).get('survey.response.line') surv_obj = pooler.get_pool(cr.dbname).get('survey') @@ -116,18 +138,30 @@ class survey_browse_response(report_rml): prefix = survey.question_prefix + " : " else: prefix = '' - rml += """ + rml += """ - Survey Title :- - """ + to_xml(survey.title) + """ + + Survey Title + + + Response Create Date + + + Respose By + + + - Response Create Date :- - """ + to_xml(response.date_create) + """ - - - User Name :- - """ + to_xml(response.user_id.name) + """ + + """ + to_xml(survey.title) + """ + + + """ + to_xml(response.date_create) + """ + + + """ + to_xml(response.user_id.name) + """ + """ for page in survey.page_ids: diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 53d57efd59b..0495144e507 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -648,7 +648,7 @@ class survey_question_wiz(osv.osv_memory): que_rec = que_obj.read(cr, uid, que) descriptive_text = "" separator_string = tools.ustr(qu_no) + "." + tools.ustr(que_rec['question']) - if que_rec['is_require_answer'] or que_rec['required_type'] != '': + if not context.has_key('active') and (que_rec['is_require_answer'] or que_rec['required_type'] != ''): star='*' else: star='' diff --git a/addons/survey/wizard/wizard_survey.py b/addons/survey/wizard/wizard_survey.py index 911abb3f9c5..b623c8ecd27 100755 --- a/addons/survey/wizard/wizard_survey.py +++ b/addons/survey/wizard/wizard_survey.py @@ -31,6 +31,7 @@ import tools import os import datetime import netsvc +import socket _survey_form = '''
@@ -91,7 +92,7 @@ def check_survey(self, cr, uid, data, context): raise wizard.except_wizard(_('Attention!'), _('%sSurvey is not in open state') % msg) data['form']['mail'] = '''Hello %(name)s, \n\n We are inviting you for following survey. \ \n ''' + name + '''\n Your login ID: %(login)s, Your password: %(passwd)s - \n link :- http://localhost:8080 \n\n Thanks,''' + \n link :- http://'''+ str(socket.gethostname()) + ''':8080 \n\n Thanks,''' return data['form'] def send_mail(self, cr, uid, data, context):