+{% endblock %}
\ No newline at end of file
diff --git a/physics/templates/physics/exam_take.html b/physics/templates/physics/exam_take.html
index 860d10fb..74a47840 100644
--- a/physics/templates/physics/exam_take.html
+++ b/physics/templates/physics/exam_take.html
@@ -21,32 +21,32 @@
{{ question.a }}:
{{ question.b }}:
{{ question.c }}:
{{ question.d }}:
{{ question.e }}:
@@ -108,14 +108,13 @@ function postAnswers(ans) {
$.post("{% url 'physics:exam_answers_submit' %}", JSON.stringify(ans)).done((data) => {
console.log(data);
if (data.success) {
- if (data.question_count == window.number_of_questions) {
let ret = confirm(
- `${data.question_count} answers sucessfully submitted. Click OK to finish the exam.`
- window.answers_submitted = true;
+ `Answers sucessfully submitted. Click OK to finish the exam.`
);
if (ret) {
window.saveSession();
+ window.answers_submitted = true;
if (config.exam_results_url != "") {
let url = config.exam_results_url;
@@ -131,9 +130,6 @@ function postAnswers(ans) {
$("#options-panel").show();
} else {
}
- } else {
- alert(`Answers sucessfully submitted.`);
- }
} else {
alert(`Error submitting answers: ${data.error}`);
}
@@ -152,6 +148,7 @@ function postAnswers(ans) {
height: 20px;
margin: 0px;
margin-bottom: -5px;
+ float: right;
}
.truefalse-switch input {
@@ -165,7 +162,7 @@ function postAnswers(ans) {
left: 0;
right: 0;
bottom: 0;
- background-color: rgba(255, 0, 0, 0.5);
+ background-color: rgba(0, 4, 255, 0.5);
-webkit-transition: .4s;
transition: .4s;
border-radius: 20px;
@@ -185,7 +182,7 @@ function postAnswers(ans) {
}
input:checked+.slider {
- background-color: rgba(0, 255, 0, 0.5);
+ background-color: rgba(162, 0, 255, 0.5);
}
input:focus+.slider {
@@ -200,7 +197,6 @@ function postAnswers(ans) {
/*------ ADDED CSS ---------*/
.slider:after {
- content: 'FALSE';
color: white;
display: block;
position: absolute;
@@ -211,12 +207,55 @@ function postAnswers(ans) {
font-family: Verdana, sans-serif;
}
- input:checked+.slider:after {
- content: 'TRUE';
+ .a.slider:after {
+ content: 'a) FALSE';
+ }
+
+ .b.slider:after {
+ content: 'b) FALSE';
+ }
+
+ .c.slider:after {
+ content: 'c) FALSE';
+ }
+
+ .d.slider:after {
+ content: 'd) FALSE';
+ }
+
+ .e.slider:after {
+ content: 'e) FALSE';
+ }
+
+ input:checked+.slider.a:after {
+ content: 'a )TRUE';
+ }
+
+ input:checked+.slider.b:after {
+ content: 'b )TRUE';
+ }
+
+ input:checked+.slider.c:after {
+ content: 'c )TRUE';
+ }
+
+ input:checked+.slider.d:after {
+ content: 'd )TRUE';
+ }
+
+ input:checked+.slider.e:after {
+ content: 'e )TRUE';
}
.question-text {
display: inline-block;
+ vertical-align: text-top;
+ clear: both;
+ width: 600px;
+ }
+
+ .abcde {
+ clear: both;
}
{% endblock %}
\ No newline at end of file
diff --git a/physics/views.py b/physics/views.py
index f7a82299..e63b0281 100644
--- a/physics/views.py
+++ b/physics/views.py
@@ -154,18 +154,16 @@ def exam_scores_cid(request, pk):
user_answers[cid].append("")
continue
- ans = s.answer
- answer_score = s.get_answer_score()
- if answer_score == "unmarked":
- index = exam.get_question_index(q)
- unmarked.add(index)
+ ans = s.get_answers()
+ answer_scores = s.get_answer_scores()
+
user_answers[cid].append(ans)
- user_answers_marks[cid].append(answer_score)
- user_answers_and_marks[cid].append((ans, answer_score))
+ user_answers_marks[cid].append(answer_scores)
+ user_answers_and_marks[cid].append((ans, answer_scores))
user_scores = {}
for user in user_answers_marks:
- user_scores[user] = sum([i for i in user_answers_marks[user] if i != "unmarked"])
+ user_scores[user] = sum([sum(i) for i in user_answers_marks[user]])
user_scores_list = list(user_scores.values())
@@ -223,35 +221,25 @@ def exam_scores_cid_user(request, pk, sk):
for q in questions:
# Get user answer
user_answer = q.cid_user_answers.filter(cid=cid).first()
- if not user_answer:
- # skip if no answer
- answers_marks.append(0)
- answers.append("")
- answer_score = 0
- ans = "Not answered"
- else:
- ans = user_answer.answer
- answer_score = user_answer.get_answer_score()
+ ans = user_answer.get_answers()
- correct_answer = q.GetPrimaryAnswer()
+ answer_scores = user_answer.get_answer_scores()
+
+ correct_answers = q.get_answers()
if not exam.publish_results:
- correct_answer = "*****"
- answer_score = 0
+ correct_answers = ("*****", "*****", "*****", "*****", "*****")
+ answer_scores = (0, 0, 0, 0, 0)
answers.append(ans)
- answers_marks.append(answer_score)
- answers_and_marks.append((ans, answer_score, correct_answer))
+ answers_marks.append(answer_scores)
- if "unmarked" in answers_marks:
- answered = [i for i in answers_marks if type(i) == int]
- total_score = sum(answered)
- unmarked_number = len(answers_marks) - len(answered)
- total_score = "{} ({} unmarked)".format(total_score, unmarked_number)
- else:
- total_score = sum(answers_marks)
+ merged_ans = zip(q.get_questions(), ans, answer_scores, correct_answers)
+ answers_and_marks.append((q, merged_ans))
- max_score = len(questions) * 2
+ total_score = sum(sum(i) for i in answers_marks)
+
+ max_score = len(questions) * 5
return render(
request,