Commit cc9f9a9d by kimth

queuekey generated from LoncapaProblem seed + system time

parent 84eb3efa
...@@ -8,6 +8,7 @@ Used by capa_problem.py ...@@ -8,6 +8,7 @@ Used by capa_problem.py
''' '''
# standard library imports # standard library imports
import hashlib
import inspect import inspect
import json import json
import logging import logging
...@@ -16,6 +17,7 @@ import numpy ...@@ -16,6 +17,7 @@ import numpy
import random import random
import re import re
import requests import requests
import time
import traceback import traceback
import abc import abc
...@@ -808,8 +810,12 @@ class CodeResponse(LoncapaResponse): ...@@ -808,8 +810,12 @@ class CodeResponse(LoncapaResponse):
xmlstr = etree.tostring(self.xml, pretty_print=True) xmlstr = etree.tostring(self.xml, pretty_print=True)
header = { 'return_url': self.system.xqueue_callback_url } header = { 'return_url': self.system.xqueue_callback_url }
queuekey = random.randint(0,2**32-1) h = hashlib.md5()
header.update({'queuekey': queuekey}) if self.system is not None:
h.update(str(self.system.get('seed')))
h.update(str(time.time()))
queuekey = int(h.hexdigest(),16)
header.update({'queuekey': queuekey})
payload = {'xqueue_header': json.dumps(header), # TODO: 'xqueue_header' should eventually be derived from a config file payload = {'xqueue_header': json.dumps(header), # TODO: 'xqueue_header' should eventually be derived from a config file
'xml': xmlstr, 'xml': xmlstr,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment