|
a/OSSEval/analysis/views.py |
|
b/OSSEval/analysis/views.py |
|
... |
|
... |
17 |
from django.shortcuts import render, get_object_or_404, render_to_response, redirect
|
17 |
from django.shortcuts import render, get_object_or_404, render_to_response, redirect
|
18 |
from django.template import RequestContext
|
18 |
from django.template import RequestContext
|
19 |
from django.utils import simplejson, timezone
|
19 |
from django.utils import simplejson, timezone
|
20 |
from django.views.generic import ListView
|
20 |
from django.views.generic import ListView
|
21 |
from xml.dom import minidom
|
21 |
from xml.dom import minidom
|
22 |
|
22 |
from pygal import Bar
|
23 |
from forms import AnalysisForm, UploadFileForm, ImportChoice
|
23 |
from forms import AnalysisForm, UploadFileForm, ImportChoice
|
24 |
from analysis.models import Analysis, Instance, UploadedFile, Answer, Methodology, MethodologyVersion, Question, Page
|
24 |
from analysis.models import Analysis, Instance, UploadedFile, Answer, Methodology, MethodologyVersion, Question, Page
|
25 |
#from methodology.models import Methodology, MethodologyVersion, Question, Page
|
25 |
#from methodology.models import Methodology, MethodologyVersion, Question, Page
|
26 |
from OSSEval.utils import xmlMinidom, TrivialJSONEncoder, SearchEngine
|
26 |
from OSSEval.utils import xmlMinidom, TrivialJSONEncoder, SearchEngine
|
27 |
|
27 |
|
|
... |
|
... |
94 |
search_html_ui = str(search_html_form(request, analysis_id))[len("Content-Type: text/html; charset=utf-8"):]
|
94 |
search_html_ui = str(search_html_form(request, analysis_id))[len("Content-Type: text/html; charset=utf-8"):]
|
95 |
analysis_detail = str(instance_list_html(request, analysis_id))[len("Content-Type: text/html; charset=utf-8"):]
|
95 |
analysis_detail = str(instance_list_html(request, analysis_id))[len("Content-Type: text/html; charset=utf-8"):]
|
96 |
|
96 |
|
97 |
return render(request, 'analysis/analysis_detail.html', {'analysis': analysis, 'analysis_detail': analysis_detail, 'search_html_ui': search_html_ui, 'weight_scenarios': weight_scenarios})
|
97 |
return render(request, 'analysis/analysis_detail.html', {'analysis': analysis, 'analysis_detail': analysis_detail, 'search_html_ui': search_html_ui, 'weight_scenarios': weight_scenarios})
|
98 |
|
98 |
|
|
|
99 |
def weight_scenario_graph(request, methodology_version_id):
|
|
|
100 |
mv = get_object_or_404(MethodologyVersion, pk=methodology_version_id)
|
|
|
101 |
weight_scenarios = mv.weightscenario_set.all()
|
|
|
102 |
bar_chart = Bar()
|
|
|
103 |
bar_chart.title = mv.methodology.name + ' scenario comparison'
|
|
|
104 |
bar_chart.x_labels = []
|
|
|
105 |
for ws in weight_scenarios:
|
|
|
106 |
ws.weights_for_graph = []
|
|
|
107 |
qs = []
|
|
|
108 |
for p in mv.page_set.all():
|
|
|
109 |
qs+= p.questions()
|
|
|
110 |
include_weight_scenario = {}
|
|
|
111 |
for ws in weight_scenarios:
|
|
|
112 |
include_weight_scenario[ws.id] = False
|
|
|
113 |
for q in qs:
|
|
|
114 |
include_this = False
|
|
|
115 |
for ws in weight_scenarios:
|
|
|
116 |
if ws.question_weight(q.id) != 1:
|
|
|
117 |
include_this = True
|
|
|
118 |
if include_this:
|
|
|
119 |
bar_chart.x_labels.append(q.text)
|
|
|
120 |
for ws in weight_scenarios:
|
|
|
121 |
this_weight = ws.question_weight(q.id)
|
|
|
122 |
if this_weight != 1:
|
|
|
123 |
include_weight_scenario[ws.id] = True
|
|
|
124 |
ws.weights_for_graph.append(this_weight)
|
|
|
125 |
for ws in weight_scenarios:
|
|
|
126 |
if include_weight_scenario[ws.id]:
|
|
|
127 |
bar_chart.add(ws.name, ws.weights_for_graph)
|
|
|
128 |
weight_scenarios_graph = bar_chart.render()
|
|
|
129 |
methodology_name = mv.methodology.name
|
|
|
130 |
return render(request, 'analysis/weight_scenario_graph.html', {'weight_scenarios_graph': weight_scenarios_graph, 'methodology_name': methodology_name})
|
|
|
131 |
|
|
|
132 |
|
99 |
def analysis_questions(request, analysis_id):
|
133 |
def analysis_questions(request, analysis_id):
|
100 |
analysis = get_object_or_404(Analysis, pk=analysis_id)
|
134 |
analysis = get_object_or_404(Analysis, pk=analysis_id)
|
101 |
weight_scenarios = analysis.methodology_version.weightscenario_set.all()
|
135 |
weight_scenarios = analysis.methodology_version.weightscenario_set.all()
|
102 |
entity = analysis.methodology_version.methodology.entity
|
136 |
entity = analysis.methodology_version.methodology.entity
|
103 |
|
137 |
|