|
a/OSSEval/analysis/views.py |
|
b/OSSEval/analysis/views.py |
|
... |
|
... |
6 |
from django.utils import simplejson, timezone
|
6 |
from django.utils import simplejson, timezone
|
7 |
from django.views.generic import ListView
|
7 |
from django.views.generic import ListView
|
8 |
from xml.dom import minidom
|
8 |
from xml.dom import minidom
|
9 |
|
9 |
|
10 |
from forms import AnalysisForm, UploadFileForm, ImportChoice
|
10 |
from forms import AnalysisForm, UploadFileForm, ImportChoice
|
11 |
from analysis.models import Analysis, Configuration, Instance, UploadedFile, Answer
|
11 |
from analysis.models import Analysis, Configuration, Instance, UploadedFile, Answer, Methodology, MethodologyVersion, Question, Page
|
12 |
from methodology.models import Methodology, MethodologyVersion, Question, Page
|
12 |
#from methodology.models import Methodology, MethodologyVersion, Question, Page
|
13 |
from OSSEval.utils import xmlMinidom, TrivialJSONEncoder, SearchEngine
|
13 |
from OSSEval.utils import xmlMinidom, TrivialJSONEncoder, SearchEngine
|
14 |
|
14 |
|
15 |
def analysis_new(request, analysis_id=0):
|
15 |
def analysis_new(request, analysis_id=0):
|
16 |
if request.method == "POST":
|
16 |
if request.method == "POST":
|
17 |
form = AnalysisForm(request.POST)
|
17 |
form = AnalysisForm(request.POST)
|
|
... |
|
... |
57 |
|
57 |
|
58 |
return render(request, 'analysis/analysis_questions.html', {'analysis': analysis, 'analysis_detail': analysis_detail, 'methodology_version': analysis.methodology_version})
|
58 |
return render(request, 'analysis/analysis_questions.html', {'analysis': analysis, 'analysis_detail': analysis_detail, 'methodology_version': analysis.methodology_version})
|
59 |
|
59 |
|
60 |
def analysis_report(request, analysis_id):
|
60 |
def analysis_report(request, analysis_id):
|
61 |
analysis = get_object_or_404(Analysis, pk=analysis_id)
|
61 |
analysis = get_object_or_404(Analysis, pk=analysis_id)
|
62 |
|
62 |
analysis.calculate_scores()
|
|
|
63 |
# print "I am in view 'analysis_report'; page: " + analysis.methodology_version.page_set.all()[0].name
|
|
|
64 |
# print "has radar_chart: " + analysis.methodology_version.page_set.all()[0].radar_chart[:100]
|
|
|
65 |
# print "has pippo: " + analysis.methodology_version.page_set.all()[0].pippo
|
|
|
66 |
td_width = 100 / (1 + len(analysis.instance_set.all()))
|
63 |
return render(request, 'analysis/analysis_report.html', {'analysis': analysis})
|
67 |
return render(request, 'analysis/analysis_report.html', {'analysis': analysis, 'td_width': td_width})
|
64 |
|
68 |
|
65 |
def save_answer(request):
|
69 |
def save_answer(request):
|
66 |
try:
|
70 |
try:
|
67 |
question_id = request.POST.get("question_id", "")
|
71 |
question_id = request.POST.get("question_id", "")
|
68 |
id_selected_instance = request.POST.get("id_selected_instance", "")
|
72 |
id_selected_instance = request.POST.get("id_selected_instance", "")
|
|
... |
|
... |
103 |
|
107 |
|
104 |
#eval python; python code assumes that all the information is in a structure called "i" which stands for "instance"
|
108 |
#eval python; python code assumes that all the information is in a structure called "i" which stands for "instance"
|
105 |
for question in list_of_questions:
|
109 |
for question in list_of_questions:
|
106 |
description = ""
|
110 |
description = ""
|
107 |
value = -1
|
111 |
value = -1
|
|
|
112 |
#run queries on search engine
|
|
|
113 |
for query in question.query_set.all():
|
|
|
114 |
description=""
|
|
|
115 |
# eval_text defines the variable "description"
|
|
|
116 |
exec(query.eval_text)
|
|
|
117 |
sites = []
|
|
|
118 |
# eval_site defines the variable "sites"
|
|
|
119 |
exec(query.eval_site)
|
|
|
120 |
search_count = str(SearchEngine.search_count(q, sites))
|
|
|
121 |
search_url = SearchEngine.search_url(q, sites)
|
|
|
122 |
search_engine_name = SearchEngine.search__engine_name()
|
|
|
123 |
description += "<a target='_blank' href='" + search_url + "'>'" + SearchEngine.readable_query(q, sites) + "' on " + search_engine_name + ": (" + search_count + " results)</a><br>"
|
|
|
124 |
# eval_description and eval_value might use the results from the above queries so have to be run after them
|
108 |
exec(question.eval_description)
|
125 |
exec(question.eval_description)
|
109 |
exec(question.eval_value)
|
126 |
exec(question.eval_value)
|
110 |
#run queries on search engine
|
|
|
111 |
for query in question.query_set.all():
|
|
|
112 |
site = ""
|
|
|
113 |
print query.eval_text
|
|
|
114 |
exec(query.eval_text)
|
|
|
115 |
print q
|
|
|
116 |
print query.eval_site
|
|
|
117 |
exec(query.eval_site)
|
|
|
118 |
print site
|
|
|
119 |
search_count = str(SearchEngine.search_count(q, site))
|
|
|
120 |
search_url = SearchEngine.search_url(q, site)
|
|
|
121 |
print "get_metadata search_url: " + search_url
|
|
|
122 |
search_engine_name = SearchEngine.search__engine_name()
|
|
|
123 |
description += "<a target='_blank' href='" + search_url + "'>'" + SearchEngine.readable_query(q, site) + "' on " + search_engine_name + ": (" + search_count + " results)</a><br>"
|
|
|
124 |
q = {}
|
127 |
q = {}
|
125 |
q["question_id"] = question.id
|
128 |
q["question_id"] = question.id
|
|
|
129 |
print "question.id: " + str(question.id)
|
126 |
q["description"] = description
|
130 |
q["description"] = description
|
127 |
q["value"] = value
|
131 |
q["value"] = value
|
128 |
metadata.append(q)
|
132 |
metadata.append(q)
|
129 |
|
133 |
|
130 |
#restituire la lista delle domande con le elaborazioni allegate
|
134 |
#restituire la lista delle domande con le elaborazioni allegate
|