Switch to side-by-side view

--- a/OSSEval/analysis/views.py
+++ b/OSSEval/analysis/views.py
@@ -21,7 +21,7 @@
 from xml.dom import minidom
 from pygal import Bar
 from forms import AnalysisForm, UploadFileForm, ImportChoice
-from analysis.models import Analysis, Instance, UploadedFile, Answer, Methodology, MethodologyVersion, Question, Page
+from analysis.models import Analysis, Instance, UploadedFile, Answer, Choice, Methodology, MethodologyVersion, Question, Page
 #from methodology.models import Methodology, MethodologyVersion, Question, Page
 from OSSEval.utils import xmlMinidom, TrivialJSONEncoder, SearchEngine
 
@@ -129,7 +129,6 @@
     methodology_name = mv.methodology.name
     return render(request, 'analysis/weight_scenario_graph.html', {'weight_scenarios_graph': weight_scenarios_graph, 'methodology_name': methodology_name})
 
-
 def analysis_questions(request, analysis_id):
     analysis = get_object_or_404(Analysis, pk=analysis_id)
     weight_scenarios = analysis.methodology_version.weightscenario_set.all()
@@ -157,17 +156,19 @@
     try:
         question_id = request.POST.get("question_id", "")
         id_selected_instance = request.POST.get("id_selected_instance", "")
-        value = request.POST.get("value", "")
+        choice_id = request.POST.get("choice_id", "")
         notes = request.POST.get("notes", "")
         # I look for an answer for the same question and instance
         try:
-            a = Answer.objects.get(instance_id=id_selected_instance, question_id=question_id)
+            choices = Choice.objects.filter(question_id=question_id)
+            a = Answer.objects.get(instance_id=id_selected_instance, choice__in=choices)
         except:
             # I didn't find one; let's create it 
             a = Answer()
             a.instance = Instance.objects.get(pk=id_selected_instance)
             a.question = Question.objects.get(pk=question_id)
-        a.value_integer = value
+        choice = Choice.objects.get(pk=choice_id)
+        a.choice = choice
         a.notes = notes
         a.save()
     except Exception as ex:
@@ -190,7 +191,8 @@
     for page in pages:
         list_of_questions += page.questions()
     #all metadata about this instance
-    i = instance.actual_instance.getInstanceInfo()
+    actual_instance = getattr(instance, entity.actual_instance_accessor) 
+    i = actual_instance.getInstanceInfo()
     
     #eval python; python code assumes that all the information is in a structure called "i" which stands for "instance"
     for question in list_of_questions:
@@ -222,6 +224,11 @@
         print "question.id: " + str(question.id)
         q["description"] = description
         q["value"] = value
+        try:
+            choice = Choice.objects.get(question=question, value=value)
+            q["choice_id"] = choice.id
+        except:
+            q["choice_id"] = 0
         metadata.append(q)
     
     #restituire la lista delle domande con le elaborazioni allegate