fix some useranswer compare issuses
This commit is contained in:
+6
-11
@@ -35,6 +35,10 @@ def image_directory_path(instance, filename):
|
||||
# file will be uploaded to MEDIA_ROOT/anatomy/picture/<filename>
|
||||
return u"picture/anatomy/{0}".format(filename)
|
||||
|
||||
def get_answer_compare(s: str) -> str:
|
||||
s = s.strip().translate(str.maketrans("", "", string.punctuation)).lower()
|
||||
s = " ".join(s.split())
|
||||
return s
|
||||
|
||||
class BodyPart(models.Model):
|
||||
bodypart = models.CharField(max_length=200)
|
||||
@@ -333,11 +337,7 @@ class Answer(models.Model):
|
||||
def clean(self):
|
||||
if self.answer:
|
||||
self.answer = self.answer.strip()
|
||||
|
||||
s = " ".join(self.answer.lower().split())
|
||||
s = s.translate(str.maketrans("", "", string.punctuation))
|
||||
|
||||
self.answer_compare = s
|
||||
self.answer_compare = get_answer_compare(self.answer)
|
||||
|
||||
# def get_compare_string(self):
|
||||
# s = self.answer.lower().strip()
|
||||
@@ -506,12 +506,7 @@ class UserAnswer(UserAnswerBase):
|
||||
|
||||
def clean(self):
|
||||
if self.answer:
|
||||
self.answer = self.answer.strip()
|
||||
|
||||
s = self.answer.lower()
|
||||
s = s.translate(str.maketrans("", "", string.punctuation)).strip()
|
||||
|
||||
self.answer_compare = s
|
||||
self.answer_compare = get_answer_compare(self.answer)
|
||||
|
||||
# def get_compare_string(self):
|
||||
# # strip here should be unneccasry (providing clean is now working)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
{% extends 'anatomy/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
CID: {{ciduseranswer.cid}}<br />
|
||||
Exam: {{ciduseranswer.exam}}<br />
|
||||
{{ciduseranswer.question}}<br />
|
||||
Answer: {{ciduseranswer.answer}}<br />
|
||||
Score: {{ciduseranswer.get_answer_score}}<br />
|
||||
<a href="{% url 'anatomy:user_answer_delete' ciduseranswer.id %}">Delete answer</a>
|
||||
<a href="{% url 'admin:anatomy_useranswer_change' ciduseranswer.id %}">Admin Edit</a>
|
||||
{% endblock content %}
|
||||
@@ -0,0 +1,12 @@
|
||||
{% extends 'anatomy/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
CID: {{useranswer.cid}}<br />
|
||||
Exam: {{useranswer.exam}}<br />
|
||||
{{useranswer.question}}<br />
|
||||
Answer: {{useranswer.answer}}<br />
|
||||
Compare Answer: {{useranswer.answer_compare}}<br />
|
||||
Score: {{useranswer.get_answer_score}}<br />
|
||||
<a href="{% url 'anatomy:user_answer_delete' useranswer.id %}">Delete answer</a>
|
||||
<a href="{% url 'admin:anatomy_useranswer_change' useranswer.id %}">Admin Edit</a>
|
||||
{% endblock content %}
|
||||
Reference in New Issue
Block a user