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

feat: [AXM-297] Add progress to assignments in BlocksInfoInCourseView API #2546

Conversation

KyryloKireiev
Copy link

Description
Add assignments_progress field to sequential info in BlocksInfoInCourseView API.

"assignment_progress": {
            "assignment_type": "Exam 2",
            "num_points_earned": 3.0,
            "num_points_possible": 3.0
        }

YouTrack

https://youtrack.raccoongang.com/issue/AXM-297

@KyryloKireiev KyryloKireiev self-assigned this Apr 24, 2024
from openedx.core.djangoapps.content.block_structure.api import get_block_structure_manager


def calculate_progress(user, course_id, cache_timeout):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add typing here?

"""
Extends sequential xblock info with assignment's name and progress.
"""
subsection_grades = calculate_progress(requested_user, course_id, BLOCK_STRUCTURE_CACHE_TIMEOUT)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably it could be wrapped in the try except with potential log to debug easier

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I wrapped into try except calculate_progress function's logic in utils file

Comment on lines 407 to 421
if grade:
points_earned = (
grade.graded_total.earned
if grades_with_locations[block_id].graded
else 0
)
points_possible = (
grade.graded_total.possible
if grades_with_locations[block_id].graded
else 0
)
assignment_type = grade.format
else:
points_earned, points_possible = 0, 0
assignment_type = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if grade:
points_earned = (
grade.graded_total.earned
if grades_with_locations[block_id].graded
else 0
)
points_possible = (
grade.graded_total.possible
if grades_with_locations[block_id].graded
else 0
)
assignment_type = grade.format
else:
points_earned, points_possible = 0, 0
assignment_type = None
if grade:
graded_total = grade.graded_total if grade.graded else None
points_earned = graded_total.earned if graded_total else 0
points_possible = graded_total.possible if graded_total else 0
assignment_type = grade.format
else:
points_earned, points_possible, assignment_type = 0, 0, None

Please, check if this fits to improve readability

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it's more readable and works correctly. I took these changes

@monteri monteri merged commit 8afbc54 into glugovgrglib/add_course_access_to_mobile_info_api Apr 25, 2024
64 checks passed
GlugovGrGlib pushed a commit that referenced this pull request May 2, 2024
… API (#2546)

* feat: [AXM-297, AXM-310] Add progress to assignments and total course progress

* feat: [AXM-297] Add progress to assignments

* style: [AXM-297] Try to fix linters (add docstrings)

* refactor: [AXM-297] Add typing, refactor methods
monteri pushed a commit that referenced this pull request May 22, 2024
… API (#2546)

* feat: [AXM-297, AXM-310] Add progress to assignments and total course progress

* feat: [AXM-297] Add progress to assignments

* style: [AXM-297] Try to fix linters (add docstrings)

* refactor: [AXM-297] Add typing, refactor methods
KyryloKireiev added a commit that referenced this pull request May 27, 2024
… API (#2546)

* feat: [AXM-297, AXM-310] Add progress to assignments and total course progress

* feat: [AXM-297] Add progress to assignments

* style: [AXM-297] Try to fix linters (add docstrings)

* refactor: [AXM-297] Add typing, refactor methods
NiedielnitsevIvan pushed a commit that referenced this pull request May 27, 2024
… API (#2546)

* feat: [AXM-297, AXM-310] Add progress to assignments and total course progress

* feat: [AXM-297] Add progress to assignments

* style: [AXM-297] Try to fix linters (add docstrings)

* refactor: [AXM-297] Add typing, refactor methods
NiedielnitsevIvan pushed a commit that referenced this pull request Jun 10, 2024
… API (#2546)

* feat: [AXM-297, AXM-310] Add progress to assignments and total course progress

* feat: [AXM-297] Add progress to assignments

* style: [AXM-297] Try to fix linters (add docstrings)

* refactor: [AXM-297] Add typing, refactor methods
KyryloKireiev added a commit that referenced this pull request Jun 21, 2024
… API (#2546)

* feat: [AXM-297, AXM-310] Add progress to assignments and total course progress

* feat: [AXM-297] Add progress to assignments

* style: [AXM-297] Try to fix linters (add docstrings)

* refactor: [AXM-297] Add typing, refactor methods
KyryloKireiev added a commit that referenced this pull request Jun 21, 2024
… API (#2546)

* feat: [AXM-297, AXM-310] Add progress to assignments and total course progress

* feat: [AXM-297] Add progress to assignments

* style: [AXM-297] Try to fix linters (add docstrings)

* refactor: [AXM-297] Add typing, refactor methods
KyryloKireiev added a commit that referenced this pull request Jun 25, 2024
… API (#2546)

* feat: [AXM-297, AXM-310] Add progress to assignments and total course progress

* feat: [AXM-297] Add progress to assignments

* style: [AXM-297] Try to fix linters (add docstrings)

* refactor: [AXM-297] Add typing, refactor methods
KyryloKireiev added a commit that referenced this pull request Jun 26, 2024
… API (#2546)

* feat: [AXM-297, AXM-310] Add progress to assignments and total course progress

* feat: [AXM-297] Add progress to assignments

* style: [AXM-297] Try to fix linters (add docstrings)

* refactor: [AXM-297] Add typing, refactor methods
KyryloKireiev added a commit that referenced this pull request Jul 1, 2024
… API (#2546)

* feat: [AXM-297, AXM-310] Add progress to assignments and total course progress

* feat: [AXM-297] Add progress to assignments

* style: [AXM-297] Try to fix linters (add docstrings)

* refactor: [AXM-297] Add typing, refactor methods
ruzniaievdm pushed a commit that referenced this pull request Jul 11, 2024
…urses on dashboard view (openedx#34848)

* feat: [AXM-24] Update structure for course enrollments API (#2515)
---------
Co-authored-by: Glib Glugovskiy <[email protected]>

* feat: [AXM-53] add assertions for primary course (#2522)
---------
Co-authored-by: monteri <[email protected]>

* feat: [AXM-297] Add progress to assignments in BlocksInfoInCourseView API (#2546)
---------
Co-authored-by: NiedielnitsevIvan <[email protected]>
Co-authored-by: Glib Glugovskiy <[email protected]>
Co-authored-by: monteri <[email protected]>
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