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: allow to prefetch xblock aside fields #33554

Closed
wants to merge 1 commit into from

Conversation

Ian2012
Copy link
Contributor

@Ian2012 Ian2012 commented Oct 20, 2023

Description

This PR fixes a compatibility issue between XBlockAside and the scope user_summary_state in which the fields of the asides were not cached.

This PR updates the implementation of the field_to_cache method to also read aside fields information

Testing instructions

  • Install feedbackxblock as an editable requirement and add checkout this PR: feat: xblock aside FeedbackXBlock#31 (it creates an aside for the feedback xblock)
  • Go to the admin and enable XBlock Asides in http://local.overhang.io:8000/admin/lms_xblock/xblockasidesconfig/
  • Before this change, the XBlock runtime will try to create a record in the courseware user summary table and will succeed the first time and fail in later attempts as the record already exists and it's not found in the cache.
  • After this change, the XBlock runtime will be able to cache the fields and all requests will work.

Author concern: After this fix, another issue was raised about invalid scopes after using the handlers. This makes me question if is this was the right approach and this contribution requires a different approach

@openedx-webhooks
Copy link

openedx-webhooks commented Oct 20, 2023

Thanks for the pull request, @Ian2012! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 20, 2023
return scope_map

try:
block = blocks[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why only cache from the first block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the main actor here is not the XBlock itself but the asides that will be rendered alongside as those are not part of the course, but are generated dynamically.

Copy link
Member

Choose a reason for hiding this comment

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

isn't it problematic to cache the user_state_summary fields of the aside xblock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, but I think this cache is per request, so every time a user requests the course content or calls an XBlock handler, the cache is regenerated.

This cache is read-write thought so being able to read the content will allow to write to it

Copy link
Contributor

Choose a reason for hiding this comment

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

I see so you're getting all the asides from the first block, but can't asides choose what blocks they're applied to? Is it possible that some asides would not be available on the first block but would be available on later blocks?

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 can do some local testing to verify that. It's true that asides choose on which blocks to render, but I'm not sure if this workflow applies to the function get_aside_from_xblock.

It seems this function always returns an aside xblock instance:

https://github.com/eduNEXT/edx-platform/blob/09a652379276551ede6070a33a7a15a65e674d4b/xmodule/modulestore/split_mongo/caching_descriptor_system.py#L420-L422

https://github.com/eduNEXT/edx-platform/blob/09a652379276551ede6070a33a7a15a65e674d4b/xmodule/modulestore/split_mongo/caching_descriptor_system.py#L403-L407

@Ian2012 Ian2012 force-pushed the cag/xblock-aside-fixes branch 2 times, most recently from 747d4b8 to deccb37 Compare October 25, 2023 15:43
@Ian2012 Ian2012 force-pushed the cag/xblock-aside-fixes branch from deccb37 to 0388ded Compare October 31, 2023 14:42
@Ian2012 Ian2012 marked this pull request as ready for review October 31, 2023 14:42
@feanil feanil requested a review from ormsbee November 7, 2023 14:21
@ormsbee
Copy link
Contributor

ormsbee commented Nov 7, 2023

@Agrendalath: is this something you might have time to review?

@Agrendalath
Copy link
Member

@ormsbee, sure, I can review this next week.

@feanil
Copy link
Contributor

feanil commented Nov 16, 2023

@Agrendalath did you get a chance to review this yet or did it need to be pushed out a bit?

@Agrendalath
Copy link
Member

Agrendalath commented Nov 17, 2023

@Ian2012, I tested this on a fresh devstack. After following your instructions and adding a single FeedbackXBlock, I can no longer use courseware pages in LMS. Checking out the FeedbackXBlock on the master branch fixes the issue.

Traceback:

2023-11-17 11:18:26,722 ERROR 763 [lms.djangoapps.courseware.model_data] [user 3] [ip 192.168.65.1] model_data.py:230 - Saving field 'vote_aggregate' failed
Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
MySQLdb.IntegrityError: (1062, "Duplicate entry 'aside-usage-v2:block-v1$:edX+DemoX+Demo_Course+type@vertical+blo' for key 'courseware_xmoduleuserstatesummaryfield.courseware_xmoduleuserst_usage_id_field_name_e4e34c44_uniq'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 223, in set_many
    field_object.save(force_insert=True)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 739, in save
    self.save_base(using=using, force_insert=force_insert,
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 776, in save_base
    updated = self._save_table(
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 881, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 919, in _do_insert
    return manager._insert(
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/query.py", line 1270, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1416, in execute_sql
    cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 252, in execute
    return self._record(super().execute, sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 177, in _record
    return method(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
django.db.utils.IntegrityError: (1062, "Duplicate entry 'aside-usage-v2:block-v1$:edX+DemoX+Demo_Course+type@vertical+blo' for key 'courseware_xmoduleuserstatesummaryfield.courseware_xmoduleuserst_usage_id_field_name_e4e34c44_uniq'")
2023-11-17 11:18:26,723 ERROR 763 [lms.djangoapps.courseware.model_data] [user 3] [ip 192.168.65.1] model_data.py:854 - Error saving fields ['vote_aggregate']
Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
MySQLdb.IntegrityError: (1062, "Duplicate entry 'aside-usage-v2:block-v1$:edX+DemoX+Demo_Course+type@vertical+blo' for key 'courseware_xmoduleuserstatesummaryfield.courseware_xmoduleuserst_usage_id_field_name_e4e34c44_uniq'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 223, in set_many
    field_object.save(force_insert=True)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 739, in save
    self.save_base(using=using, force_insert=force_insert,
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 776, in save_base
    updated = self._save_table(
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 881, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 919, in _do_insert
    return manager._insert(
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/query.py", line 1270, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1416, in execute_sql
    cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 252, in execute
    return self._record(super().execute, sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 177, in _record
    return method(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
django.db.utils.IntegrityError: (1062, "Duplicate entry 'aside-usage-v2:block-v1$:edX+DemoX+Demo_Course+type@vertical+blo' for key 'courseware_xmoduleuserstatesummaryfield.courseware_xmoduleuserst_usage_id_field_name_e4e34c44_uniq'")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 849, in set_many
    self.cache[scope].set_many(set_many_data)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 231, in set_many
    raise KeyValueMultiSaveError(saved_fields)  # lint-amnesty, pylint: disable=raise-missing-from
xblock.exceptions.KeyValueMultiSaveError
2023-11-17 11:18:26,724 ERROR 763 [root] [user None] [ip None] signals.py:22 - Uncaught exception from None
Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
MySQLdb.IntegrityError: (1062, "Duplicate entry 'aside-usage-v2:block-v1$:edX+DemoX+Demo_Course+type@vertical+blo' for key 'courseware_xmoduleuserstatesummaryfield.courseware_xmoduleuserst_usage_id_field_name_e4e34c44_uniq'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 223, in set_many
    field_object.save(force_insert=True)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 739, in save
    self.save_base(using=using, force_insert=force_insert,
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 776, in save_base
    updated = self._save_table(
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 881, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 919, in _do_insert
    return manager._insert(
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/query.py", line 1270, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1416, in execute_sql
    cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 252, in execute
    return self._record(super().execute, sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 177, in _record
    return method(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
django.db.utils.IntegrityError: (1062, "Duplicate entry 'aside-usage-v2:block-v1$:edX+DemoX+Demo_Course+type@vertical+blo' for key 'courseware_xmoduleuserstatesummaryfield.courseware_xmoduleuserst_usage_id_field_name_e4e34c44_uniq'")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 849, in set_many
    self.cache[scope].set_many(set_many_data)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 231, in set_many
    raise KeyValueMultiSaveError(saved_fields)  # lint-amnesty, pylint: disable=raise-missing-from
xblock.exceptions.KeyValueMultiSaveError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/mixins.py", line 265, in force_save_fields
    self._field_data.set_many(self, fields_to_save_json)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/field_data.py", line 164, in set_many
    field_data.set_many(block, new_update_dict)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 226, in set_many
    self._kvs.set_many(updated_dict)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 135, in set_many
    self._field_data_cache.set_many(kv_dict)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 855, in set_many
    raise KeyValueMultiSaveError(saved_fields + exc.saved_field_names)  # lint-amnesty, pylint: disable=raise-missing-from
xblock.exceptions.KeyValueMultiSaveError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/decorators/cache.py", line 31, in _cache_controlled
    response = viewfunc(request, *args, **kw)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/edx-platform/common/djangoapps/util/views.py", line 43, in inner
    response = view_func(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/edx-platform/openedx/features/enterprise_support/api.py", line 367, in inner
    return view_func(request, course_id, *args, **kwargs)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 152, in get
    return CourseTabView.handle_exceptions(request, self.course_key, self.course, exception)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 150, in get
    return self.render(request)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 244, in render
    return render_to_response('courseware/courseware.html', self._create_courseware_context(request))
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 479, in _create_courseware_context
    courseware_context['fragment'] = self.section.render(self.view, section_context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/core.py", line 198, in render
    return self.runtime.render(self, view, context)
  File "/edx/app/edxapp/edx-platform/xmodule/x_module.py", line 997, in render
    return super().render(block, view_name, context=context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 847, in render
    frag = view_fn(context)
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 460, in student_view
    return self._student_or_public_view(context, prereq_met, prereq_meta_info, banner_text)
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 587, in _student_or_public_view
    params = self._get_render_metadata(context, children, prereq_met, prereq_meta_info, banner_text, view, fragment)  # lint-amnesty, pylint: disable=line-too-long
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 553, in _get_render_metadata
    blocks = self._render_student_view_for_blocks(context, children, fragment, view) if prereq_met else []
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 778, in _render_student_view_for_blocks
    rendered_block = block.render(view, context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/core.py", line 198, in render
    return self.runtime.render(self, view, context)
  File "/edx/app/edxapp/edx-platform/xmodule/x_module.py", line 997, in render
    return super().render(block, view_name, context=context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 852, in render
    return self.render_asides(block, view_name, updated_frag, context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 1038, in render_asides
    return self.layout_asides(block, context, frag, view_name, aside_frag_fns)
  File "/edx/app/edxapp/edx-platform/xmodule/x_module.py", line 1522, in layout_asides
    return super().layout_asides(block, context, frag, view_name, aside_frag_fns)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 1059, in layout_asides
    aside.save()
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/mixins.py", line 250, in save
    self.force_save_fields(fields_to_save)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/mixins.py", line 275, in force_save_fields
    raise XBlockSaveError(saved_fields, fields, msg)  # pylint: disable= raise-missing-from
xblock.exceptions.XBlockSaveError
Internal Server Error: /courses/course-v1:edX+DemoX+Demo_Course/courseware/fe3754f5d2c449f8a91a2229c11052c7/97b96cda696e4ca19da99d6480df4394/
Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
MySQLdb.IntegrityError: (1062, "Duplicate entry 'aside-usage-v2:block-v1$:edX+DemoX+Demo_Course+type@vertical+blo' for key 'courseware_xmoduleuserstatesummaryfield.courseware_xmoduleuserst_usage_id_field_name_e4e34c44_uniq'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 223, in set_many
    field_object.save(force_insert=True)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 739, in save
    self.save_base(using=using, force_insert=force_insert,
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 776, in save_base
    updated = self._save_table(
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 881, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 919, in _do_insert
    return manager._insert(
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/query.py", line 1270, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1416, in execute_sql
    cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 252, in execute
    return self._record(super().execute, sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 177, in _record
    return method(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
django.db.utils.IntegrityError: (1062, "Duplicate entry 'aside-usage-v2:block-v1$:edX+DemoX+Demo_Course+type@vertical+blo' for key 'courseware_xmoduleuserstatesummaryfield.courseware_xmoduleuserst_usage_id_field_name_e4e34c44_uniq'")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 849, in set_many
    self.cache[scope].set_many(set_many_data)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 231, in set_many
    raise KeyValueMultiSaveError(saved_fields)  # lint-amnesty, pylint: disable=raise-missing-from
xblock.exceptions.KeyValueMultiSaveError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/mixins.py", line 265, in force_save_fields
    self._field_data.set_many(self, fields_to_save_json)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/field_data.py", line 164, in set_many
    field_data.set_many(block, new_update_dict)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 226, in set_many
    self._kvs.set_many(updated_dict)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 135, in set_many
    self._field_data_cache.set_many(kv_dict)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 855, in set_many
    raise KeyValueMultiSaveError(saved_fields + exc.saved_field_names)  # lint-amnesty, pylint: disable=raise-missing-from
xblock.exceptions.KeyValueMultiSaveError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/decorators/cache.py", line 31, in _cache_controlled
    response = viewfunc(request, *args, **kw)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/edx-platform/common/djangoapps/util/views.py", line 43, in inner
    response = view_func(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/edx-platform/openedx/features/enterprise_support/api.py", line 367, in inner
    return view_func(request, course_id, *args, **kwargs)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 152, in get
    return CourseTabView.handle_exceptions(request, self.course_key, self.course, exception)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 150, in get
    return self.render(request)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 244, in render
    return render_to_response('courseware/courseware.html', self._create_courseware_context(request))
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 479, in _create_courseware_context
    courseware_context['fragment'] = self.section.render(self.view, section_context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/core.py", line 198, in render
    return self.runtime.render(self, view, context)
  File "/edx/app/edxapp/edx-platform/xmodule/x_module.py", line 997, in render
    return super().render(block, view_name, context=context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 847, in render
    frag = view_fn(context)
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 460, in student_view
    return self._student_or_public_view(context, prereq_met, prereq_meta_info, banner_text)
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 587, in _student_or_public_view
    params = self._get_render_metadata(context, children, prereq_met, prereq_meta_info, banner_text, view, fragment)  # lint-amnesty, pylint: disable=line-too-long
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 553, in _get_render_metadata
    blocks = self._render_student_view_for_blocks(context, children, fragment, view) if prereq_met else []
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 778, in _render_student_view_for_blocks
    rendered_block = block.render(view, context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/core.py", line 198, in render
    return self.runtime.render(self, view, context)
  File "/edx/app/edxapp/edx-platform/xmodule/x_module.py", line 997, in render
    return super().render(block, view_name, context=context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 852, in render
    return self.render_asides(block, view_name, updated_frag, context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 1038, in render_asides
    return self.layout_asides(block, context, frag, view_name, aside_frag_fns)
  File "/edx/app/edxapp/edx-platform/xmodule/x_module.py", line 1522, in layout_asides
    return super().layout_asides(block, context, frag, view_name, aside_frag_fns)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 1059, in layout_asides
    aside.save()
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/mixins.py", line 250, in save
    self.force_save_fields(fields_to_save)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/mixins.py", line 275, in force_save_fields
    raise XBlockSaveError(saved_fields, fields, msg)  # pylint: disable= raise-missing-from
xblock.exceptions.XBlockSaveError
2023-11-17 11:18:26,814 ERROR 763 [django.request] [user None] [ip None] log.py:224 - Internal Server Error: /courses/course-v1:edX+DemoX+Demo_Course/courseware/fe3754f5d2c449f8a91a2229c11052c7/97b96cda696e4ca19da99d6480df4394/
Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
MySQLdb.IntegrityError: (1062, "Duplicate entry 'aside-usage-v2:block-v1$:edX+DemoX+Demo_Course+type@vertical+blo' for key 'courseware_xmoduleuserstatesummaryfield.courseware_xmoduleuserst_usage_id_field_name_e4e34c44_uniq'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 223, in set_many
    field_object.save(force_insert=True)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 739, in save
    self.save_base(using=using, force_insert=force_insert,
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 776, in save_base
    updated = self._save_table(
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 881, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 919, in _do_insert
    return manager._insert(
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/query.py", line 1270, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1416, in execute_sql
    cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 252, in execute
    return self._record(super().execute, sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 177, in _record
    return method(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
django.db.utils.IntegrityError: (1062, "Duplicate entry 'aside-usage-v2:block-v1$:edX+DemoX+Demo_Course+type@vertical+blo' for key 'courseware_xmoduleuserstatesummaryfield.courseware_xmoduleuserst_usage_id_field_name_e4e34c44_uniq'")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 849, in set_many
    self.cache[scope].set_many(set_many_data)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 231, in set_many
    raise KeyValueMultiSaveError(saved_fields)  # lint-amnesty, pylint: disable=raise-missing-from
xblock.exceptions.KeyValueMultiSaveError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/mixins.py", line 265, in force_save_fields
    self._field_data.set_many(self, fields_to_save_json)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/field_data.py", line 164, in set_many
    field_data.set_many(block, new_update_dict)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 226, in set_many
    self._kvs.set_many(updated_dict)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 135, in set_many
    self._field_data_cache.set_many(kv_dict)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 855, in set_many
    raise KeyValueMultiSaveError(saved_fields + exc.saved_field_names)  # lint-amnesty, pylint: disable=raise-missing-from
xblock.exceptions.KeyValueMultiSaveError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/decorators/cache.py", line 31, in _cache_controlled
    response = viewfunc(request, *args, **kw)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/edx-platform/common/djangoapps/util/views.py", line 43, in inner
    response = view_func(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/edx/app/edxapp/edx-platform/openedx/features/enterprise_support/api.py", line 367, in inner
    return view_func(request, course_id, *args, **kwargs)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 152, in get
    return CourseTabView.handle_exceptions(request, self.course_key, self.course, exception)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 150, in get
    return self.render(request)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 244, in render
    return render_to_response('courseware/courseware.html', self._create_courseware_context(request))
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/index.py", line 479, in _create_courseware_context
    courseware_context['fragment'] = self.section.render(self.view, section_context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/core.py", line 198, in render
    return self.runtime.render(self, view, context)
  File "/edx/app/edxapp/edx-platform/xmodule/x_module.py", line 997, in render
    return super().render(block, view_name, context=context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 847, in render
    frag = view_fn(context)
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 460, in student_view
    return self._student_or_public_view(context, prereq_met, prereq_meta_info, banner_text)
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 587, in _student_or_public_view
    params = self._get_render_metadata(context, children, prereq_met, prereq_meta_info, banner_text, view, fragment)  # lint-amnesty, pylint: disable=line-too-long
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 553, in _get_render_metadata
    blocks = self._render_student_view_for_blocks(context, children, fragment, view) if prereq_met else []
  File "/edx/app/edxapp/edx-platform/xmodule/seq_block.py", line 778, in _render_student_view_for_blocks
    rendered_block = block.render(view, context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/core.py", line 198, in render
    return self.runtime.render(self, view, context)
  File "/edx/app/edxapp/edx-platform/xmodule/x_module.py", line 997, in render
    return super().render(block, view_name, context=context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 852, in render
    return self.render_asides(block, view_name, updated_frag, context)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 1038, in render_asides
    return self.layout_asides(block, context, frag, view_name, aside_frag_fns)
  File "/edx/app/edxapp/edx-platform/xmodule/x_module.py", line 1522, in layout_asides
    return super().layout_asides(block, context, frag, view_name, aside_frag_fns)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 1059, in layout_asides
    aside.save()
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/mixins.py", line 250, in save
    self.force_save_fields(fields_to_save)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/mixins.py", line 275, in force_save_fields
    raise XBlockSaveError(saved_fields, fields, msg)  # pylint: disable= raise-missing-from
xblock.exceptions.XBlockSaveError

cc: @feanil

@Ian2012
Copy link
Contributor Author

Ian2012 commented Nov 17, 2023

@Agrendalath This is the issue commented here:

Author concern: After this fix, another issue was raised about invalid scopes after using the handlers. This makes me question if is this was the right approach and this contribution requires a different approach

What do you think we need to fix to handle those cases?

@Agrendalath
Copy link
Member

Author concern: After this fix, another issue was raised about invalid scopes after using the handlers. This makes me question if is this was the right approach and this contribution requires a different approach

What do you think we need to fix to handle those cases?

@Ian2012, unfortunately, I haven't worked with XBlock Asides enough to answer this question properly. @bradenmacdonald, @ormsbee, do you have any ideas?

@bradenmacdonald
Copy link
Contributor

@Agrendalath I've never worked with XBlock asides at all unfortunately, and am not sure how to answer that. I've never even seen an aside as far as I know.

@Ian2012
Copy link
Contributor Author

Ian2012 commented Jan 24, 2024

@feanil I will close this PR as I don't have the time to maintain it and to research if this is the right contribution to support XBlockAside fields. Let's hope someone else take this work

@Ian2012 Ian2012 closed this Jan 24, 2024
@openedx-webhooks
Copy link

@Ian2012 Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future.

1 similar comment
@openedx-webhooks
Copy link

@Ian2012 Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants