本文整理汇总了Python中courseware.user_state_client.DjangoXBlockUserStateClient.get_history方法的典型用法代码示例。如果您正苦于以下问题:Python DjangoXBlockUserStateClient.get_history方法的具体用法?Python DjangoXBlockUserStateClient.get_history怎么用?Python DjangoXBlockUserStateClient.get_history使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类courseware.user_state_client.DjangoXBlockUserStateClient
的用法示例。
在下文中一共展示了DjangoXBlockUserStateClient.get_history方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fix_studentmodules_in_list
# 需要导入模块: from courseware.user_state_client import DjangoXBlockUserStateClient [as 别名]
# 或者: from courseware.user_state_client.DjangoXBlockUserStateClient import get_history [as 别名]
def fix_studentmodules_in_list(self, save_changes, idlist_path):
'''Read in the list of StudentModule objects that might need fixing, and then fix each one'''
# open file and read id values from it:
for line in open(idlist_path, 'r'):
student_module_id = line.strip()
# skip the header, if present:
if student_module_id == 'id':
continue
try:
module = StudentModule.objects.select_related('student').get(id=student_module_id)
except StudentModule.DoesNotExist:
LOG.error(u"Unable to find student module with id = %s: skipping... ", student_module_id)
continue
self.remove_studentmodule_input_state(module, save_changes)
user_state_client = DjangoXBlockUserStateClient()
hist_modules = user_state_client.get_history(module.student.username, module.module_state_key)
for hist_module in hist_modules:
self.remove_studentmodulehistory_input_state(hist_module, save_changes)
if self.num_visited % 1000 == 0:
LOG.info(" Progress: updated {0} of {1} student modules".format(self.num_changed, self.num_visited))
LOG.info(" Progress: updated {0} of {1} student history modules".format(self.num_hist_changed,
self.num_hist_visited))