Commit Graph

114 Commits

Author SHA1 Message Date
Usama Sadiq
859df03049 refactor: ran pyupgrade on lms/djangoapps/courseware (#26737) 2021-03-12 12:15:58 +05:00
usamasadiq
7bbde8f0f5 Applied pylint-amnesty 2021-02-08 13:00:22 +05:00
Jawayria
03e6a874d0 Applied pylint-amnesty to courseware 2021-02-03 21:56:24 +05:00
Feanil Patel
6e3fe00fff Fix all E303 pep8 errors. 2019-12-30 12:25:38 -05:00
Feanil Patel
9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00
Ned Batchelder
efba6e45e8 Finally import courseware properly everywhere to get rid of a warning 2019-09-26 09:40:15 -04:00
Braden MacDonald
1382bf8720 Save user state for Blockstore XBlocks in CSM, clean up CSM a bit (#21630)
This commit introduces the changes needed for XBlocks in Blockstore to save
their user state into CSM. Before this commit, all student state for Blockstore
blocks was ephemeral (in-process dict store).

Notes:

* The main risk factor of this PR is that it adds non-course keys to the
  course_id field in CSM. If any code (like analytics?) reads course keys
  directly out of CSM and doesn't have graceful handling for key types it
  doesn't recognize, it could cause an issue. With the included changes to
  opaque-keys, calling CourseKey.from_string(...) on these values will raise
  InvalidKeyError since they're not CourseKeys. (But calling
  LearningContextKey.from_string(...) will work for both course and library
  keys.)
* This commit introduces a slight regression for the Studio view of XBlocks in
  Blockstore content libraries: their state is now lost from request to request.
  I have a follow up PR to give them a proper studio-appropriate state store,
  but I want to review it separately so it doesn't hold up this PR and we can
  test this PR on its own.
2019-09-18 10:27:46 -04:00
aarif
64bd86c12c ran python-modernize and isort on files mentioned in INCR-435 2019-07-12 15:29:19 +05:00
Matthew Piatetsky
6e81c84d8b fix unicode strings in lms/ part 1 2019-02-05 15:15:02 -05:00
Eric Fischer
e18448e27d Silence deprecation warnings
https://docs.djangoproject.com/en/1.11/releases/1.10/#using-user-is-authenticated-and-user-is-anonymous-as-methods
2018-05-02 10:03:50 -04:00
rabia23
b22a656c53 EDUCATOR-1930 change log message position in set_score method 2017-12-27 13:28:49 +00:00
rabia23
dbd0468a6e EDUCATOR-1930 resolve Integrity Error exception in set score method for student module table's duplicate entry 2017-12-15 16:57:10 +00:00
Ned Batchelder
e23e3a0486 Fix a number of unused-import pylint violations 2017-11-21 19:57:06 -05:00
Brian Beggs
ca92ffe21d Remove SubfieldBase metaclass 2017-10-26 16:59:51 -04:00
Andy Armstrong
79acb5c5be Reorder LMS imports using isort 2017-06-11 21:48:06 -04:00
J. Cliff Dyer
4f6d5d9ce9 Estimate creation time for subsections grades based on timestamp of
incoming scores.

TNL-6697
2017-04-18 16:51:17 -04:00
David Ormsbee
608fceb0b5 Remove select_for_update option for FieldDataCache
We've already been ignoring the param for a long time. This just
removes it entirely.
2017-01-26 12:51:22 -05:00
David Ormsbee
5ef1e08050 Disable student state writes for crawlers.
When crawlers like edX-downloader make requests on courseware, they are
often concurrently loading many units in the same sequence. This causes
contention for the rows in courseware_studentmodule that store the
student's state for various XBlocks/XModules, most notably for the
sequence, chapter, and course -- all of which record and update user
position information when loaded.

It would be nice if we could actually remove these writes altogether
and come up with a cleaner way of keeping track of the user's position.
In general, GETs should be side-effect free. However, any such change
would break backwards compatibility, and would require close
coordination with research teams to make sure they weren't negatively
affected.

This commit identifies crawlers by user agent (CrawlersConfig model),
and blocks student state writes if a crawler is detected. FieldDataCache
writes simply become no-ops. It doesn't actually alter the rendering
of the courseware in any way -- the main impact is that the blocks
won't record your most recent position, which is meaningless for
crawlers anyway.

This can also be used as a building block for other policy we want to
define around crawlers. We just have to be mindful that this only works
with "nice" crawlers who are honest in their user agents, and that
significantly more sophisticated (and costly) measures would be
necessary to prevent crawlers that try to be even trivially sneaky.

[PERF-403]
2017-01-26 09:36:53 -05:00
Eric Fischer
5a98a90eba Use timestamps in _has_database_updated_with_new_score check
Also fixes issue where ORA grades were never updated, by including
them in this check.

TNL-5994
TNL-5995
2016-12-09 13:46:34 -05:00
Calen Pennington
fd0d69594a Upgrade to the latest version of opaque-keys 2016-12-01 13:04:31 -05:00
Nimisha Asthagiri
aa000c1a3d Support for rescoring a problem only if the new score is higher
TNL-5046
2016-10-20 15:08:54 -04:00
Nimisha Asthagiri
02e6925275 Update grades to use Block Structures 2016-06-23 20:22:31 -04:00
Dmitry Viskov
57a9839e4c LTI-9 - Bug with sending back grades for a non-leaf blocks on devstack 2016-03-30 03:38:21 +03:00
Sarina Canelake
8928e9ef19 Remove CallStackManager (PLAT-931) 2015-12-08 10:21:55 -05:00
utkjad
387303d364 Injecting call stack manager in CSM/CSMH,introducting @trackit,@wrapt, and refining implementation[PLAT-758] 2015-08-26 22:29:43 +00:00
Calen Pennington
aa374ca12a Make DjangoXBlockUserStateClient pass semantic tests
This required the following changes to the DjangoXBlockUserStateClient
semantics:

1) Changes get/get_many to return XBlockUserState tuples, rather
than state dictionaries or (block_key, state) tuples.
2) Raises DoesNotExist if get_history is called on an XBlock that has
had no data saved to it.
3) Returns XBlockUserState tuples as the results of get_history.
2015-08-01 08:13:25 -04:00
Calen Pennington
704ae7139a Add a subclass-implementation of the UserStateClient tests 2015-08-01 08:12:04 -04:00
Sven Marnach
3d7246ecc8 Allow masquerading as a specific user different from the logged in user. 2015-07-13 18:55:45 -07:00
David Ormsbee
79de77cf95 Optimize grading/progress page to reduce database queries (cache max scores).
The progress page did a number of things that make performance terrible for
courses with large numbers of problems, particularly if those problems are
customresponse CapaModule problems that need to be executed via codejail.

The grading code takes pains to not instantiate student state and execute the
problem code. If a student has answered the question, the max score is stored
in StudentModule. However, if the student hasn't attempted the question yet, we
have to run the problem code just to call .max_score() on it. This is necessary
in grade() if the student has answered other problems in the assignment (so we
can know what to divide by). This is always necessary to know in
progress_summary() because we list out every problem there. Code execution can
be especially slow if the problems need to invoke codejail.

To address this, we create a MaxScoresCache that will cache the max raw score
possible for every problem. We select the cache keys so that it will
automatically become invalidated when a new version of the course is published.

The fundamental assumption here is that a problem cannot have two different
max score values for two unscored students. A problem *can* score two students
differently such that they have different max scores. So Carlos can have 2/3 on
a problem, while Lyla gets 3/4. But if neither Carlos nor Lyla has ever
interacted with the problem (i.e. they're just seeing it on their progress
page), they must both see 0/4 -- it cannot be the case that Carlos sees 0/3 and
Lyla sees 0/4.

We used to load all student state into two separate FieldDataCache instances,
after which we do a bunch of individual queries for scored items. Part of this
split-up was done because of locking problems, but I think we might have gotten
overzealous with our manual transaction hammer.

In this commit, we consolidate all state access in grade() and progress()
to use one shared FieldDataCache. We also use a filter so that we only pull
back StudentModule state for things that might possibly affect the grade --
items that either have scores or have children.

