def ajax(): reader = codecs.getreader("utf-8") query = json.load(reader(request.body)) if query['type'] == "question": if query['method']=='PE': return methods.PE(float(query['min_interval']),float(query['max_interval']),float(query['proba']), int(query['choice']), str(query['mode'])) elif query['method']=='LE': return methods.LE(float(query['min_interval']),float(query['max_interval']),float(query['proba']), int(query['choice']), str(query['mode'])) elif query['method']=='CE_Constant_Prob': return methods.CE(float(query['min_interval']),float(query['max_interval']),float(query['gain']), int(query['choice']), str(query['mode'])) else: return query['method'] elif query['type'] == "calc_util": return fit.regressions(query['points']) elif query['type'] == "k_calculus": print("on va calculer k_calculus sur le fichier kcalc") if query['number'] == 3: return {'k':kcalc.calculk(query['k']['k1'],query['k']['k2'],query['k']['k3'])} elif query['number'] == 4: return {'k':kcalc.calculk4(query['k']['k1'],query['k']['k2'],query['k']['k3'],query['k']['k4'])} elif query['number'] == 5: return {'k':kcalc.calculk4(query['k']['k1'],query['k']['k2'],query['k']['k3'],query['k']['k4'], query['k']['k5'])} elif query['type'] == "svg": dictionary = query['data'] min = query['min'] max = query['max'] liste_cord = query['liste_cord'] return plot.generate_svg_plot(dictionary, min, max, liste_cord) elif query['type'] == "export_xls": return export_xls.generate_fichier(query['data'])
def ajax(): if check_passwd(request.get_cookie("mdp"))==False: return template('authentification', get_url=app.get_url) reader = codecs.getreader("utf-8") query = json.load(reader(request.body)) if query['type'] == "question": if query['method']=='PE': return methods.PE(float(query['min_interval']),float(query['max_interval']),float(query['proba']), int(query['choice']), str(query['mode'])) elif query['method']=='LE': return methods.LE(float(query['min_interval']),float(query['max_interval']),float(query['proba']), int(query['choice']), str(query['mode'])) elif query['method']=='CE_Constant_Prob': return methods.CE(float(query['min_interval']),float(query['max_interval']),float(query['gain']), int(query['choice']), str(query['mode'])) else: return query['method'] elif query['type'] == "calc_util": return fit.regressions(query['points']) elif query['type'] == "k_calculus": print("on va calculer k_calculus sur le fichier kcalc") if query['number'] == 2: return kcalc.calculk2(query['k']['k1'],query['k']['k2']) elif query['number'] == 3: return kcalc.calculk3(query['k']['k1'],query['k']['k2'],query['k']['k3']) elif query['number'] == 4: return kcalc.calculk4(query['k']['k1'],query['k']['k2'],query['k']['k3'],query['k']['k4']) elif query['number'] == 5: return kcalc.calculk5(query['k']['k1'],query['k']['k2'],query['k']['k3'],query['k']['k4'], query['k']['k5']) elif query['number'] == 6: return kcalc.calculk6(query['k']['k1'],query['k']['k2'],query['k']['k3'],query['k']['k4'], query['k']['k5'], query['k']['k6']) elif query['type'] == "utility_calculus_multiplicative": return kcalc.calculUtilityMultiplicative(query['k'],query['utility']) elif query['type'] == "utility_calculus_multilinear": return kcalc.calculUtilityMultilinear(query['k'],query['utility']) elif query['type'] == "svg": dictionary = query['data'] min = query['min'] max = query['max'] liste_cord = query['liste_cord'] width=query['width'] return plot.generate_svg_plot(dictionary, min, max, liste_cord, width) elif query['type'] == "export_xlsx": return export_xlsx.generate_fichier(query['data']) elif query['type'] == "export_xlsx_option": return export_xlsx.generate_fichier_with_specification(query['data'])
def ajax(): if check_passwd(request.get_cookie("mdp")) == False: return template('authentification', get_url=app.get_url) reader = codecs.getreader("utf-8") query = json.load(reader(request.body)) if query['type'] == "question": if query['method'] == 'PE': return methods.PE(float(query['min_interval']), float(query['max_interval']), float(query['proba']), int(query['choice']), str(query['mode'])) elif query['method'] == 'LE': return methods.LE(float(query['min_interval']), float(query['max_interval']), float(query['proba']), int(query['choice']), str(query['mode'])) elif query['method'] == 'CE_Constant_Prob': return methods.CE(float(query['min_interval']), float(query['max_interval']), float(query['gain']), int(query['choice']), str(query['mode'])) else: return query['method'] elif query['type'] == "calc_util": return fit.regressions(query['points']) elif query['type'] == "calc_util_multi": return fit.multipoints(query['points']) elif query['type'] == "k_calculus": if query['number'] == 2: return kcalc.calculk2(query['k']['k1'], query['k']['k2']) elif query['number'] == 3: return kcalc.calculk3(query['k']['k1'], query['k']['k2'], query['k']['k3']) elif query['number'] == 4: return kcalc.calculk4(query['k']['k1'], query['k']['k2'], query['k']['k3'], query['k']['k4']) elif query['number'] == 5: return kcalc.calculk5(query['k']['k1'], query['k']['k2'], query['k']['k3'], query['k']['k4'], query['k']['k5']) elif query['number'] == 6: return kcalc.calculk6(query['k']['k1'], query['k']['k2'], query['k']['k3'], query['k']['k4'], query['k']['k5'], query['k']['k6']) elif query['type'] == "utility_calculus_multiplicative": return kcalc.calculUtilityMultiplicative(query['k'], query['utility']) elif query['type'] == "utility_calculus_multilinear": return kcalc.calculUtilityMultilinear(query['k'], query['utility']) elif query['type'] == "svg": dictionary = query['data'] min = float(query['min']) max = float(query['max']) liste_cord = query['liste_cord'] width = query['width'] return plot.generate_svg_plot(dictionary, min, max, liste_cord, width) elif query['type'] == "svgg": dictionary = query['data'] min = float(query['min']) max = float(query['max']) liste_cord = query['liste_cord'] width = query['width'] choice = query['choice'] return plot.generate_svg_plot2(dictionary, min, max, liste_cord, width, choice) elif query['type'] == "svg_QUALI": dictionary = query['data'] list_names = query['list_names'] width = query['width'] return plot.generate_svg_plot_QUALI(dictionary, list_names, width) elif query['type'] == "pie_chart": names = query['names'] probas = query['probas'] return plot.pie_chart(names, probas) elif query['type'] == "export_xlsx": return export_xlsx.generate_fichier(query['data']) elif query['type'] == "export_xlsx_option": return export_xlsx.generate_fichier_with_specification(query['data']) elif query['type'] == "latex_render": return latex_render.render(query['formula']) elif query['type'] == "tree": return draw_tree.draw(query['gain'], query['upper_label'], query['bottom_label'], query['upper_proba'], query['bottom_proba'], query['assess_type'])
def ajax(): if check_passwd(request.get_cookie("mdp")) == False: return template('authentification', get_url=app.get_url) reader = codecs.getreader("utf-8") query = json.load(reader(request.body)) """ query = {'type': 'export_xlsx', 'data': {'attributes': [{'type': 'Quantitative', 'name': 'pieniche', 'unit': 'euros', 'val_min': 20, 'val_med': ['40', '60', '80'], 'val_max': 100, 'method': 'PE', 'mode': 'Normal', 'completed': 'False', 'checked': True, 'questionnaire': {'number': 3, 'points': {'40': 0.43, '60': 0.86, '80': 0.82}, 'utility': {}}, 'fonction': 'exponential', 'numero': 0, 'pts': {'points': [1, 2, 3], 'coord': [[40, 0.43], [60, 0.86], [80, 0.82], [20, 0], [100, 1]], 'exp': {'a': -1.963679476149352, 'b': 0.028213793872664365, 'c': 1.116885624561104, 'r2': 0.9669098127318985}, 'quad': {'a': -0.5720588230939125, 'b': 0.00016102941154695627, 'c': 0.03182352938563475, 'r2': 0.9609977126945451}, 'pow': {'a': 2.2107646754127557, 'b': 1.3371874567609472, 'c': -4.168783582605269, 'r2': 0.9633217332780892}, 'lin': {'a': 0.0125, 'b': -0.25, 'r2': 0.7480678661997344}, 'expo-power': {'a': -1825.2176950884375, 'b': -7.508435131653395, 'c': 4.5317707067475485e-05, 'r2': 0.9498855834689701}}}, {'type': 'Quantitative', 'name': 'ccxw', 'unit': 'cxw', 'val_min': 10, 'val_med': ['32.5', '55', '77.5'], 'val_max': 100, 'method': 'PE', 'mode': 'Normal', 'completed': 'False', 'checked': True, 'questionnaire': {'number': 3, 'points': {'55': 0.76, '32.5': 0.32, '77.5': 0.96}, 'utility': {}}, 'fonction': '', 'numero': 0}], 'k_calculus': [{'method': 'multiplicative', 'active': True, 'k': [], 'GK': None, 'GU': None}, {'method': 'multilinear', 'active': False, 'k': [], 'GK': None, 'GU': None}], 'settings': {'decimals_equations': '2', 'decimals_dpl': '8', 'proba_ce': '0.3', 'proba_le': '0.3', 'language': 'french', 'display': 'trees'} } } """ if query['type'] == "question": if query['method'] == 'PE': return methods.PE(float(query['min_interval']), float(query['max_interval']), float(query['proba']), int(query['choice']), str(query['mode'])) elif query['method'] == 'LE': return methods.LE(float(query['min_interval']), float(query['max_interval']), float(query['proba']), int(query['choice']), str(query['mode'])) elif query['method'] == 'CE_Constant_Prob': return methods.CE(float(query['min_interval']), float(query['max_interval']), float(query['gain']), int(query['choice']), str(query['mode'])) else: return query['method'] elif query['type'] == "calc_util": return fit.regressions(query['points']) elif query['type'] == "calc_util_multi": return fit.multipoints(query['points']) elif query['type'] == "k_calculus": if query['number'] == 2: return kcalc.calculk2(query['k']['k1'], query['k']['k2']) elif query['number'] == 3: return kcalc.calculk3(query['k']['k1'], query['k']['k2'], query['k']['k3']) elif query['number'] == 4: return kcalc.calculk4(query['k']['k1'], query['k']['k2'], query['k']['k3'], query['k']['k4']) elif query['number'] == 5: return kcalc.calculk5(query['k']['k1'], query['k']['k2'], query['k']['k3'], query['k']['k4'], query['k']['k5']) elif query['number'] == 6: return kcalc.calculk6(query['k']['k1'], query['k']['k2'], query['k']['k3'], query['k']['k4'], query['k']['k5'], query['k']['k6']) elif query['type'] == "utility_calculus_multiplicative": return kcalc.calculUtilityMultiplicative(query['k'], query['utility'], query['virgule']) elif query['type'] == "utility_calculus_multilinear": return kcalc.calculUtilityMultilinear(query['k'], query['utility'], query['virgule']) elif query['type'] == "svg": dictionary = query['data'] min_ = float(query['min']) max_ = float(query['max']) liste_cord = query['liste_cord'] width = query['width'] liste = query['liste'] return plot.generate_svg_plot(dictionary, min_, max_, liste_cord, width, liste) elif query['type'] == "svgg": dictionary = query['data'] min = float(query['min']) max = float(query['max']) liste_cord = query['liste_cord'] width = query['width'] choice = query['choice'] return plot.generate_svg_plot2(dictionary, min, max, liste_cord, width, choice) elif query['type'] == "svg_QUALI": dictionary = query['data'] list_names = query['list_names'] width = query['width'] return plot.generate_svg_plot_QUALI(dictionary, list_names, width) elif query['type'] == "pie_chart": names = query['names'] probas = query['probas'] return plot.pie_chart(names, probas) elif query['type'] == "demande_de_transformation": return selecteur.selecteur1(query['data'], query['numero']) elif query['type'] == "export_xlsx": return export_xlsx.generate_fichier(query['data']) elif query['type'] == "export_xlsx_option": return export_xlsx.generate_fichier_with_specification(query['data']) elif query['type'] == "latex_render": return latex_render.render(query['formula']) elif query['type'] == "tree": return draw_tree.draw(query['gain'], query['upper_label'], query['bottom_label'], query['upper_proba'], query['bottom_proba'], query['assess_type'])