implementation of grading events

for TNL-5045
This commit is contained in:
Sanford Student
2016-11-16 11:47:25 -05:00
parent 5d4514d716
commit 5f2ffbe75b
15 changed files with 620 additions and 85 deletions

View File

@@ -0,0 +1,50 @@
"""
Helper functions to access and update the id and type
used in event tracking.
"""
from uuid import uuid4, UUID
from request_cache import get_cache
def get_event_transaction_id():
"""
Retrieves the current event transaction id from the request
cache.
"""
return get_cache('event_transaction').get('id', None)
def get_event_transaction_type():
"""
Retrieves the current event transaction type from the request
cache.
"""
return get_cache('event_transaction').get('type', None)
def create_new_event_transaction_id():
"""
Sets the event transaction id to a newly-
generated UUID.
"""
new_id = uuid4()
get_cache('event_transaction')['id'] = new_id
return new_id
def set_event_transaction_id(new_id):
"""
Sets the event transaction id to a UUID object
generated from new_id.
new_id must be a parsable string version
of a UUID.
"""
get_cache('event_transaction')['id'] = UUID(new_id)
def set_event_transaction_type(action_type):
"""
Takes a string and stores it in the request cache
as the user action type.
"""
get_cache('event_transaction')['type'] = action_type

View File

@@ -1,7 +1,7 @@
"""Utility functions and classes for track backends"""
from datetime import datetime, date
import json
from datetime import datetime, date
from pytz import UTC

View File

@@ -1440,7 +1440,6 @@ class CapaMixin(CapaFields):
# rescoring should have no effect on attempts, so don't
# need to increment here, or mark done. Just save.
self.set_state_from_lcp()
self.publish_grade(only_if_higher)
new_score = self.lcp.get_score()
@@ -1460,7 +1459,11 @@ class CapaMixin(CapaFields):
event_info['attempts'] = self.attempts
self.track_function_unmask('problem_rescore', event_info)
return {'success': success}
return {
'success': success,
'new_raw_earned': new_score['score'],
'new_raw_possible': new_score['total'],
}
def save_problem(self, data):
"""