Skip to content

Allow configuring subtasks to always show testcases.#1677

Open
veluca93 wants to merge 1 commit intocms-dev:mainfrom
veluca93:always_show_testcases
Open

Allow configuring subtasks to always show testcases.#1677
veluca93 wants to merge 1 commit intocms-dev:mainfrom
veluca93:always_show_testcases

Conversation

@veluca93
Copy link
Copy Markdown
Contributor

Also defines a new (optional) format for parameters for ScoreTypeGroup.

@veluca93 veluca93 requested a review from prandla April 10, 2026 20:45
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 86.11111% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.71%. Comparing base (9d9ef69) to head (7274ee0).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
cms/grading/scoretypes/abc.py 90.00% 3 Missing ⚠️
cms/grading/scoretypes/GroupThreshold.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1677      +/-   ##
==========================================
+ Coverage   54.68%   54.71%   +0.02%     
==========================================
  Files         336      336              
  Lines       27439    27464      +25     
==========================================
+ Hits        15006    15026      +20     
- Misses      12433    12438       +5     
Flag Coverage Δ
functionaltests 0.00% <0.00%> (ø)
unittests 54.71% <86.11%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Also defines a new (optional) format for parameters for ScoreTypeGroup.
Also allows specifying testcases by lists instead of by regex.
@veluca93 veluca93 force-pushed the always_show_testcases branch from b183593 to 7274ee0 Compare April 10, 2026 20:58
veluca93 added a commit to veluca93/task-maker-rust that referenced this pull request Apr 10, 2026
This includes allowing to configure per-subtask "always show testcases"
introduced in cms-dev/cms#1677.
Copy link
Copy Markdown
Member

@prandla prandla left a comment

Choose a reason for hiding this comment

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

Some philosophical comments regarding type hints.

The implementation itself looks fine.

class ScoreTypeGroupParametersDict(TypedDict):
max_score: float
testcases: int | str | list[str]
threshold: NotRequired[float]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i'm a little unhappy about this scoretype-specific field being here, but well, the typing of the parameters is a huge mess anyways and this is hardly the worst part of it.

i don't think it's possible to fix it without refactoring how scoretypes work in general. python doesn't have associated types, so i don't think there is even a good way to express "this scoretype uses this subtype of the parameters dict for its methods". so we can just continue ignoring the type errors.

{% endfor %}"""

def get_max_score(self, group_parameter: ScoreTypeGroupParameters) -> float:
if isinstance(group_parameter, tuple) or isinstance(group_parameter, list):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can these ever legitemately be tuples? these parameters should be loaded from json, which doesn't return tuples. the type hint says tuple only because there is no way to type-hint a list whose elements have different types 🙃 (actually, that should probably be added to the comment near the definition of ScoreTypeGroupParameters)

if you assumed doing an isinstance(tuple) here would get the type checker to behave on the next line, then unfortunately that doesn't appear to be the case, as pyright at least assumes that the parameter is some kind of magical intersection of list and ScoreTypeGroupParametersDict.

@prandla
Copy link
Copy Markdown
Member

prandla commented Apr 11, 2026

I also briefly considered whether we should drop support for the list-based format entirely (at least within cms.grading.scoretypes) and convert the lists to dicts in the importers / a db updater, but it'd probably end up being more effort in total. that would probably also be more disruptive to forks with custom scoretypes.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants