|
a/OSSEval/analysis/models.py |
|
b/OSSEval/analysis/models.py |
|
... |
|
... |
287 |
def to_xml(self):
|
287 |
def to_xml(self):
|
288 |
return '<QuestionType Id="' + str(self.id) + '" Name="' + self.name + '"/>'
|
288 |
return '<QuestionType Id="' + str(self.id) + '" Name="' + self.name + '"/>'
|
289 |
|
289 |
|
290 |
class Question(models.Model):
|
290 |
class Question(models.Model):
|
291 |
page = models.ForeignKey(Page)
|
291 |
page = models.ForeignKey(Page)
|
292 |
text = models.CharField(max_length=200)
|
292 |
text = models.CharField(max_length=500)
|
293 |
order = models.IntegerField()
|
293 |
order = models.IntegerField()
|
294 |
eval_description = models.TextField(null=True,blank=True)
|
294 |
eval_description = models.TextField(null=True,blank=True)
|
295 |
eval_value = models.TextField(null=True,blank=True)
|
295 |
eval_value = models.TextField(null=True,blank=True)
|
296 |
question_type = models.ForeignKey(QuestionType)
|
296 |
question_type = models.ForeignKey(QuestionType)
|
297 |
|
297 |
|
|
... |
|
... |
439 |
|
439 |
|
440 |
|
440 |
|
441 |
class Graphs(models.Model):
|
441 |
class Graphs(models.Model):
|
442 |
bar_chart = models.TextField(blank=True)
|
442 |
bar_chart = models.TextField(blank=True)
|
443 |
radar_chart = models.TextField(blank=True)
|
443 |
radar_chart = models.TextField(blank=True)
|
|
|
444 |
# Graphs are generated for instances of classes that have a "pages" attribute
|
|
|
445 |
# which is a list of instances of the Class Page
|
|
|
446 |
# page and methodology_version have pages so this instance of graph has
|
|
|
447 |
# either a page or methodology_version not null
|
444 |
page = models.ForeignKey(Page,null=True,blank=True)
|
448 |
page = models.ForeignKey(Page,null=True,blank=True)
|
445 |
methodology_version = models.ForeignKey(MethodologyVersion,null=True,blank=True)
|
449 |
methodology_version = models.ForeignKey(MethodologyVersion,null=True,blank=True)
|
446 |
weight_scenario = models.ForeignKey(WeightScenario)
|
450 |
weight_scenario = models.ForeignKey(WeightScenario)
|
447 |
|
451 |
|
448 |
class Weight(models.Model):
|
452 |
class Weight(models.Model):
|
|
... |
|
... |
481 |
created = models.DateField(default=datetime.now, blank=True)
|
485 |
created = models.DateField(default=datetime.now, blank=True)
|
482 |
methodology_version = models.ForeignKey(MethodologyVersion)
|
486 |
methodology_version = models.ForeignKey(MethodologyVersion)
|
483 |
user_login = models.CharField(max_length=50)
|
487 |
user_login = models.CharField(max_length=50)
|
484 |
visible = models.BooleanField(default=True)
|
488 |
visible = models.BooleanField(default=True)
|
485 |
weight_scenario = models.ForeignKey(WeightScenario)
|
489 |
weight_scenario = models.ForeignKey(WeightScenario)
|
486 |
protected = models.BooleanField(default=False)
|
|
|
487 |
|
490 |
|
488 |
def __str__(self):
|
491 |
def __str__(self):
|
489 |
return self.name
|
492 |
return self.name
|
490 |
|
493 |
|
491 |
def calculate_scores(self, weight_scenario_id):
|
494 |
def calculate_scores(self, weight_scenario_id):
|
|
... |
|
... |
525 |
self.user_login = xmlMinidom.getStringAttribute(xmldoc, 'UserLogin')
|
528 |
self.user_login = xmlMinidom.getStringAttribute(xmldoc, 'UserLogin')
|
526 |
self.visible = xmlMinidom.getStringAttribute(xmldoc, 'Visible')
|
529 |
self.visible = xmlMinidom.getStringAttribute(xmldoc, 'Visible')
|
527 |
self.protected = xmlMinidom.getStringAttribute(xmldoc, 'Protected')
|
530 |
self.protected = xmlMinidom.getStringAttribute(xmldoc, 'Protected')
|
528 |
#self.weight_scenario
|
531 |
#self.weight_scenario
|
529 |
xml_weight_scenario = xmldoc.getElementsByTagName('WeightScenario')[0]
|
532 |
xml_weight_scenario = xmldoc.getElementsByTagName('WeightScenario')[0]
|
530 |
ws = WeightScenario()
|
533 |
ws = WeightScenario()
|
|
|
534 |
# while we import an analysis we shall not insert new weight scenarios
|
|
|
535 |
# weight scenarios should be just a reference to and existing one imported
|
|
|
536 |
# with the methodology
|
531 |
ws.from_xml(xml_weight_scenario, self.methodology_version, insert)
|
537 |
ws.from_xml(xml_weight_scenario, self.methodology_version, False)
|
532 |
self.weight_scenario = ws
|
538 |
self.weight_scenario = ws
|
533 |
self.save()
|
539 |
self.save()
|
534 |
#Instances
|
540 |
#Instances
|
535 |
xml_instances = xmldoc.getElementsByTagName('Instance')
|
541 |
xml_instances = xmldoc.getElementsByTagName('Instance')
|
536 |
for xml_instance in xml_instances:
|
542 |
for xml_instance in xml_instances:
|
|
... |
|
... |
568 |
self.analysis = analysis
|
574 |
self.analysis = analysis
|
569 |
xml_actual_instance = xmldoc.getElementsByTagName(self.analysis.methodology_version.methodology.entity.actual_entity_class)[0]
|
575 |
xml_actual_instance = xmldoc.getElementsByTagName(self.analysis.methodology_version.methodology.entity.actual_entity_class)[0]
|
570 |
module = importlib.import_module(self.analysis.methodology_version.methodology.entity.actual_entity_app + ".models")
|
576 |
module = importlib.import_module(self.analysis.methodology_version.methodology.entity.actual_entity_app + ".models")
|
571 |
actual_entity_class = getattr(module, self.analysis.methodology_version.methodology.entity.actual_entity_class)
|
577 |
actual_entity_class = getattr(module, self.analysis.methodology_version.methodology.entity.actual_entity_class)
|
572 |
self.actual_instance = actual_entity_class()
|
578 |
self.actual_instance = actual_entity_class()
|
|
|
579 |
# I need to save this instance so that I can save the actual_instance in the following from_xml
|
|
|
580 |
self.save()
|
573 |
self.actual_instance.from_xml(xml_actual_instance, self, insert)
|
581 |
self.actual_instance.from_xml(xml_actual_instance, self, insert)
|
574 |
self.save()
|
582 |
self.save()
|
575 |
#Answers
|
583 |
#Answers
|
576 |
xml_answers = xmldoc.getElementsByTagName('Answer')
|
584 |
xml_answers = xmldoc.getElementsByTagName('Answer')
|
577 |
for xml_answer in xml_answers:
|
585 |
for xml_answer in xml_answers:
|