Skip to content

Instantly share code, notes, and snippets.

View efischer19's full-sized avatar

Eric Fischer efischer19

View GitHub Profile
@efischer19
efischer19 / gist:f4597d228df6243e8b504ef6d240b1f1
Created April 7, 2017 19:29
grades work for invisible courses
(Pdb) from courseware.access import has_access
(Pdb) from lms.djangoapps.grades.new.course_data import CourseData
(Pdb) has_access(self.request.user, 'load', self.course)
AccessResponse(True, None, None, None)
(Pdb) self.course.visible_to_staff_only = True
(Pdb) has_access(self.request.user, 'load', self.course)
AccessResponse(False, 'not_visible_to_user', 'Course is not visible to this user', u'You do not have access to this course')
# Instantiate a and b identically
(Pdb) course_data_a = CourseData(self.user, course_key=self.factory_course.id)
(Pdb) course_data_b = CourseData(self.user, course_key=self.factory_course.id)
# Access a.loction, then b.course, then b.location. Just accesses!
# Also note that the location properties are represented slightly differently (SlashSeparatedCourseKey vs CourseLocator), but they compare as equal
(Pdb) course_data_a.location
BlockUsageLocator(SlashSeparatedCourseKey('org.1', 'course_1', 'Run_1', None, None), 'course', 'Run_1')
(Pdb) course_data_b.course
CourseDescriptorWithMixins(CombinedSystem(None, CachingDescriptorSystem(<xmodule.modulestore.mongo.draft.DraftModuleStore object at 0x7effd58f68d0>, u'org.1/course_1/Run_1', [u'i4x://org.1/course_1/course/Run_1'], <class 'xmodule.raw_module.RawDescriptor'>, [])), KvsFieldData(MongoKeyValueStore({u'wiki_slug': u'course_1'}, None, [], {u'tabs': [{u'course_staff_only': False, u'type': u'course_info', u'name': u'Home'}, {u'course_staff_only': False, u'type
@efischer19
efischer19 / devstack_scripts.txt
Created March 22, 2017 19:50
Devstack reinstallation
ericfischer@dhcp-18-189-111-194:~/scripts$ cat readme.txt
First, reset devstack:
. ./reset_devstack.sh
Then, install ora2 and copy some files into devstack:
. ./setup_devstack.sh
Then, install the newly cloned src repos locally:
vagrant ssh
sudo su edxapp
./ora2_reinstall.sh
exit
@efischer19
efischer19 / demo.txt
Created February 9, 2017 16:47
How to check on edxapp_worker
To ensure worker process are running:
[efischer19-sandbox] efischer19@efischer19 i-0a87e264bf73f6be1:~$ /edx/bin/supervisorctl
...
edxapp_worker:cms_default_1 RUNNING pid 9300, uptime 6 days, 22:12:52
edxapp_worker:cms_high_1 RUNNING pid 9298, uptime 6 days, 22:12:52
edxapp_worker:cms_low_1 RUNNING pid 9296, uptime 6 days, 22:12:52
edxapp_worker:lms_default_1 RUNNING pid 9299, uptime 6 days, 22:12:52
edxapp_worker:lms_grades_1 RUNNING pid 9302, uptime 6 days, 22:12:52
edxapp_worker:lms_high_1 RUNNING pid 9303, uptime 6 days, 22:12:52
edxapp_worker:lms_high_mem_1 RUNNING pid 9297, uptime 6 days, 22:12:52
edxapp@precise64:~/edx-platform$ paver test_acceptance -s lms --extra_args="lms/djangoapps/courseware/features/lti.feature" --fasttest
---> pavelib.acceptance_test.test_acceptance
---> pavelib.prereqs.install_prereqs
---> pavelib.prereqs.install_node_prereqs
Node prereqs unchanged, skipping...
---> pavelib.prereqs.install_python_prereqs
---> pavelib.prereqs.uninstall_python_packages
Python uninstalls unchanged, skipping...
Python prereqs unchanged, skipping...
---> pavelib.utils.test.utils.clean_reports_dir
@efischer19
efischer19 / query.txt
Created September 8, 2016 15:16
Grades queries
<truncated, everything before this is "is the feature flag enabled" and "what's the data we're persisting" queries, nothing unusual>
The get_or_create logic begins here:
QUERY = u'SAVEPOINT "s140540290041600_x457"' - PARAMS = ()
select_related (read: INNER_JOIN) is attempted here, but since the object doesn't exist yet it does us no good:
QUERY = u'SELECT "grades_persistentsubsectiongrade"."created", "grades_persistentsubsectiongrade"."modified", "grades_persistentsubsectiongrade"."id", "grades_persistentsubsectiongrade"."user_id", "grades_persistentsubsectiongrade"."course_id", "grades_persistentsubsectiongrade"."usage_key", "grades_persistentsubsectiongrade"."subtree_edited_timestamp", "grades_persistentsubsectiongrade"."course_version", "grades_persistentsubsectiongrade"."earned_all", "grades_persistentsubsectiongrade"."possible_all", "grades_persistentsubsectiongrade"."earned_graded", "grades_persistentsubsectiongrade"."possible_graded", "grades_persistentsubsectiongrade"."visible_blocks_hash", "grades_
Aug 23 20:32:05 ip-10-2-11-126 [service_variant=lms][courseware.model_data][env:prod-edx-edxapp] ERROR [ip-10-2-11-126 17804] [model_data.py:426] - Saving user state failed for kiril-me
Traceback (most recent call last):
File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/model_data.py", line 423, in set_many pending_updates
File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/user_state_client.py", line 226, in set_many student_module.save(force_update=True)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/base.py", line 734, in save force_update=force_update, update_fields=update_fields)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/base.py", line 762, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/base.py", line 827, in _save_table forced_update)
File "/edx/app/edxapp/venvs/ed
mysql> select * from grades_visibleblocksmodel;
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+
| blocks_json
edxapp@precise64:~/edx-platform$ ./manage.py lms --settings=devstack makemigrations grades
> /edx/app/edxapp/edx-platform/lms/djangoapps/grades/models.py(12)<module>()
-> class VisibleBlocksModel(models.Model):
(Pdb) w
/edx/app/edxapp/edx-platform/manage.py(112)<module>()
-> startup.run()
/edx/app/edxapp/edx-platform/lms/startup.py(54)run()
-> django.setup()
/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/__init__.py(18)setup()
-> apps.populate(settings.INSTALLED_APPS)
======================================================================
ERROR: test_student_view_data_param (lms.djangoapps.course_api.blocks.tests.test_views.TestBlocksInCourseView)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/edx/app/edxapp/edx-platform/lms/djangoapps/course_api/blocks/tests/test_views.py", line 207, in test_student_view_data_param
'student_view_data': self.BLOCK_TYPES_WITH_STUDENT_VIEW_DATA + ['chapter']
File "/edx/app/edxapp/edx-platform/lms/djangoapps/course_api/blocks/tests/test_views.py", line 72, in verify_response
response = self.client.get(url or self.url, self.query_params)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/test/client.py", line 500, in get
**extra)