Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

attributeset.py 1.4KB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from django.db import models
  2. import random
  3. # attributeset für worker skills und order workload
  4. class AttributeSet(models.Model):
  5. experience = models.IntegerField(default=10)
  6. reliability = models.IntegerField(default=10)
  7. python = models.IntegerField(default=10)
  8. javascript = models.IntegerField(default=10)
  9. cpp = models.IntegerField(default=10)
  10. management = models.IntegerField(default=10)
  11. def __str__(self):
  12. return "AttributeSet"
  13. @classmethod
  14. def createRandom(cls, median):
  15. attributelist = []
  16. for j in range(6):
  17. randnumber = round(random.uniform(0.5, 1.5) * (median))
  18. # if randnumber > 100:
  19. # randnumber = 100
  20. attributelist.append(randnumber)
  21. attributeset = cls(
  22. experience=attributelist[0],
  23. reliability=attributelist[1],
  24. python=attributelist[2],
  25. javascript=attributelist[3],
  26. cpp=attributelist[4],
  27. management=attributelist[5],
  28. )
  29. attributeset.save()
  30. return attributeset
  31. def increase(self, amount, attribute):
  32. if attribute in [
  33. "experience",
  34. "reliability",
  35. "python",
  36. "javascript",
  37. "cpp",
  38. "management",
  39. ]:
  40. setattr(self, attribute, (getattr(self, attribute) + amount))
  41. self.save()