fix some useranswer compare issuses

This commit is contained in:
Ross
2024-01-10 21:06:49 +00:00
parent 76b4746b13
commit 8d0ffbba06
12 changed files with 86 additions and 96 deletions
+6 -11
View File
@@ -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 %}
@@ -1,24 +0,0 @@
{% extends 'longs/base.html' %}
{% block content %}
CID: {{ciduseranswer.cid}}<br />
Exam: {{ciduseranswer.exam}}<br />
<h3>Question</h3>
{{ciduseranswer.question}}
<h3>Answers</h3>
<h4>Observation</h4>
<pre>{{ciduseranswer.answer_observations}}</pre><br />
<h4>Interpretation</h4>
<pre>{{ciduseranswer.answer_interpretation}}</pre><br />
<h4>Principle Diagnosis</h4>
<pre>{{ciduseranswer.answer_principle_diagnosis}}</pre><br />
<h4>Differential Diagnosis</h4>
<pre>{{ciduseranswer.answer_differential_diagnosis}}</pre><br />
<h4>Managment</h4>
<pre>{{ciduseranswer.answer_management}}</pre><br />
{% endblock content %}
@@ -0,0 +1,24 @@
{% extends 'longs/base.html' %}
{% block content %}
CID: {{useranswer.cid}}<br />
Exam: {{useranswer.exam}}<br />
<h3>Question</h3>
{{useranswer.question}}
<h3>Answers</h3>
<h4>Observation</h4>
<pre>{{useranswer.answer_observations}}</pre><br />
<h4>Interpretation</h4>
<pre>{{useranswer.answer_interpretation}}</pre><br />
<h4>Principle Diagnosis</h4>
<pre>{{useranswer.answer_principle_diagnosis}}</pre><br />
<h4>Differential Diagnosis</h4>
<pre>{{useranswer.answer_differential_diagnosis}}</pre><br />
<h4>Managment</h4>
<pre>{{useranswer.answer_management}}</pre><br />
{% endblock content %}
@@ -1,17 +0,0 @@
{% extends 'physics/base.html' %}
{% block content %}
CID: {{ciduseranswer.cid}}<br />
Exam: {{ciduseranswer.exam}}<br />
{{ciduseranswer.question}}<br />
Answers: <br />
<ol>
<li>{{ciduseranswer.a}}</li>
<li>{{ciduseranswer.b}}</li>
<li>{{ciduseranswer.c}}</li>
<li>{{ciduseranswer.d}}</li>
<li>{{ciduseranswer.e}}</li>
</ol>
Score: {{ciduseranswer.get_answer_score}}<br />
<a href="{% url 'physics:user_answer_delete' ciduseranswer.id %}">Delete answer</a>
{% endblock content %}
@@ -0,0 +1,17 @@
{% extends 'physics/base.html' %}
{% block content %}
CID: {{useranswer.cid}}<br />
Exam: {{useranswer.exam}}<br />
{{useranswer.question}}<br />
Answers: <br />
<ol>
<li>{{useranswer.a}}</li>
<li>{{useranswer.b}}</li>
<li>{{useranswer.c}}</li>
<li>{{useranswer.d}}</li>
<li>{{useranswer.e}}</li>
</ol>
Score: {{useranswer.get_answer_score}}<br />
<a href="{% url 'physics:user_answer_delete' useranswer.id %}">Delete answer</a>
{% endblock content %}
+3 -9
View File
@@ -76,8 +76,8 @@ def image_directory_path(instance, filename):
def get_answer_compare(s):
s = s.strip().lower()
s = s.translate(str.maketrans("", "", string.punctuation.replace("#", "")))
s = s.strip().translate(str.maketrans("", "", string.punctuation.replace("#", ""))).lower()
s = " ".join(s.split())
return s
@@ -804,13 +804,7 @@ class UserAnswer(UserAnswerBase):
self.score = Answer.MarkOptions.UNMARKED
if self.answer:
self.answer = self.answer.strip()
s = self.answer.lower()
s = s.translate(
str.maketrans("", "", string.punctuation.replace("#", ""))
).strip()
self.answer_compare = s
self.answer_compare = get_answer_compare(self.answer)
else:
self.answer = ""
self.answer_compare = ""
@@ -1,13 +0,0 @@
{% extends 'rapids/base.html' %}
{% block content %}
CID: {{ciduseranswer.cid}}<br/>
User: {{ciduseranswer.user}}<br/>
Exam: {{ciduseranswer.exam}}<br/>
{{ciduseranswer.question}}<br/>
Normal: {{ciduseranswer.normal}}<br/>
Answer: {{ciduseranswer.answer}}<br/>
Score: {{ciduseranswer.get_answer_score}}<br/>
<a href="{% url 'rapids:user_answer_delete' ciduseranswer.id %}">Delete answer</a>
{% endblock content %}
@@ -0,0 +1,13 @@
{% extends 'rapids/base.html' %}
{% block content %}
CID: {{useranswer.cid}}<br/>
User: {{useranswer.user}}<br/>
Exam: {{useranswer.exam}}<br/>
{{useranswer.question}}<br/>
Normal: {{useranswer.normal}}<br/>
Answer: {{useranswer.answer}}<br/>
Score: {{useranswer.get_answer_score}}<br/>
<a href="{% url 'rapids:user_answer_delete' useranswer.id %}">Delete answer</a>
{% endblock content %}
@@ -1,11 +0,0 @@
{% extends 'rapids/base.html' %}
{% block content %}
CID: {{ciduseranswer.cid}}<br/>
Exam: {{ciduseranswer.exam}}<br/>
{{ciduseranswer.question}}<br/>
Answer: {{ciduseranswer.answer}}<br/>
Score: {{ciduseranswer.get_score}}<br/>
<a href="{% url 'sbas:user_answer_delete' ciduseranswer.id %}">Delete answer</a>
{% endblock content %}
@@ -0,0 +1,11 @@
{% extends 'rapids/base.html' %}
{% block content %}
CID: {{useranswer.cid}}<br/>
Exam: {{useranswer.exam}}<br/>
{{useranswer.question}}<br/>
Answer: {{useranswer.answer}}<br/>
Score: {{useranswer.get_score}}<br/>
<a href="{% url 'sbas:user_answer_delete' useranswer.id %}">Delete answer</a>
{% endblock content %}