Skip to content

Feature/problem status#108

Open
XanderVertegaal wants to merge 10 commits into
feature/hidden-problemsfrom
feature/problem-status
Open

Feature/problem status#108
XanderVertegaal wants to merge 10 commits into
feature/hidden-problemsfrom
feature/problem-status

Conversation

@XanderVertegaal
Copy link
Copy Markdown
Contributor

@XanderVertegaal XanderVertegaal commented May 20, 2026

(Depends on #106, which should be merged first.)

This PR introduces two new fields/properties on the Problem model:

  • Problem.gold (DB field) indicates whether the problem has been marked with 'gold' status by a master annotator.
  • Problem.status (computed) indicates the current status of a problem, which determines which users are able to see it, cf. the overview in README.md.

Only Master Annotators are able to toggle 'gold' status on a problem. I've added a modal that provides information about the various statuses and their effects. This is shown when the circle-info icon (see screenshot below).

image

@XanderVertegaal XanderVertegaal added the enhancement New feature or request label May 20, 2026
from problem.models import Problem, Sentence


@pytest.fixture
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've lifted these fixtures here so they are available to more test files.

expect(emitted).toEqual([{ id: 123, hidden: true }]);
});

it('should show the alert banner only when the problem is hidden', () => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The alert banner is no longer part of the VisibilityToggleComponent proper. It's now part of the ProblemDetails component. No functional changes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like that you also moved the test there. 👍

@XanderVertegaal XanderVertegaal marked this pull request as ready for review May 26, 2026 07:16
Copy link
Copy Markdown
Contributor

@jgonggrijp jgonggrijp left a comment

Choose a reason for hiding this comment

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

Looks good to me!

expect(emitted).toEqual([{ id: 123, hidden: true }]);
});

it('should show the alert banner only when the problem is hidden', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like that you also moved the test there. 👍

Comment on lines +8 to +26
@keyframes growIn {
from {
opacity: 0;
max-height: 0;
padding-top: 0;
padding-bottom: 0;
margin-bottom: 0;
overflow: hidden;
}
to {
opacity: 1;
max-height: 200px;
overflow: hidden;
}
}

.alert.alert-info {
animation: growIn 0.3s ease-out;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks very familiar. Didn't you add a similar piece of SCSS code in another recent PR?

Comment on lines +160 to +161
gold: false,
status: ProblemStatus.BRONZE
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is not a big deal and also not a change request, but it's worth mentioning that you can keep the diff smaller by always including a trailing comma. That also simplifies editing in cases where you want to change the order of lines.

Comment on lines +93 to +97
if not isinstance(gold, bool):
return Response(
{"detail": "'gold' must be a boolean."},
status=HTTP_400_BAD_REQUEST,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this validation come with DRF out of the box?

Comment on lines +11 to +13
entity1="dog",
entity2="canine",
relationship=KnowledgeBaseAnnotation.Relationship.EQUAL,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Zoology nitpick: dogs are a subset of canines.

Comment on lines +86 to +87
assert serializer.data["status"] == Problem.Status.BRONZE
assert serializer.data["gold"] is False
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why go with == on one line and is on the next?

</div>
@if (currentUser?.canChangeProblemStatus) {
<la-gold-toggle [problem]="problem()" />
} @if (currentUser?.canChangeProblemVisibility) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I understand correctly, these are two independent @ifs. So maybe distance the second conditional from the closing brace of the first.

Suggested change
} @if (currentUser?.canChangeProblemVisibility) {
}
@if (currentUser?.canChangeProblemVisibility) {

Comment on lines +2 to +3
@let canChangeVisibility = canChangeVisibility$
| async;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think in this case, the added newline makes the code less readable.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants