initial development checkpoint 4
This commit is contained in:
@@ -54,11 +54,17 @@ class Question:
|
||||
rop = ResponseOptionPool(cur)
|
||||
return "<br>".join([i.render_short() for i in rop.select_by_question_id(self.id)])
|
||||
|
||||
def get_correct_response_percentage(self, cur):
|
||||
rop = ResponseOptionPool(cur)
|
||||
response_options = rop.select_by_question_id(self.id)
|
||||
return sum([int(i.get_correctness()) for i in response_options]) / len(response_options) * 100
|
||||
|
||||
def render_short(self, cur):
|
||||
time_label = self.get_time_label()
|
||||
response_options = self.get_response_option_short_list(cur)
|
||||
correct_percentage = round(self.get_correct_response_percentage(cur))
|
||||
|
||||
return f'<div class="question-short"><a class="question-link" href="/index.py?mode=view-question&id={self.id}"><span class="sub-label">#{self.id}</span><span class="main-label">{self.title}</span></a><span class="sub-title">{time_label}</span><div class="response-option-short-list">{response_options}</div><div class="controls"><a class="sub-button" href="/index.py?mode=edit-question&id={self.id}">Редагувати</a><a class="scary-button" href="/index.py?mode=delete-question&id={self.id}">Видалити</a></div></div>'
|
||||
return f'<div class="question-short"><a class="question-link" href="/index.py?mode=view-question&id={self.id}"><span class="sub-label">#{self.id}</span><span class="main-label">{self.title}</span></a><span class="sub-title">{time_label}<br>{correct_percentage}% відповідей правильні</span><div class="response-option-short-list">{response_options}</div><div class="controls"><a class="magic-button" href="?mode=generate-response-options&id={self.id}">Згенерувати відповіді</a><a class="sub-button" href="/index.py?mode=edit-question&id={self.id}">Редагувати</a><a class="scary-button" href="/index.py?mode=delete-question&id={self.id}">Видалити</a></div></div>'
|
||||
|
||||
class QuestionPool:
|
||||
def __init__(self, db):
|
||||
|
||||
@@ -22,7 +22,7 @@ class ResponseOption:
|
||||
return self.questionID
|
||||
|
||||
def get_correctness(self):
|
||||
return correctness
|
||||
return self.correctness
|
||||
|
||||
def render_short(self):
|
||||
if self.correctness:
|
||||
|
||||
@@ -17,7 +17,7 @@ class Test:
|
||||
return self.name
|
||||
|
||||
def render_short(self):
|
||||
return f'<div class="test-short"><a class="test-link" href="/index.py?mode=view-test&id={self.id}"><span class="sub-label">#{self.id}</span><span class="main-label">{self.name}</span></a></div>'
|
||||
return f'<div class="test-short"><a class="test-link" href="/index.py?mode=view-test&id={self.id}"><span class="sub-label">#{self.id}</span><span class="main-label">{self.name}</span></a><div class="controls"><a class="sub-button" href="?mode=edit-test&id={self.id}">Редагувати</a><a class="scary-button" href="?mode=delete-test&id={self.id}">Видалити</a></div></div>'
|
||||
|
||||
class TestPool:
|
||||
def __init__(self, db):
|
||||
|
||||
Reference in New Issue
Block a user