-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Assessments app Initial model structure #2
base: features/assessments-app
Are you sure you want to change the base?
feat: Assessments app Initial model structure #2
Conversation
apps/assessments/models/question.py
Outdated
DEFAULT_RELATED_NAME = 'questions' | ||
|
||
|
||
class Question(HtkBaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking that there should be:
Question Types:
BasicQuestion
- answer is a free text response (e.g.What is 1+1?
:2
)MultiChoiceQuestion
- multiple answer choices are presented, only one is correctMultiChoiceMultiAnswerQuestion
- multiple answer choices are presented, any number (0 or many) can be correct, all correct responses must be selected
DEFAULT_RELATED_NAME = 'choices' | ||
|
||
|
||
class QuestionChoice(HtkBaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AnswerChoice
DEFAULT_RELATED_NAME = 'answers' | ||
|
||
|
||
class Answer(HtkBaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class Assessment:
@property
def max_score(self):
return self.questions.count()
class AssessmentQuestion:
assessment: fk(Assesssment)
class AssessmentResponse
assessment: fk
user: fk
@property
def score(self):
score = len([response for response in self.responses.all() if response.is_correct])
return score
@property
def display_score(self):
return f'{self.score} / {self.assessment.max_score}'
@property
def score_percentage(self):
return self.score / self.assessment.max_score * 100
class AssessmentQuestionCorrectResponse: # or `AnswerKey`?
assessment: fk
question(_id): fk, related_name="answer_key", unique=True # (or maybe OneToOneField?)
answer_text: str(correct answer)
answer_choices: M2M(AnswerChoice)
class AssessmentQuestionResponse:
assessment_response: fk(AssessmentResponse, related_name="responses")
question: fk(the question this response is for)
answer_text: str(user's text)
answer_choices: M2M(AnswerChoice)
def __init__(self, assessment_response):
pass
@property
def is_correct(self):
is_correct = True # innocent until proven guilty
answer_key = self.question.answer_key
if is_correct and answer_key.answer_text != self.answer_text:
is_correct = False
if is_correct and answer_key.answer_choices != self.answer_choices:
is_correct = False
return is_correct
# Properties | ||
|
||
@property | ||
def choices_ordered(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
answer_choices_**
apps/assessments/models/question.py
Outdated
text = models.TextField(max_length=512) | ||
order = models.PositiveSmallIntegerField(default=0) | ||
should_shuffle_choices = models.BooleanField(default=False) | ||
has_correct_answer = models.BooleanField(default=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
No description provided.