more fixes
This commit is contained in:
+21
-12
@@ -549,16 +549,23 @@ def exam_scores_cid(request, pk):
|
||||
user_scores[user] = sum(user_answers_marks[user])
|
||||
|
||||
user_scores_list = list(user_scores.values())
|
||||
mean = statistics.mean(user_scores_list)
|
||||
median = statistics.median(user_scores_list)
|
||||
try:
|
||||
mode = statistics.mode(user_scores_list)
|
||||
except statistics.StatisticsError:
|
||||
mode = "No unique mode"
|
||||
|
||||
df = user_scores_list
|
||||
fig = px.histogram(df, x=0)
|
||||
fig_html = fig.to_html()
|
||||
if len(user_scores_list) < 1:
|
||||
mean = 0
|
||||
median = 0
|
||||
mode = 0
|
||||
fig_html = ""
|
||||
else:
|
||||
mean = statistics.mean(user_scores_list)
|
||||
median = statistics.median(user_scores_list)
|
||||
try:
|
||||
mode = statistics.mode(user_scores_list)
|
||||
except statistics.StatisticsError:
|
||||
mode = "No unique mode"
|
||||
|
||||
df = user_scores_list
|
||||
fig = px.histogram(df, x=0)
|
||||
fig_html = fig.to_html()
|
||||
|
||||
total = len(questions)
|
||||
|
||||
@@ -592,6 +599,7 @@ def exam_scores_cid_user(request, pk, sk):
|
||||
answers_marks = []
|
||||
answers = []
|
||||
|
||||
|
||||
for q in questions:
|
||||
# Get user answer
|
||||
s = q.cid_user_answers.filter(cid=cid)
|
||||
@@ -608,11 +616,12 @@ def exam_scores_cid_user(request, pk, sk):
|
||||
a = 1
|
||||
else:
|
||||
a = 0
|
||||
correct_answer = q.GetPrimaryAnswer()
|
||||
answers.append(ans)
|
||||
answers_marks.append(a)
|
||||
answers_and_marks.append((ans, a))
|
||||
answers_and_marks.append((ans, a, correct_answer))
|
||||
|
||||
score = sum(answers_marks)
|
||||
total_score = sum(answers_marks)
|
||||
|
||||
total = len(questions)
|
||||
|
||||
@@ -625,7 +634,7 @@ def exam_scores_cid_user(request, pk, sk):
|
||||
"questions": questions,
|
||||
"answers": answers,
|
||||
"answers_marks": answers_marks,
|
||||
"score": score,
|
||||
"total_score": total_score,
|
||||
"answers_and_marks": answers_and_marks,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user