Because some older XModules do work in their __init__() methods (like Video),
instantiating them takes time, particularly on large courses. This commit also
changes the code that fetches the grading_context to filter out children that
can't possibly affect the grade.

Finally, we introduce a ScoresClient that also tries to fetch score
information all at once, instead of in separate queries. Technically, we are
fetching this information redundantly, but that's because the state and score
interfaces are being teased apart as we move forward. Still, this only
amounts to one extra SQL query, and has very little impact on performance
overall.

Much thanks to @adampalay -- his hackathon work in #7168 formed the basis of
this.

https://openedx.atlassian.net/browse/CSM-17
2015-07-09 10:03:58 -04:00
Calen Pennington
c1ace04483 Merge pull request #8391 from edx/alawibaba/plat5892
First draft.
2015-06-12 12:39:38 -04:00
Calen Pennington
b9f5eef4ae Log an exception before swallowing it in a KeyValueMultiSaveError 2015-06-12 12:37:49 -04:00
Xiaolu Xiong
4f45839211 Merge pull request #8325 from beardeer/master
Merge pull request #8325 from beardeer/edx-platform
2015-06-04 11:45:15 -04:00
Xiaolu Xiong
aa1bca6b41 Change the misleading doc string (str doesn't has attr 'name' ) 2015-06-04 08:30:38 -04:00
Adam Palay
6012a34765 disable contracts that were breaking capa problems on devstack (TNL-2343) 2015-06-03 16:17:30 -04:00
Calen Pennington
122039ac58 Add __len__ to FieldDataCache 2015-05-20 15:33:31 -04:00
Calen Pennington
4625036d31 Standardize on triple double-quotes for docstrings 2015-05-20 15:33:30 -04:00
Calen Pennington
827a8f815a Improve documentation of courseware.model_data 2015-05-20 15:33:30 -04:00
Calen Pennington
bd1e9aa129 Record valid scopes when raising InvalidScopeError 2015-05-20 15:33:30 -04:00
Calen Pennington
13dc390f7a Use a specialized method to clean up DjangoKeyValueStore 2015-05-20 15:33:30 -04:00
Calen Pennington
2e06e592ca Use DjangoXBlockUserStateClient to implement UserStateCache 2015-05-20 15:33:29 -04:00
Calen Pennington
257660ed85 Move query-chunking into StudentModule and related ORM-objects 2015-05-20 15:33:29 -04:00
Calen Pennington
cacdbc35d7 Remove the ability to select_for_updates from FieldDataCache.
The only consumer of that functionality (the XQueue callback) already
does retries, so newly introduce integrity errors (due to multiple
commiters trying to update a StudentModule) won't break the XQueue
processing pipeline.
2015-05-20 15:07:29 -04:00
Calen Pennington
917ea90dc3 Inline some private methods in UserStateCache 2015-05-20 15:07:28 -04:00
Calen Pennington
57d5fa28b5 Reorder methods in UserStateCache 2015-05-20 15:07:27 -04:00
Calen Pennington
3ea74743ee Flatten DjangoOrmFieldCache methods into UserStateCache 2015-05-20 15:07:27 -04:00
Calen Pennington
8c959528bc Add a last_modified method to FieldDataCache 2015-05-20 15:07:27 -04:00
Calen Pennington
3430024d22 Add a temporary set_grade method to the FieldDataCache and UserStateCache 2015-05-20 15:07:26 -04:00
Calen Pennington
c3bb2e9b3a Use per-type cache set_many calls in FieldDataCache set_many 2015-05-20 15:07:26 -04:00
Calen Pennington
60e436c290 Push get down into per-type caches 2015-05-20 15:07:26 -04:00
Calen Pennington
407db16938 Implement per-type set methods in terms of set_many methods 2015-05-20 15:07:25 -04:00