Skip to content
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

[WIP]Optimize gradebook csv export/import #456

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dzhuang
Copy link
Contributor

@dzhuang dzhuang commented Feb 9, 2018

  • Add checks for new introduced settings items.
  • Add tests.

Features:

  1. Allow define user prefered csv encoding. (So that csv containing non-latin characters can be opened by Excel directly without convertion).
  2. Allow replace None in gradebook to 0.
  3. Allow customized output fields in csv,
  4. Allow enforce grades floor and ceiling for grades.
  5. Enable round for grades.
  6. Allow remove instructors and TAs from the output.

@codecov
Copy link

codecov bot commented Feb 9, 2018

Codecov Report

Merging #456 into master will increase coverage by 0.95%.
The diff coverage is 99.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #456      +/-   ##
==========================================
+ Coverage   67.36%   68.31%   +0.95%     
==========================================
  Files          46       46              
  Lines       10933    11119     +186     
  Branches     2041     2087      +46     
==========================================
+ Hits         7365     7596     +231     
+ Misses       2936     2893      -43     
+ Partials      632      630       -2
Impacted Files Coverage Δ
relate/checks.py 92.57% <100%> (+0.12%) ⬆️
course/models.py 84.1% <100%> (+0.12%) ⬆️
course/grades.py 71.34% <98.83%> (+3%) ⬆️
course/utils.py 73.03% <99.07%> (+4.86%) ⬆️
course/page/code.py 72.49% <0%> (+0.51%) ⬆️
course/auth.py 81.12% <0%> (+7.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22530d2...8f22e8f. Read the comment docs.

@dzhuang dzhuang force-pushed the allow_user_defined_csv_codec branch from f204428 to 9d8bc55 Compare February 9, 2018 16:15
@dzhuang dzhuang force-pushed the allow_user_defined_csv_codec branch 20 times, most recently from f6d99b5 to 7c54fc0 Compare February 12, 2018 18:42
@dzhuang dzhuang changed the title [WIP] Optimize gradebook csv exportation Optimize gradebook csv exportation Feb 12, 2018
@dzhuang dzhuang force-pushed the allow_user_defined_csv_codec branch from 7c54fc0 to ded9cbe Compare February 12, 2018 18:54
@dzhuang dzhuang changed the title Optimize gradebook csv exportation Optimize gradebook csv export/import Feb 12, 2018
@dzhuang dzhuang force-pushed the allow_user_defined_csv_codec branch from ded9cbe to 99e8f6f Compare February 12, 2018 19:03
@dzhuang
Copy link
Contributor Author

dzhuang commented Feb 12, 2018

@inducer How do you feel about this PR? I am not confident in the naming. Thanks.

@dzhuang dzhuang force-pushed the allow_user_defined_csv_codec branch 5 times, most recently from 842d8ca to 2c6a17f Compare February 13, 2018 05:12
@dzhuang dzhuang force-pushed the allow_user_defined_csv_codec branch from 2c6a17f to d08c457 Compare February 13, 2018 06:40
course/grades.py Outdated
initial=0,
min_value=0,
max_value=100 * MAX_EXTRA_CREDIT_FACTOR,
label=_("Minimum points"),
Copy link
Owner

Choose a reason for hiding this comment

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

Could use a help text. Don't know what it does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All done.

course/grades.py Outdated
min_value=0,
initial=0,
max_value=2,
label=_("Round Digits"),
Copy link
Owner

Choose a reason for hiding this comment

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

Help text.

Copy link
Owner

Choose a reason for hiding this comment

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

Or maybe change label to "Round point counts to N digits" and "Round percentages to N digits". Also, why max out at 2?

Copy link
Contributor Author

@dzhuang dzhuang Feb 14, 2018

Choose a reason for hiding this comment

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

I previously set that to 4, and I found (in tests) the value are all rounded to 2 digits already, had thought that's preset behavior. Since you commented on this, I'll check that.

course/grades.py Outdated
required=False,
initial=False,
label=_("Use 0 point for grade state `NONE`, which possibly "
"means the opptunity had not been graded."),
Copy link
Owner

Choose a reason for hiding this comment

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

Why "possibly"?

Copy link
Contributor Author

@dzhuang dzhuang Feb 14, 2018

Choose a reason for hiding this comment

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

That's why I opened #457 . I think it's quite confusing. both not-graded-yet and graded can result in None. Also, those participations who didn't open a session for the grading opportunity also get None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just opened an issue #461 about NONE .

course/grades.py Outdated
self.fields["exclude_tas"] = forms.BooleanField(
required=False,
initial=True,
label=_("Exclude Grades of Teaching assistants"),
Copy link
Owner

Choose a reason for hiding this comment

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

"Teaching assistant" and "Instructor" are not concepts in Relate. That means you may not use them in any UI. (They used to be, but they no longer are.) Right now, there are just arbitrarily-defined roles. The only thing available is a "permission" that says whether a role's/participant's grades are to be included in the grades.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok.

course/utils.py Outdated
@@ -1320,4 +1324,215 @@ def _render_notebook_from_source(

# }}}


class RelateCsvHandler(object):
# Tests ref tests.template_backends.test_django.DjangoTemplatesTests
Copy link
Owner

Choose a reason for hiding this comment

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

I have no idea what this does and why it belongs here.

Copy link
Owner

Choose a reason for hiding this comment

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

Why is this not in checks.py?

Copy link
Owner

Choose a reason for hiding this comment

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

It could stand renaming to RelateCSVSettingsValidator or some such maybe?

Copy link
Contributor Author

@dzhuang dzhuang Feb 14, 2018

Choose a reason for hiding this comment

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

I have no idea what this does and why it belongs here.

It's something that make the a csv configuration (currently for csv export) from settings.RelateCSVSetting, by check and add some default value if not configured, and packaged some methods like generate the user attribute choice fields (in the ExportCsvForm) for csv export.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is this not in checks.py?

As mentioned above, it's functionalities are not limited to check only, do you prefer to put that in checks.py? Won't it look weird to import a function from checks.py?.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could stand renaming to RelateCSVSettingsValidator or some such maybe?

What about RelateCSVSettingsInitializer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

docstring added.

dzhuang added a commit to dzhuang/relate that referenced this pull request Feb 14, 2018
@dzhuang dzhuang force-pushed the allow_user_defined_csv_codec branch from af9bd54 to 8f22e8f Compare February 14, 2018 10:03
@dzhuang
Copy link
Contributor Author

dzhuang commented Feb 14, 2018

Updated.

)

csv_settings = RelateCSVSettingsInitializer()
Copy link
Owner

Choose a reason for hiding this comment

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

Can we do without this global variable somehow?

Copy link
Owner

Choose a reason for hiding this comment

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

(I'd much prefer a function, for example.)

Copy link
Contributor Author

@dzhuang dzhuang Feb 16, 2018

Choose a reason for hiding this comment

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

In fact, the csv_setting object created here is intended to be an app global object, since I am creating the object with its properties to be cached_properties, each of which need to be calculated only once.

However, I agree it's not elegant to use it here in this way. What about initialize the csv_settings object, i.e.,

csv_settings = RelateCSVSettingsInitializer()

in utils.py, and then import it in grades.py. Will that be better?

label=_("0 percentage for graded 'NONE'"),
help_text=string_concat(
_("Use 0 percentage for graded opportunities which have "
"`NONE` points."),
Copy link
Owner

Choose a reason for hiding this comment

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

"NONE points" reads awkwardly. Maybe "that do not currently have a defined point count."

Copy link
Contributor Author

@dzhuang dzhuang Feb 16, 2018

Choose a reason for hiding this comment

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

That's fair. I think then we should notice user if False, it will result in NONE in the csv.

help_text=_(
"If selected, grades of course staff (participations who "
"have '%(permission)s' permissions) will be excluded."
% {"permission": pperm.assign_grade}),
Copy link
Owner

Choose a reason for hiding this comment

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

Why not base this on the existing pperm.included_in_grade_statistics?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair.

@dzhuang
Copy link
Contributor Author

dzhuang commented Feb 16, 2018

I felt this PR should be WIP before #461 is resolved, so that we can full test grade status and gradebook behavior.

@dzhuang dzhuang changed the title Optimize gradebook csv export/import [WIP]Optimize gradebook csv export/import Feb 16, 2018
Base automatically changed from master to main March 8, 2021 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants