Skip to content

Commit 5369dd6

Browse files
authored
Merge pull request #96 from arielfayol37/polishing
fixed(maybe) answer validation for units and sheer answer independence
2 parents bf84f35 + 824846a commit 5369dd6

File tree

17 files changed

+101
-86
lines changed

17 files changed

+101
-86
lines changed
0 Bytes
Binary file not shown.

Dr_R/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,6 @@
149149
EMAIL_PORT = 587
150150
EMAIL_USE_TLS = True
151151
EMAIL_HOST_USER = 'no.reply.dr.r.valpo@gmail.com' # Your Gmail address
152-
EMAIL_HOST_PASSWORD = 'jxey ewuu mrsq fvnb' # Your Gmail password
152+
EMAIL_HOST_PASSWORD = 'azuv oucz hahf sfqp' # Your Gmail password
153153

154154

db.sqlite3

0 Bytes
Binary file not shown.
-44 Bytes
Binary file not shown.
49 Bytes
Binary file not shown.
591 Bytes
Binary file not shown.

deimos/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def get_potential(self, no_unit = False):
290290
return potential * overall_percentage
291291

292292
def __str__(self):
293-
return f"Question-Student:{self.question} {self.student.username}"
293+
return f"{self.question} {self.student.username}"
294294

295295
class Note(models.Model):
296296
"""
@@ -342,7 +342,7 @@ class QuestionAttempt(models.Model):
342342
# while the actual submission will be stored in submitted_answer.
343343
submitted_answer =models.CharField(max_length=3000, blank=True, null=True)
344344
def __str__(self):
345-
return f"{self.question_student.student.username} attempt for {self.question_student.question}"
345+
return f"{self.question_student.student.username} for {self.question_student.question}"
346346

347347
class QASuccessPairs(models.Model):
348348
"""

deimos/static/deimos/js/answer_question.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ document.addEventListener('DOMContentLoaded', ()=> {
379379
return;
380380
}
381381

382-
} else if (questionType.value ==='mcq' && inputedMcqAnswersDiv.trueCounter===0){
383-
alert('Must select at least on MCQ answer as true');
382+
} else if (questionType.value =='mcq' && inputedMcqAnswersDiv.dataset.trueCounter== 0){
383+
alert('Must select at least one MCQ answer as true');
384384
return;
385385
} else if (questionType.value == 'mp'){
386386
// check whether all the parts have been selected.
@@ -854,23 +854,24 @@ document.addEventListener('DOMContentLoaded', ()=> {
854854
potential: '.status-potential',
855855
unitsNumAttempts:'.status-units-num-attempts'
856856
};
857-
857+
const qb = form.closest('.question-block');
858+
if (result.complete){
859+
qb.querySelector('.status-potential').style.display = 'none';
860+
}
858861
// Loop through each key in the statusMappings object
859862
for (const key in statusMappings) {
860863
if (statusMappings.hasOwnProperty(key)) {
861864
// Construct the selector using the mapping
862865
const selector = statusMappings[key] + ' .status-value';
863-
const qb = form.closest('.question-block');
866+
864867
// Update the innerHTML of the element matching the selector
865868
const element = qb.querySelector(selector);
866869
if(element != null){
867870
element.innerHTML = result[key];
868871
}
869-
if(result.success){
870-
qb.querySelector('.status-potential').style.display = 'none';
871-
}
872872
}
873873
}
874+
874875

875876
}
876877

deimos/templates/deimos/answer_question.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h3 class="original-size">Question {{question_dict.question.number}}</h3>
3838
</div>
3939

4040
<div class="status-potential">
41-
{% if not question_dict.question_student.success %}
41+
{% if not question_dict.question_student.is_complete %}
4242
Potential: <span class="status-value">{{question_dict.potential}}</span>%
4343
{% endif %}
4444
</div>
@@ -67,7 +67,7 @@ <h3 class="original-size">Question {{question_dict.question.number}}</h3>
6767
</div>
6868

6969
<div class="status-potential">
70-
{% if not question_dict.question_student.success %}
70+
{% if not question_dict.question_student.is_complete %}
7171
Potential: <span class="status-value">{{question_dict.potential}}</span>%
7272
{% endif %}
7373
</div>
@@ -213,7 +213,7 @@ <h3 class="original-size">Question {{question_dict.question.number}}</h3>
213213
<br/>
214214
{% endfor %}
215215
</div>
216-
{% if question_dict.question_student.success %}
216+
{% if question_dict.question_student.is_complete %}
217217
<input type="submit" class="btn btn-success exempt submit-btn" value="Submit Answer" style="display: none;">
218218
{% else %}
219219
<input type="submit" class="btn btn-success exempt submit-btn" value="Submit Answer">
@@ -263,7 +263,7 @@ <h3 class="original-size">Question {{question_dict.question.number}}</h3>
263263
</div>
264264
</div>
265265
<br/>
266-
{% if question_dict.question_student.success or question_dict.too_many_attempts %}
266+
{% if question_dict.question_student.is_complete %}
267267
<input type="submit" class="btn btn-success exempt submit-btn" value="Submit Answer" style="display: none;">
268268
{% else %}
269269
<input type="submit" class="btn btn-success exempt submit-btn" value="Submit Answer">
@@ -289,7 +289,7 @@ <h3 class="original-size">Question {{question_dict.question.number}}</h3>
289289
</div>
290290
</div>
291291
</div>
292-
{% if not question_dict.question_student.success %}
292+
{% if not question_dict.question_student.is_complete %}
293293
<input type="hidden" value="structural_{{question_dict.answer.get_answer_code}}" class="question-type"/>
294294
<!--TODO: !Important. I don't think we will ever use the pk of the answer for structural questions.-->
295295
<input type="hidden" value="{{question_dict.answer.pk}}" name="structural_answer_id_0"/>

deimos/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ def compare_units(units_1, units_2):
157157
"""
158158

159159
# custom_base_units = ['m', 's', 'cd', 'K', 'mol', 'g', 'A']
160-
scales = {'k':'10^3', 'u':'10^-6', 'm_':'10^-3', 'p':'10^-12', 'M':'10^6', 'n':'10^-9','µ':'10^-6'}
160+
scales = {'k':'(10^3)', 'u':'(10^-6)', 'm_':'(10^-3)', 'p':'(10^-12)', 'M':'(10^6)', 'n':'(10^-9)','µ':'(10^-6)'}
161161
# Important! Hz must come before H, as well as Sv before S, Wb before W etc
162162
correspondances = {
163-
'C': 'A*s', 'V': 'k*g*m^2*s^-3*A^-1','Ω': 'k*g m^2*s^-3*A^-2',
164-
'T': 'k*g*s^-2*A^-1','Hz': 's^-1','Pa': 'k*g*m^-1*s^-2','N': 'k*g*m*s^-2','J': 'k*g*m^2*s^-2',
165-
'Wb':'k*g*m^2*A*s^-2','W': 'k*g*m^2*s^-3', 'F':'k*g*A^2*s^4*m^-2', 'H':'k*g*m^2*A^2*s^-2',
166-
'Sv':'m^2*s^-2','S':'k*g*s^3*A^2*m^-2', 'lx':'cd*m^-2', 'Bq':'s^-1', 'Gy':'m^2*s^-2', 'kat':'mol*s^-1',
167-
'atm':'101325*k*g*m^-1*s^-2'
163+
'C': '(A*s)', 'V': '(k*g*m^2*s^-3*A^-1)','Ω': '(k*g m^2*s^-3*A^-2)',
164+
'T': '(k*g*s^-2*A^-1)','Hz': '(s^-1)','Pa': '(k*g*m^-1*s^-2)','N': '(k*g*m*s^-2)','J': '(k*g*m^2*s^-2)',
165+
'Wb':'(k*g*m^2*A*s^-2)','W': '(k*g*m^2*s^-3)', 'F':'(k*g*A^2*s^4*m^-2)', 'H':'(k*g*m^2*A^2*s^-2)',
166+
'Sv':'(m^2*s^-2)','S':'(k*g*s^3*A^2*m^-2)', 'lx':'(cd*m^-2)', 'Bq':'(s^-1)', 'Gy':'(m^2*s^-2)', 'kat':'(mol*s^-1)',
167+
'atm':'(101325*k*g*m^-1*s^-2)'
168168
}
169169
# transform_units_expression() must be done before to replacing the correspondances
170170
# and scales to reduce runtime.

0 commit comments

Comments
 (0)