예제 #1
0
def python_code(request):   
	global datas
	global fig5
	global finalX
	global ABCX
	# form = FeedbackForm()
	fig1,fig2,fig3,fig4,fig5,Xfinal,ABCX=graphs.python(datas)
	Xfinal=[('Grd',float("{0:.3f}".format(Xfinal[0]))),('Vrb',float("{0:.3f}".format(Xfinal[1]))),('Att',float("{0:.3f}".format(Xfinal[2]))),('Std',float("{0:.3f}".format(Xfinal[3])))]
	Xfinal=sorted(Xfinal,key=lambda x:(-x[1],x[0]))
	finalX=[]
	for i in range (0,len(Xfinal)):
		finalX.append([Xfinal[i][0],"{0:.3f}".format(Xfinal[i][1])])#so every number has 3 dp
	ABCX="{0:.3f}".format(ABCX)
	template=loader.get_template('ABCquestionnaire/final.html')
	tmp1=six.StringIO()
	fig1.savefig(tmp1, format='svg', bbox_inches='tight')    
	# c1={'svg1':tmp1.getvalue()}
	tmp2=six.StringIO()
	fig2.savefig(tmp2, format='svg', bbox_inches='tight')
	# c2={'svg2':tmp2.getvalue()}
	tmp3=six.StringIO()
	fig3.savefig(tmp3, format='svg', bbox_inches='tight')
	# c3={'svg3':tmp3.getvalue()}
	tmp4=six.StringIO()
	fig4.savefig(tmp4, format='svg', bbox_inches='tight')
	# c4={'svg4':tmp4.getvalue()}
	tmp5=six.StringIO()
	fig5.savefig(tmp5, format='svg', bbox_inches='tight')
	# c5={'svg5':tmp5.getvalue()}
	c={'svg1':tmp1.getvalue(),'svg2':tmp2.getvalue(),'svg3':tmp3.getvalue(),'svg4':tmp4.getvalue(),'svg5':tmp5.getvalue(),'finalX':finalX,'ABCX':ABCX}
	return render(request, 'ABCquestionnaire/final.html', c)
예제 #2
0
def python_code(request):   
    values=Value.objects.order_by('-id')[0]
    datas=[values.SN,values.choice1,values.choice2,values.choice3,values.choice4,
            values.choice5,values.choice6,values.choice7,values.choice8,values.choice9,
            values.choice10,values.choice11,values.choice12,values.choice13,values.choice14,
            values.choice15,values.choice16,values.choice17 
        ]
    fig1,fig2,fig3,fig4,fig5=graphs.python(datas)
    template=loader.get_template('ABCquestionnaire/final.html')
    tmp1=six.StringIO()
    fig1.savefig(tmp1, format='svg', bbox_inches='tight')    
    c1={'svg1':tmp1.getvalue()}
    tmp2=six.StringIO()
    fig2.savefig(tmp2, format='svg', bbox_inches='tight')
    c2={'svg2':tmp2.getvalue()}
    tmp3=six.StringIO()
    fig3.savefig(tmp3, format='svg', bbox_inches='tight')
    c3={'svg3':tmp3.getvalue()}
    tmp4=six.StringIO()
    fig4.savefig(tmp4, format='svg', bbox_inches='tight')
    c4={'svg4':tmp4.getvalue()}
    tmp5=six.StringIO()
    fig5.savefig(tmp5, format='svg', bbox_inches='tight')
    c5={'svg5':tmp5.getvalue()}
    global c
    c={'svg1':tmp1.getvalue(),'svg2':tmp2.getvalue(),'svg3':tmp3.getvalue(),'svg4':tmp4.getvalue(),'svg5':tmp5.getvalue()}
    #return HttpResponse((template.render(c1),template.render(c2),template.render(c3),template.render(c4),template.render(c5)))
    return render(request, 'ABCquestionnaire/final.html', c)
예제 #3
0
def python_code(request):
    global datas
    global fig5
    global Xfinal
    global ABCX
    fig1, fig2, fig3, fig4, fig5, Xfinal, ABCX = graphs.python(datas)
    Xfinal = [('Grd', float("{0:.3f}".format(Xfinal[0]))),
              ('Vrb', float("{0:.3f}".format(Xfinal[1]))),
              ('Att', float("{0:.3f}".format(Xfinal[2]))),
              ('Std', float("{0:.3f}".format(Xfinal[3])))]
    Xfinal = sorted(Xfinal, key=lambda x: (-x[1], x[0]))
    template = loader.get_template('ABCquestionnaire/final.html')
    tmp1 = six.StringIO()
    fig1.savefig(tmp1, format='svg', bbox_inches='tight')
    # c1={'svg1':tmp1.getvalue()}
    tmp2 = six.StringIO()
    fig2.savefig(tmp2, format='svg', bbox_inches='tight')
    # c2={'svg2':tmp2.getvalue()}
    tmp3 = six.StringIO()
    fig3.savefig(tmp3, format='svg', bbox_inches='tight')
    # c3={'svg3':tmp3.getvalue()}
    tmp4 = six.StringIO()
    fig4.savefig(tmp4, format='svg', bbox_inches='tight')
    # c4={'svg4':tmp4.getvalue()}
    tmp5 = six.StringIO()
    fig5.savefig(tmp5, format='svg', bbox_inches='tight')
    # c5={'svg5':tmp5.getvalue()}
    global c
    c = {
        'svg1': tmp1.getvalue(),
        'svg2': tmp2.getvalue(),
        'svg3': tmp3.getvalue(),
        'svg4': tmp4.getvalue(),
        'svg5': tmp5.getvalue(),
        'Xfinal': Xfinal,
        'ABCX': ABCX
    }
    return render(request, 'ABCquestionnaire/final.html', c)