Commit e98a9c79 by Dillon Dumesnil

v0.5

parent 8d89bdaa
...@@ -24,6 +24,8 @@ from xmodule.util.misc import escape_html_characters ...@@ -24,6 +24,8 @@ from xmodule.util.misc import escape_html_characters
from xmodule.x_module import DEPRECATION_VSCOMPAT_EVENT, XModule from xmodule.x_module import DEPRECATION_VSCOMPAT_EVENT, XModule
from xmodule.xml_module import XmlDescriptor, name_to_pathname from xmodule.xml_module import XmlDescriptor, name_to_pathname
from lms.djangoapps.review.get_review_ids import get_records
log = logging.getLogger("edx.courseware") log = logging.getLogger("edx.courseware")
# Make '_' a no-op so we can scrape strings. Using lambda instead of # Make '_' a no-op so we can scrape strings. Using lambda instead of
...@@ -83,6 +85,16 @@ class HtmlBlock(object): ...@@ -83,6 +85,16 @@ class HtmlBlock(object):
# but for now the XModule mixin requires that this method be defined. # but for now the XModule mixin requires that this method be defined.
# pylint: disable=no-member # pylint: disable=no-member
if self.system.anonymous_student_id: if self.system.anonymous_student_id:
# List of 5 problem urls I want to show
url_list = get_records(5, self.course_id)
# for i in xrange(len(url_list)):
# Adds the problem urls into the iFrame template
# self.data = self.data.format("%%PROBLEM_URL_" + str(i) +"%%", url_list[i])
return self.data.format(PROBLEM_URL_0= url_list[0],
PROBLEM_URL_1= url_list[1],
PROBLEM_URL_2= url_list[2],
PROBLEM_URL_3= url_list[3],
PROBLEM_URL_4= url_list[4])
return self.data.replace("%%USER_ID%%", self.system.anonymous_student_id) return self.data.replace("%%USER_ID%%", self.system.anonymous_student_id)
return self.data return self.data
......
---
metadata:
display_name: Dillon IFrame Tool
data: |
<h3 class="hd hd-2">Dillon Review Tool</h3>
<iframe title="Dillon Review Test 1" src="{PROBLEM_URL_0}" width="100%" height="550" marginwidth="0" marginheight="0" frameborder="0">
Your browser does not support IFrames.
</iframe>
<iframe title="Dillon Review Test 2" src="{PROBLEM_URL_1}" width="100%" height="550" marginwidth="0" marginheight="0" frameborder="0">
Your browser does not support IFrames.
</iframe>
<iframe title="Dillon Review Test 3" src="{PROBLEM_URL_2}" width="100%" height="550" marginwidth="0" marginheight="0" frameborder="0">
Your browser does not support IFrames.
</iframe>
<iframe title="Dillon Review Test 4" src="{PROBLEM_URL_3}" width="100%" height="550" marginwidth="0" marginheight="0" frameborder="0">
Your browser does not support IFrames.
</iframe>
<iframe title="Dillon Review Test 5" src="{PROBLEM_URL_4}" width="100%" height="550" marginwidth="0" marginheight="0" frameborder="0">
Your browser does not support IFrames.
</iframe>
"""
Logic for the review block to grab records from the database.
"""
'''
Description
'''
import logging
from courseware.models import StudentModule
from opaque_keys.edx.locator import CourseLocator
import crum
import random
log = logging.getLogger(__name__)
DATABASE = 'csm'
REVIEW_COURSE_MAPPING = {
'course-v1:DillonX+DAD401+2017_T3': 'DillonX+DAD402+2017_T3',
'course-v1:DillonX+DAD301+2017_T3': 'DillonX+DAD302+2017_T3'
}
# SQL_query = 'SELECT state, grade, max_grade FROM courseware_studentmodule '\
# 'WHERE student_id='{student_id}' AND course_id='{course_id}' '\
# 'AND module_type='problem';'
def get_records(num_desired, current_course):
user = crum.get_current_user()
problem_ids = []
# dummy_course = CourseLocator(u'DummyX', u'Dummy1', u'2017_T3', None, None)
# course = [key for key in user.__dict__['_anonymous_id'].keys() if type(key) == type(dummy_course)][0]
for record in StudentModule.objects.filter(**{'student_id': user.id, 'course_id': current_course, 'module_type': 'problem'}):
problem = str(record.module_state_key).split("@")
problem_ids.append(problem[-1])
problems_to_show = random.sample(problem_ids, num_desired)
review_course_id = REVIEW_COURSE_MAPPING[str(current_course)]
template_url = 'https://dillon-dumesnil.sandbox.edx.org/xblock/block-v1:{course_id}+type@problem+block@{problem_id}'
# local_template_url = '/xblock/block-v1:{course_id}+type@problem+block@{problem_id}'
urls = []
for problem in problems_to_show:
urls.append(local_template_url.format(course_id=review_course_id, problem_id=problem))
return urls
# return template_url.format(course_id=review_course_id, problem_id=problem_to_show)
# return 'https://courses.edx.org/xblock/block-v1:MITx+6.002.1x_1+2T2016+type@problem+block@903ce05eb08e452ba9991a2756d3cce2'
# return '/xblock/block-v1:DillonX+DAD301+2017_T3+type@problem+block@050d2b4ce4514c888ff654c5972cc1fa'
# return '/xblock/block-v1:DillonX+DAD101+2017_T3+type@problem+block@68b08558f32b49e7aa1841015e24a296'
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