Parent: [7f6519] (diff)

Download this file

models.pyc    133 lines (133 with data), 25.0 kB

ó
AÍSc@s\ddlmZddlmZddlmZddlmZmZddlm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZddlmZddlmZddlmZd	ejfd
„ƒYZdejfd„ƒYZd
efd„ƒYZdefd„ƒYZ dejfd„ƒYZ!dejfd„ƒYZ"dejfd„ƒYZ#dejfd„ƒYZ$dejfd„ƒYZ%dejfd„ƒYZ&dejfd„ƒYZ'dejfd „ƒYZ(d!ejfd"„ƒYZ)d#ejfd$„ƒYZ*d%ejfd&„ƒYZ+d'ejfd(„ƒYZ,d)S(*i˙˙˙˙(tmodels(tdatetime(t	randrange(tRadartBar(
t	NeonStyletDarkSolarizedStyletLightSolarizedStylet
LightStylet
CleanStyletRedBlueStyletDarkColorizedStyletLightColorizedStyletTurquoiseStyletLightGreenStyletDarkGreenStyletDarkGreenBlueStylet	BlueStyle(tEntity(t
xmlMinidom(tNodetMethodologycBseZejddƒZejdddedeƒZejdedeƒZej	deƒZ
ejeƒZ
d„Zed„Zd„ZRS(	t
max_lengthiČiĐtnulltblanktdefaultcCs|jS(N(tname(tself((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyt__str__scCsľ|stj|dƒ|_ntj|dƒ|_tj|dƒ|_tj|dƒ|_tj|dƒ|_t	ƒ}|j
dƒd}|j||ƒ||_|j
ƒdS(NtIdtNametDescriptiont
DocumentationtActiveRi(RtgetNaturalAttributetidtgetStringAttributeRt	getStringtdescriptiont
documentationtactiveRtgetElementsByTagNametfrom_xmltentitytsave(Rtxmldoctinserttet
xml_entity((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*s		cCsrd|jd}|d|jd7}||jjƒ7}dt|jƒd|jdt|jƒd|d	S(
Ns<Description><![CDATA[s]]></Description>s<Documentation><![CDATA[s]]></Documentation>s<Methodology Id="s" Name="s
" Active="s">s</Methodology>(R&R'R+tto_xmltstrR#RR((Rtstr_xml((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1#s(t__name__t
__module__Rt	CharFieldRtTrueR&t	TextFieldR'tBooleanFieldR(t
ForeignKeyRR+RR*R1(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR
s	tHasPagescBsHeZejdeƒZejdeƒZd„Zddd„ƒYZRS(Rc	
CsŔt}tdddddtdddtd	|ƒ}tdddddtd
tdtd	|ƒ}|jjdkr|j|_n	d|_g|_i}x|D]}g||j	<q Wx|j
jƒD]~}|jj|jƒxb|D]Z}y6t
jjd
|d|ƒ}||j	j|jƒWqç||j	jdƒqçXqçWqÇWxH|D]@}|j|j||j	ƒ|j|jt||j	ƒƒqPW|jƒ|_|jƒ|_|jƒdS(Ntwidthi,theightit
explicit_sizetrounded_barsitdisable_xml_declarationtstyletlegend_at_bottomtPages
Summary graphtpagetinstancei(RRR7Rt	__class__R4Rttitletx_labelsR#tpage_settalltappendt	PageScoretobjectstgettscoretaddtsumtrendertradar_chartt	bar_chartR,(	Rt	instancesRARTRStinstance_scoresRERDtps((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyt
create_graphs,s0--		

 
$tMetacBseZeZRS((R4R5R7tabstract(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRYIs((	R4R5RR8R7RTRSRXRY(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR;)s	tMethodologyVersioncBs_eZejƒZejƒZejdeƒZ	ej
eƒZd„Z
ed„Zd„ZRS(RcCs.|jjdt|jƒ|jr)dndS(Ns - s (Active version)t(tmethodologyRR2tnumbertcurrent(R((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRRscCss|stj|dƒ|_n|jdjj|_tj|dƒ|_tj|dƒ|_	t
ƒ}|jdƒd}|j||ƒ||_
|jƒx<|jD]1}|jtjkr§|jdkr§|}Pq§q§WxT|jD]I}|jtjkrć|jdkrćtƒ}|j||d|ƒqćqćW|jd	ƒ}	x*|	D]"}
tƒ}|j|
||ƒqIWdS(
NRtNumbertCreatedtCurrentRitPagesRCtWeightScenarios(RR"R#t
attributest
firstChildtdataR^R$tcreatedR_RR)R*R]R,t
childNodestnodeTypeRtELEMENT_NODEttagNameRCtNonetWeightScenario(RR-R.tmtxml_methodologyt	xml_childt	xml_pagestxml_pagetptxml_weight_scenariostxml_weight_scenariotws((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*Us,		
!!	
	cCsŰ|jjƒ}|d7}x'|jjƒD]}||jƒ7}q)W|d7}|d7}x'|jjƒD]}||jƒ7}qgW|d7}dt|jƒdt|jƒdt|jƒdt|j	ƒd	|d
S(Ns<Pages>s</Pages>s<WeightScenarios>s</WeightScenarios>s<MethodologyVersion Id="s
" Number="s" Created="s" Current="s">s</MethodologyVersion>(
R]R1RIRJtweightscenario_setR2R#R^RhR_(RR3RDtweight_scenario((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1qs



(R4R5RtIntegerFieldR^t	DateFieldRhR9tFalseR_R:RR]RR7R*R1(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR[Ls	RCcBsŤeZejddƒZejdedeƒZejdde	de	ƒZ
ejede	de	ƒZd„Z
d„Ze	d„Zd„Zd	„Zd
dd„ƒYZRS(
RiČRRRcCsCt|jjƒƒ}x'|jjƒD]}||jƒ7}q%W|S(N(tlisttquestion_setRJRIt	questions(RtqRt((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRƒscCs|jS(N(R(R((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR‰scCs°|stj|dƒ|_ntj|dƒ|_|jdjj|_|dk	ra||_
n|dk	ry||_n|jƒx<|j
D]1}|jtjkr|jdkr|}PqqWxT|j
D]I}|jtjkrĚ|jdkrĚtƒ}|j|d||ƒqĚqĚWx<|j
D]1}|jtjkr#|jdkr#|}	Pq#q#WxQ|	j
D]F}
|
jtjkrb|
jdkrbtƒ}|j|
||ƒqbqbWdS(NRRtOrderRcRCt	QuestionstQuestion(RR"R#R$RReRfRgtorderRmtmethodology_versiontparentR,RiRjRRkRlRCR*Rƒ(RR-R…tparent_pageR.RqRrRsRtt
xml_questionstxml_questionR€((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*Œs2
!!	!!	cCsąd}x'|jjƒD]}||jƒ7}qW|d7}|d7}x'|jjƒD]}||jƒ7}qTW|d7}dt|jƒd|jdt|jƒd|d	S(
Ns<Pages>s</Pages>s<Questions>s</Questions>s
<Page Id="s" Name="s	" Order="s">s</Page>(RIRJR1R~R2R#RR„(RR3RDtquestion((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1Ťs


c
Cs9ytjjd|d|ƒ}Wn"td|d|ddƒ}nXd|_x5|jjƒD]$}|j|j|||ƒ7_q]Wx“|jƒD]…}|j|j	ƒ}yOt
jjd|d|ƒ}||jd|_|jƒ|j|j7_Wq’t
k
r}	|	jGHq’Xq’W|jƒ|j|ƒ|jS(NRDREROiRŠi(RLRMRNRORIRJtcalculate_scoresRtquestion_weightR#tAnswert
value_integerR,t	ExceptiontmessageRX(
RRERyRURWRDRŠtweighttanswertex((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR‹śs(	"


RYcBseZdgZRS(R„(R4R5tordering(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRYĐs((R4R5RR6RRzR|R„R:R7R†R[R…RRR*R1R‹RY(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRC~s				tQuestionTypecBs5eZdZejddƒZed„Zd„ZRS(sL
    For future use; at the moment a question is just a multiple choice
    RiČcCs7|stj|dƒ|_ntj|dƒ|_dS(NRR(RR"R#R$R(RR-R.((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*ŮscCs dt|jƒd|jdS(Ns<QuestionType Id="s" Name="s"/>(R2R#R(R((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1Ţs(	R4R5t__doc__RR6RR7R*R1(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR•ÓsRƒcBsĽeZejeƒZejddƒZejƒZ	ej
dedeƒZej
dedeƒZ
ejeƒZd„Zed„Zd„Zdd	d„ƒYZRS(
RiČRRcCs|jjd|jS(Ns - (RDRttext(R((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRéscCs|stj|dƒ|_ntj|dƒ|_tj|dƒ|_tjjddƒ}||_	||_
tj|dƒ|_tj|dƒ|_
|jƒ|jdƒ}x*|D]"}tƒ}|j|||ƒqšW|jd	ƒ}x*|D]"}	tƒ}
|
j|	||ƒqőWdS(
NRtTextRtpkitEvalDescriptiont	EvalValuetQuerytChoice(RR"R#R$R—R„R•RMRNRDt
question_typeR%teval_descriptiont
eval_valueR,R)RœR*R(RR-RDR.tqttxml_queriest	xml_queryR€txml_choicest
xml_choicetc((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*ěs$		

	
	cCsd|jdkrdn|jd}|d|jdkrAdn|jd7}|d7}x'|jjƒD]}||jƒ7}qjW|d7}|d7}x'|jjƒD]}||jƒ7}q¨W|d	7}d
t|jƒd|j	dt|j
ƒd
|dS(Ns<EvalDescription><![CDATA[R\s]]></EvalDescription>s<EvalValue><![CDATA[s]]></EvalValue>s	<Queries>s
</Queries>s	<Choices>s
</Choices>s<Question Id="s" Text="s	" Order="s">s</Question>(RŸRmR t	query_setRJR1t
choice_setR2R#R—R„(RR3tquerytchoice((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1s&*



RYcBseZdgZRS(R„(R4R5R”(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRYs((R4R5RR:RCRDR6R—RzR„R8R7RŸR R•RžRR*R1RY(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRƒás		RœcBsheZdZejeƒZejddƒZejddƒZ	ejddƒZ
ed„Zd„Z
RS(sx
    Queries against web search engines used to automate the answer to a question and/or as a hint to the reviewer 
    RiĐcCsh|stj|dƒ|_n||_tj|dƒ|_tj|dƒ|_d|_|jƒdS(NRtEvalTexttEvalSiteR\(	RR"R#RŠR%t	eval_textt	eval_siteteval_site_excludeR,(RR-RŠR.((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*s		cCsCd|jd}|d|jd7}dt|jƒd|dS(Ns<EvalText><![CDATA[s]]></EvalText>s<EvalSite><![CDATA[s]]></EvalSite>s<Query Id="s">s</Query>(R­RŽR2R#(RR3((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1's(R4R5R–RR:RƒRŠR6R­RŽRŻR7R*R1(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRœs	RcBsueZdZejeƒZejddƒZej	ƒZ
ejddƒZed„Z
d„Zddd„ƒYZRS(	s
    RiČiĐcCst|stj|dƒ|_n||_tj|dƒ|_tj|dƒ|_tj|dƒ|_|j	ƒdS(NRR˜RtTodo(
RR"R#RŠR$R—R„R%ttodoR,(RR-RŠR.((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*4s	cCsJd|jd}dt|jƒd|jdt|jƒd|dS(Ns<Todo>s</Todo>s<Choice Id="s" Text="s	" Order="s">s	</Choice>(RąR2R#R—R„(RR3((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1=sRYcBseZdgZRS(R„(R4R5R”(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRYAs((R4R5R–RR:RƒRŠR6R—RzR„RąR7R*R1RY(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR,s		RncBsbeZejddƒZejeƒZejde	ƒZ
d„Zed„Z
d„Zd„ZRS(RiČRcCsBd}x5|jjƒD]$}|jj|kr|j}qqW|S(s2
        returns the weight; default is 1
        i(t
weight_setRJRŠR#R‘(Rtquestion_idR‘tw((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRŒIs
cCs›|stj|dƒ|_n||_tj|dƒ|_tj|dƒ|_|jƒ|jdƒ}x*|D]"}t	ƒ}|j
|||ƒqqWdS(NRRR!tWeight(RR"R#R…R$RR(R,R)RľR*(RR-R…R.txml_weightst
xml_weightR´((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*Rs	

	cCssd}x'|jjƒD]}||jƒ7}qW|d7}dt|jƒd|jdt|jƒd|dS(Ns	<Weights>s
</Weights>s<WeightScenario Id="s" Name="s
" Active="s">s</WeightScenario>(R˛RJR1R2R#RR((RR3R‘((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1_s

cCs|jS(N(R(R((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRfs(R4R5RR6RR:R[R…R9R|R(RŒR7R*R1R(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRnDs		
	RľcBsGeZejeƒZejƒZejeƒZ	e
d„Zd„ZRS(cCsn|stj|dƒ|_n||_tj|dƒ|_tjjdtj|dƒƒ|_	|j
ƒdS(NRR‘R™Rł(RR"R#tscenarioR$R‘RƒRMRNRŠR,(RR-R¸R.((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*ns	$cCs:dt|jƒdt|jjƒdt|jƒdS(Ns<Weight Id="s" question_id="s
" weight="s"/>(R2R#RŠR‘(R((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1vs(
R4R5RR:RƒRŠt
FloatFieldR‘RnR¸R7R*R1(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRľis
tAnalysiscBsÚeZejddƒZejddƒZejdedeƒZej	de
jdeƒZej
eƒZejddƒZejdeƒZej
eƒZejdeƒZd„Zd„Zed	„Zd
„ZRS(RiČiĐRRRi2cCs|jS(N(R(R((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR„scCsÚyW|jjjdtƒ}t|ƒdkr:|d}ntdt|jjƒƒ‚Wntƒ}nXxP|jj	j
ƒD]<}x3|jj
ƒD]"}|j|||jj
ƒƒq“Wq}W|jj
|jj
ƒƒdS(s|
        Calculates scores for each couple (instance, page) and (instance, question)
        Stores them on the db 
        R(iisBThere should be exactly one WeightScenario for MethodologyVersion N(R…RxtfilterR7tlenRR2R#RnRIRJtinstance_setR‹RX(Rtweight_scenariosRyRDRE((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR‹‡s
 
$cCsdS(s†
        All but the MethodologyVersion so that we can independently import from xml 
        MethodologyVersion and Analysis
        N((RR-R.((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*¤scCsťd|jd}|d|jd7}||jjƒ7}|d7}x'|jjƒD]}||jƒ7}qSW|d7}dt|jƒd|jd	t|j	ƒd
|j
d|dS(
Ns
<Description>s</Description>s	<Comment>s
</Comment>s<Instances>s</Instances>s<Analysis Id="s" Name="s"  Created="s
" UserLogin="s">s</Analysis>(R&tcommentRyR1R˝RJR2R#RRht
user_login(RR3RE((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1Ťs

(R4R5RR6RR&R8R7RżR{RtnowRhR:R[R…RŔR9tvisibleRnRyR|t	protectedRR‹R*R1(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRşys		tInstancecBseeZdZejddƒZejddddƒZejeƒZ	d„Z
ed„Zd„Z
RS(sI
    It represents one of the entities we evaluate in the assessment
    RiČRR\cCs|jd|jS(Ns - (Rtname_for_search(R((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRžscCsdS(N((RR-R.((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*ÁscCsmd}x'|jjƒD]}||jƒ7}qW|d7}dt|jƒd|jd|jd|dS(Ns	<Answers>s
</Answers>s<Instance Id="s" Name="s" NameForSearch="s">s</Instance>(t
answer_setRJR1R2R#RRĹ(RR3R’((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1Äs

(R4R5R–RR6RRĹR:RştanalysisRR7R*R1(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRÄśs	RLcBsEeZejeƒZejeƒZejƒZ	ddd„ƒYZ
RS(RYcBseZdZRS(RDRE(spagesinstance(R4R5tunique_together(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRYĐs((R4R5RR:RCRDRÄRERšRORY(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRLĚsRcBs„eZdZejeƒZejeƒZej	ƒZ
ejddƒZej
ddƒZed„Zd„Zdd	d„ƒYZRS(
s™
    value_integer is the value of the answer
    score is value_integer * weight
    where weight is associated to the question in a WeightScenario
    RiRiĐcCsdS(N((RR-R.((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR*ŕscCsLd|jd}|dt|jjƒd7}dt|jƒd|dS(Ns<Notes>s</Notes>s<Question Id="s
"></Question>s<Answer ValueInteger="s">s	</Answer>(tnotesR2RŠR#RŽ(RR3((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyR1ăsRYcBseZdZRS(RŠRE(squestionsinstance(R4R5RČ(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRYés((R4R5R–RR:RÄRERƒRŠRzRŽRšROR6RÉR7R*R1RY(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRÔs	t
ConfigurationcBs#eZejededeƒZRS(RR(R4R5RR:R[R7tdefault_methodology_version(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRĘěstUploadedFilecBs eZdZejddƒZRS(sW
    Used to save uploaded xml file so that it can be later retrieved and imported
    t	upload_tosdocuments/%Y/%m/%d(R4R5R–Rt	FileFieldtdocfile(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyRĚđsN(-t	django.dbRRtrandomRtpygalRRtpygal.styleRRRRR	R
RRR
RRRRt
entity.modelsRt
OSSEval.utilsRtxml.dom.minidomRtModelRR;R[RCR•RƒRœRRnRľRşRÄRLRRĘRĚ(((sI/media/discoc/Dati/Lavoro/PROSE/Lavoro/OSSEval/OSSEval/analysis/models.pyt<module>s.X#2U4%=