Skip to content

Features: Images in questions, Configurable amount of questions - #20

Open
redshiftss wants to merge 4 commits into
mainfrom
progress-bar-and-misc
Open

Features: Images in questions, Configurable amount of questions#20
redshiftss wants to merge 4 commits into
mainfrom
progress-bar-and-misc

Conversation

@redshiftss

@redshiftss redshiftss commented Jan 25, 2026

Copy link
Copy Markdown
Collaborator

This PR addresses:

It also adds a (pretty barebones, unpopulated) dev environment, and some info on how to set that up locally in case anyone's interested in contributing. I have not yet added instructions on who to contact in case of wrong questions since I wasn't sure who would want their e-mail out in the open from the question-writing team.

@mxsasha should also note that there should be some kind of media volume that gets mounted to the docker container when deploying, similar to how we do it in the dev setup.

A screenshot of the penaltyparty user interface for entering an answer, with the changes proposed in this PR.

@redshiftss
redshiftss requested a review from mxsasha January 25, 2026 15:13
@redshiftss
redshiftss force-pushed the progress-bar-and-misc branch from f9e4929 to bf83da1 Compare January 25, 2026 15:16
@redshiftss redshiftss self-assigned this Jan 25, 2026

@mxsasha mxsasha left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking forever on this and thanks for making the PR! Good changes, but we can do some improvements :)

Comment thread .devcontainer/Dockerfile Outdated

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a lot of duplication with the base Dockerfile, and I'm concerned they'll run out of sync. Maybe it can use the other one as a base?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should squash these migrations.

Comment thread penaltyparty/pp/models.py Outdated
Comment on lines +33 to +35
def is_boolean(self):
answers = self.answer_set.filter(status=Answer.STATUS.active)
return "True" in list(self.answer_set.filter(status=Answer.STATUS.active)) and "False" in list(self.answer_set.filter(status=Answer.STATUS.active))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not actually work. These are Answer instances, therefore never true/false.

Suggested change
def is_boolean(self):
answers = self.answer_set.filter(status=Answer.STATUS.active)
return "True" in list(self.answer_set.filter(status=Answer.STATUS.active)) and "False" in list(self.answer_set.filter(status=Answer.STATUS.active))
def is_boolean(self):
active_answer_texts = set(
self.answer_set.filter(status=Answer.STATUS.active)
.values_list("answer_text", flat=True)
)
return "True" in active_answer_texts and "False" in active_answer_texts

Comment thread penaltyparty/pp/views.py Outdated
questions_amt = self.object.questions_amount
else:
questions_amt = DEFAULT_TEST_GROUP_QUESTION_AMOUNT
random_pk = random.sample(list(pks), questions_amt)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This raises ValueError if the requested questions is more than the total amount we have. We need to validate for that.

Comment thread penaltyparty/pp/models.py
class Question(TimeStampedModel):
STATUS = Choices("active", "inactive")
question_text = models.TextField(unique=True)
question_image = models.ImageField(blank=True, null=True, upload_to="./uploads")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to sort out uploads in my deployment environment.

Comment thread .devcontainer/Dockerfile Outdated
postgresql18

# set default password for postgres user
RUN echo "password" > passwd postgres

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean? It just creates a file.

Comment thread penaltyparty/pp/models.py Outdated
return random.choice(remaining_questions)

def questions_answered(self):
return len(self.answers.all())

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More efficient (as you already did in total_questions):

Suggested change
return len(self.answers.all())
return self.answers.count()

Comment thread penaltyparty/pp/models.py Outdated
null=True,
blank=True,
)
questions_amount = models.BigIntegerField(verbose_name="How many questions would you like the test to have? (optional, will default to 40 if left blank)", null=True, blank=True)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, how about default=40, null=False? Backwards compatible, and fits.

Also, let's use DEFAULT_TEST_GROUP_QUESTION_AMOUNT, which we can then move to settings/__init__.py, fits better there anyways.

Comment thread penaltyparty/pp/views.py Outdated
Comment on lines +44 to +47
if self.object.questions_amount is not None:
questions_amt = self.object.questions_amount
else:
questions_amt = DEFAULT_TEST_GROUP_QUESTION_AMOUNT

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, I suggest a new method:

  def clean_questions_amount(self):
      return self.cleaned_data["questions_amount"] or DEFAULT_TEST_GROUP_QUESTION_AMOUNT

Comment thread CONTRIBUTING.md
It helps if you can tell us what exactly is wrong with the question, and reference specific sections of the WFTDA Rules/cases.

# Notes on style:
The only formatter we _particularly_ enforce is the use of `djLint` for formatting the HTML templates.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add this to CI, but that's out of scope here.

@redshiftss

Copy link
Copy Markdown
Collaborator Author

@mxsasha Sorry for taking so long to respond! I think I've addressed most of your comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants