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

Fix non-revealed chapters in ModuleView #1273

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

PasiSa
Copy link
Contributor

@PasiSa PasiSa commented Sep 20, 2023

Fixes #1266

Slightly modified from similar commit earlier pushed to master (#1267 )

Description

What?

[ANSWER HERE]

Why?

[ANSWER HERE]

How?

[ANSWER HERE]

Fixes #

Testing

Remember to add or update unit tests for new features and changes.

What type of test did you run?

  • Accessibility test using the WAVE extension.
  • Django unit tests.
  • Selenium tests.
  • Other test. (Add a description below)
  • Manual testing.

[ADD A DESCRIPTION ABOUT WHAT YOU TESTED MANUALLY]

Did you test the changes in

  • Chrome
  • Firefox
  • This pull request cannot be tested in the browser.

Think of what is affected by these changes and could become broken

Translation

Programming style

  • Did you follow our style guides?
  • Did you use Python type hinting in all functions that you added or edited? (type hints for function parameters and return values)

Have you updated the README or other relevant documentation?

  • documents inside the doc directory.
  • README.md.
  • Aplus Manual.
  • Other documentation (mention below which documentation).

Is it Done?

  • Reviewer has finished the code review
  • After the review, the developer has made changes accordingly
  • Customer/Teacher has accepted the implementation of the feature

Clean up your git commit history before submitting the pull request!

@markkuriekkinen markkuriekkinen self-assigned this Sep 20, 2023
@markkuriekkinen markkuriekkinen self-requested a review September 20, 2023 20:02
Copy link
Contributor

@markkuriekkinen markkuriekkinen left a comment

Choose a reason for hiding this comment

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

Thanks!

@markkuriekkinen markkuriekkinen merged commit 0e74906 into apluslms:v1.20_stable Sep 20, 2023
@@ -67,11 +68,12 @@ def get_resource_objects(self):
self.url_without_language = remove_query_param_from_url(self.request.get_full_path(), 'hl')
self.query_language = None
self.user_language = None
self.points = CachedPoints(self.instance, self.request.user, self.content, self.is_course_staff)
Copy link
Contributor

Choose a reason for hiding this comment

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

@PasiSa this crashes in the interactions between A+ and Gitmanager.
self.request.user is a GraderUser, but CachedPoints does not work with GraderUser.

aplus-plus-1        | [2023-09-21 00:45:45,023: ERROR/log] Internal Server Error: /api/v2/courses/2/send_mail/
aplus-plus-1        | Traceback (most recent call last):
aplus-plus-1        |   File "/usr/local/lib/python3.9/dist-packages/rest_framework/views.py", line 497, in dispatch
aplus-plus-1        |     self.initial(request, *args, **kwargs)
aplus-plus-1        |   File "/srv/aplus/authorization/api/mixins.py", line 14, in initial
aplus-plus-1        |     self.get_resource_objects()
aplus-plus-1        |   File "/srv/aplus/course/viewbase.py", line 71, in get_resource_objects
aplus-plus-1        |     self.points = CachedPoints(self.instance, self.request.user, self.content, self.is_course_staff)
aplus-plus-1        |   File "/srv/aplus/exercise/cache/points.py", line 69, in __init__
aplus-plus-1        |     super().__init__(course_instance, user)
aplus-plus-1        |   File "/srv/aplus/lib/cache/cached.py", line 33, in __init__
aplus-plus-1        |     self.data = self.__get_data()
aplus-plus-1        |   File "/srv/aplus/lib/cache/cached.py", line 61, in __get_data
aplus-plus-1        |     data = self._generate_data(*self.__models, data=data)
aplus-plus-1        |   File "/srv/aplus/exercise/cache/points.py", line 91, in _generate_data
aplus-plus-1        |     user.userprofile.submissions
aplus-plus-1        | AttributeError: 'GraderUser' object has no attribute 'submissions'

Copy link
Contributor

Choose a reason for hiding this comment

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

My workaround: a8e76f7

markkuriekkinen added a commit that referenced this pull request Sep 20, 2023
Commit 0e74906 (#1273) introduced
a crash when `GraderUser` accesses any course page or API.
The commit added a `CachedPoints` instance variable to
`CourseInstanceBaseMixin`, but `CachedPoints` crashes when it is
initialized with the `GraderUser`. `CachedPoints` does not crash
with `AnonymousUser`, thus it is used instead of `GraderUser`
to work around the crash.

In the master branch, the commit
0c0de05 is similar to 0e74906,
but there is no crash due to the cache changes in #1231.
ihalaij1 pushed a commit to ihalaij1/a-plus that referenced this pull request Dec 22, 2023
Commit 0e74906 (apluslms#1273) introduced
a crash when `GraderUser` accesses any course page or API.
The commit added a `CachedPoints` instance variable to
`CourseInstanceBaseMixin`, but `CachedPoints` crashes when it is
initialized with the `GraderUser`. `CachedPoints` does not crash
with `AnonymousUser`, thus it is used instead of `GraderUser`
to work around the crash.

In the master branch, the commit
0c0de05 is similar to 0e74906,
but there is no crash due to the cache changes in apluslms#1231.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants