Commit 14eb9c9a by cahrens

Merge branch 'master' into feature/christina/metadata-ui

parents 5d41e2a9 5118b06e
......@@ -26,7 +26,7 @@ class LMSLinksTestCase(TestCase):
link = utils.get_lms_link_for_item(location, True)
self.assertEquals(
link,
"//preview.localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us"
"//preview/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us"
)
......
......@@ -88,7 +88,7 @@ def get_lms_link_for_item(location, preview=False, course_id=None):
if settings.LMS_BASE is not None:
if preview:
lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE', 'preview.' + settings.LMS_BASE)
lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE')
else:
lms_base = settings.LMS_BASE
......
......@@ -178,8 +178,7 @@ def edit_unit(request, location):
break
index = index + 1
preview_lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE',
'preview.' + settings.LMS_BASE)
preview_lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE')
preview_lms_link = '//{preview_lms_base}/courses/{org}/{course}/{course_name}/courseware/{section}/{subsection}/{index}'.format(
preview_lms_base=preview_lms_base,
......
......@@ -81,6 +81,7 @@ with open(ENV_ROOT / CONFIG_PREFIX + "env.json") as env_file:
ENV_TOKENS = json.load(env_file)
LMS_BASE = ENV_TOKENS.get('LMS_BASE')
# Note that MITX_FEATURES['PREVIEW_LMS_BASE'] gets read in from the environment file.
SITE_NAME = ENV_TOKENS['SITE_NAME']
......
......@@ -39,8 +39,8 @@ MITX_FEATURES = {
'STUDIO_NPS_SURVEY': True,
'SEGMENT_IO': True,
# Enable URL that shows information about the status of variuous services
'ENABLE_SERVICE_STATUS': False,
# Enable URL that shows information about the status of various services
'ENABLE_SERVICE_STATUS': False
}
ENABLE_JASMINE = False
......
......@@ -55,6 +55,7 @@ DATABASES = {
}
LMS_BASE = "localhost:8000"
MITX_FEATURES['PREVIEW_LMS_BASE'] = "localhost:8000"
REPOS = {
'edx4edx': {
......
......@@ -82,6 +82,7 @@ DATABASES = {
}
LMS_BASE = "localhost:8000"
MITX_FEATURES['PREVIEW_LMS_BASE'] = "preview"
CACHES = {
# This is the cache used for most things. Askbot will not work without a
......
The code in this directory is based on:
django-mako Copyright (c) 2008 Mikeal Rogers
and is redistributed here with modifications under the same Apache 2.0 license
as the orginal.
================================================================================
django-mako
================================================================================
......
......@@ -527,12 +527,12 @@ def _do_create_account(post_vars):
js = {'success': False}
# Figure out the cause of the integrity error
if len(User.objects.filter(username=post_vars['username'])) > 0:
js['value'] = "An account with this username already exists."
js['value'] = "An account with the Public Username '" + post_vars['username'] + "' already exists."
js['field'] = 'username'
return HttpResponse(json.dumps(js))
if len(User.objects.filter(email=post_vars['email'])) > 0:
js['value'] = "An account with this e-mail already exists."
js['value'] = "An account with the Email '" + post_vars['email'] + "' already exists."
js['field'] = 'email'
return HttpResponse(json.dumps(js))
......
......@@ -469,6 +469,7 @@ class LoncapaProblem(object):
random_seed=self.seed,
python_path=python_path,
cache=self.system.cache,
slug=self.problem_id,
)
except Exception as err:
log.exception("Error while execing script code: " + all_code)
......
......@@ -140,6 +140,8 @@ class LoncapaResponse(object):
self.context = context
self.system = system
self.id = xml.get('id')
for abox in inputfields:
if abox.tag not in self.allowed_inputfields:
msg = "%s: cannot have input field %s" % (
......@@ -286,7 +288,7 @@ class LoncapaResponse(object):
}
try:
safe_exec.safe_exec(code, globals_dict, python_path=self.context['python_path'])
safe_exec.safe_exec(code, globals_dict, python_path=self.context['python_path'], slug=self.id)
except Exception as err:
msg = 'Error %s in evaluating hint function %s' % (err, hintfn)
msg += "\nSee XML source line %s" % getattr(
......@@ -935,7 +937,6 @@ class CustomResponse(LoncapaResponse):
# if <customresponse> has an "expect" (or "answer") attribute then save
# that
self.expect = xml.get('expect') or xml.get('answer')
self.myid = xml.get('id')
log.debug('answer_ids=%s' % self.answer_ids)
......@@ -972,7 +973,7 @@ class CustomResponse(LoncapaResponse):
'ans': ans,
}
globals_dict.update(kwargs)
safe_exec.safe_exec(code, globals_dict, python_path=self.context['python_path'])
safe_exec.safe_exec(code, globals_dict, python_path=self.context['python_path'], slug=self.id)
return globals_dict['cfn_return']
return check_function
......@@ -981,7 +982,7 @@ class CustomResponse(LoncapaResponse):
if not self.code:
if answer is None:
log.error("[courseware.capa.responsetypes.customresponse] missing"
" code checking script! id=%s" % self.myid)
" code checking script! id=%s" % self.id)
self.code = ''
else:
answer_src = answer.get('src')
......@@ -1034,7 +1035,7 @@ class CustomResponse(LoncapaResponse):
# note that this doesn't help the "cfn" version - only the exec version
self.context.update({
# my ID
'response_id': self.myid,
'response_id': self.id,
# expected answer (if given as attribute)
'expect': self.expect,
......@@ -1089,7 +1090,7 @@ class CustomResponse(LoncapaResponse):
# exec the check function
if isinstance(self.code, basestring):
try:
safe_exec.safe_exec(self.code, self.context, cache=self.system.cache)
safe_exec.safe_exec(self.code, self.context, cache=self.system.cache, slug=self.id)
except Exception as err:
self._handle_exec_exception(err)
......@@ -1813,7 +1814,7 @@ class SchematicResponse(LoncapaResponse):
]
self.context.update({'submission': submission})
try:
safe_exec.safe_exec(self.code, self.context, cache=self.system.cache)
safe_exec.safe_exec(self.code, self.context, cache=self.system.cache, slug=self.id)
except Exception as err:
msg = 'Error %s in evaluating SchematicResponse' % err
raise ResponseError(msg)
......
......@@ -71,7 +71,7 @@ def update_hash(hasher, obj):
@statsd.timed('capa.safe_exec.time')
def safe_exec(code, globals_dict, random_seed=None, python_path=None, cache=None):
def safe_exec(code, globals_dict, random_seed=None, python_path=None, cache=None, slug=None):
"""
Execute python code safely.
......@@ -87,6 +87,9 @@ def safe_exec(code, globals_dict, random_seed=None, python_path=None, cache=None
to cache the execution, taking into account the code, the values of the globals,
and the random seed.
`slug` is an arbitrary string, a description that's meaningful to the
caller, that will be used in log messages.
"""
# Check the cache for a previous result.
if cache:
......@@ -112,7 +115,7 @@ def safe_exec(code, globals_dict, random_seed=None, python_path=None, cache=None
try:
codejail_safe_exec(
code_prolog + LAZY_IMPORTS + code, globals_dict,
python_path=python_path,
python_path=python_path, slug=slug,
)
except SafeExecException as e:
emsg = e.message
......
"""
Modules that get shown to the users when an error has occured while
loading or rendering other modules
"""
import hashlib
import logging
import json
......@@ -22,12 +27,19 @@ log = logging.getLogger(__name__)
class ErrorFields(object):
"""
XBlock fields used by the ErrorModules
"""
contents = String(scope=Scope.content)
error_msg = String(scope=Scope.content)
display_name = String(scope=Scope.settings)
class ErrorModule(ErrorFields, XModule):
"""
Module that gets shown to staff when there has been an error while
loading or rendering other modules
"""
def get_html(self):
'''Show an error to staff.
......@@ -42,6 +54,10 @@ class ErrorModule(ErrorFields, XModule):
class NonStaffErrorModule(ErrorFields, XModule):
"""
Module that gets shown to students when there has been an error while
loading or rendering other modules
"""
def get_html(self):
'''Show an error to a student.
TODO (vshnayder): proper style, divs, etc.
......@@ -61,7 +77,7 @@ class ErrorDescriptor(ErrorFields, JSONEditingDescriptor):
module_class = ErrorModule
@classmethod
def _construct(self, system, contents, error_msg, location):
def _construct(cls, system, contents, error_msg, location):
if location.name is None:
location = location._replace(
......@@ -80,7 +96,7 @@ class ErrorDescriptor(ErrorFields, JSONEditingDescriptor):
'contents': contents,
'display_name': 'Error: ' + location.name
}
return ErrorDescriptor(
return cls(
system,
location,
model_data,
......
......@@ -268,7 +268,7 @@ class MongoModuleStore(ModuleStoreBase):
query = {'_id.org': location.org,
'_id.course': location.course,
'_id.category': {'$in': ['course', 'chapter', 'sequential', 'vertical',
'wrapper', 'problemset', 'conditional']}
'wrapper', 'problemset', 'conditional', 'randomize']}
}
# we just want the Location, children, and inheritable metadata
record_filter = {'_id': 1, 'definition.children': 1}
......
---
metadata:
display_name: default
data_dir: a_made_up_name
display_name: Video Alpha 1
version: 1
data: |
<videoalpha youtube="0.75:JMD_ifUUfsU,1.0:OEoXaMPEzfM,1.25:AKqURZnYqpk,1.50:DYpADpL7jAY"/>
<videoalpha show_captions="true" sub="name_of_file" youtube="0.75:JMD_ifUUfsU,1.0:OEoXaMPEzfM,1.25:AKqURZnYqpk,1.50:DYpADpL7jAY" >
<source src="https://s3.amazonaws.com/edx-course-videos/edx-intro/edX-FA12-cware-1_100.mp4"/>
<source src="https://s3.amazonaws.com/edx-course-videos/edx-intro/edX-FA12-cware-1_100.webm"/>
<source src="https://s3.amazonaws.com/edx-course-videos/edx-intro/edX-FA12-cware-1_100.ogv"/>
</videoalpha>
children: []
"""
Tests for ErrorModule and NonStaffErrorModule
"""
import unittest
from xmodule.tests import test_system
import xmodule.error_module as error_module
class TestErrorModule(unittest.TestCase):
"""
Tests for ErrorModule and ErrorDescriptor
"""
def setUp(self):
self.system = test_system()
self.org = "org"
self.course = "course"
self.fake_xml = "<problem />"
self.broken_xml = "<problem>"
self.error_msg = "Error"
def test_error_module_create(self):
descriptor = error_module.ErrorDescriptor.from_xml(
self.fake_xml, self.system, self.org, self.course)
self.assertTrue(isinstance(descriptor, error_module.ErrorDescriptor))
def test_error_module_rendering(self):
descriptor = error_module.ErrorDescriptor.from_xml(
self.fake_xml, self.system, self.org, self.course, self.error_msg)
module = descriptor.xmodule(self.system)
rendered_html = module.get_html()
self.assertIn(self.error_msg, rendered_html)
self.assertIn(self.fake_xml, rendered_html)
class TestNonStaffErrorModule(TestErrorModule):
"""
Tests for NonStaffErrorModule and NonStaffErrorDescriptor
"""
def test_non_staff_error_module_create(self):
descriptor = error_module.NonStaffErrorDescriptor.from_xml(
self.fake_xml, self.system, self.org, self.course)
self.assertTrue(isinstance(descriptor, error_module.NonStaffErrorDescriptor))
def test_non_staff_error_module_rendering(self):
descriptor = error_module.NonStaffErrorDescriptor.from_xml(
self.fake_xml, self.system, self.org, self.course)
module = descriptor.xmodule(self.system)
rendered_html = module.get_html()
self.assertNotIn(self.error_msg, rendered_html)
self.assertNotIn(self.fake_xml, rendered_html)
......@@ -4,10 +4,12 @@
import json
import unittest
from lxml import etree
from xmodule.poll_module import PollDescriptor
from xmodule.conditional_module import ConditionalDescriptor
from xmodule.word_cloud_module import WordCloudDescriptor
from xmodule.videoalpha_module import VideoAlphaDescriptor
class PostData:
"""Class which emulate postdata."""
......@@ -117,3 +119,33 @@ class WordCloudModuleTest(LogicTest):
)
self.assertEqual(100.0, sum(i['percent'] for i in response['top_words']) )
class VideoAlphaModuleTest(LogicTest):
descriptor_class = VideoAlphaDescriptor
raw_model_data = {
'data': '<videoalpha />'
}
def test_get_timeframe_no_parameters(self):
xmltree = etree.fromstring('<videoalpha>test</videoalpha>')
output = self.xmodule._get_timeframe(xmltree)
self.assertEqual(output, ('', ''))
def test_get_timeframe_with_one_parameter(self):
xmltree = etree.fromstring(
'<videoalpha start_time="00:04:07">test</videoalpha>'
)
output = self.xmodule._get_timeframe(xmltree)
self.assertEqual(output, (247, ''))
def test_get_timeframe_with_two_parameters(self):
xmltree = etree.fromstring(
'''<videoalpha
start_time="00:04:07"
end_time="13:04:39"
>test</videoalpha>'''
)
output = self.xmodule._get_timeframe(xmltree)
self.assertEqual(output, (247, 47079))
......@@ -93,7 +93,7 @@ class VideoAlphaModule(VideoAlphaFields, XModule):
return result
def _get_timeframe(self, xmltree):
""" Converts 'from' and 'to' parameters in video tag to seconds.
""" Converts 'start_time' and 'end_time' parameters in video tag to seconds.
If there are no parameters, returns empty string. """
def parse_time(s):
......@@ -103,11 +103,13 @@ class VideoAlphaModule(VideoAlphaFields, XModule):
return ''
else:
x = time.strptime(s, '%H:%M:%S')
return datetime.timedelta(hours=x.tm_hour,
minutes=x.tm_min,
seconds=x.tm_sec).total_seconds()
return datetime.timedelta(
hours=x.tm_hour,
minutes=x.tm_min,
seconds=x.tm_sec
).total_seconds()
return parse_time(xmltree.get('from')), parse_time(xmltree.get('to'))
return parse_time(xmltree.get('start_time')), parse_time(xmltree.get('end_time'))
def handle_ajax(self, dispatch, get):
"""Handle ajax calls to this video.
......
......@@ -13,8 +13,8 @@ Feature: Register for a course
Scenario: I can unregister for a course
Given I am registered for the course "6.002x"
And I visit the dashboard
When I click the link with the text "Unregister"
And I press the "Unregister" button in the Unenroll dialog
Then All dialogs should be closed
And I should be on the dashboard page
Then I should see the course numbered "6.002x" in my dashboard
When I unregister for the course numbered "6.002x"
Then I should be on the dashboard page
And I should see "Looks like you haven't registered for any courses yet." somewhere in the page
And I should NOT see the course numbered "6.002x" in my dashboard
......@@ -25,8 +25,15 @@ def i_should_see_that_course_in_my_dashboard(step, course):
assert world.is_css_present(course_link_css)
@step(u'I press the "([^"]*)" button in the Unenroll dialog')
def i_press_the_button_in_the_unenroll_dialog(step, value):
button_css = 'section#unenroll-modal input[value="%s"]' % value
@step(u'I should NOT see the course numbered "([^"]*)" in my dashboard$')
def i_should_not_see_that_course_in_my_dashboard(step, course):
course_link_css = 'section.my-courses a[href*="%s"]' % course
assert not world.is_css_present(course_link_css)
@step(u'I unregister for the course numbered "([^"]*)"')
def i_unregister_for_that_course(step, course):
unregister_css = 'section.info a[href*="#unenroll-modal"][data-course-number*="%s"]' % course
world.css_click(unregister_css)
button_css = 'section#unenroll-modal input[value="Unregister"]'
world.css_click(button_css)
assert world.is_css_present('section.container.dashboard')
lms/static/images/pinned.png

518 Bytes | W: | H:

lms/static/images/pinned.png

49.5 KB | W: | H:

lms/static/images/pinned.png
lms/static/images/pinned.png
lms/static/images/pinned.png
lms/static/images/pinned.png
  • 2-up
  • Swipe
  • Onion skin
lms/static/images/unpinned.png

498 Bytes | W: | H:

lms/static/images/unpinned.png

48.1 KB | W: | H:

lms/static/images/unpinned.png
lms/static/images/unpinned.png
lms/static/images/unpinned.png
lms/static/images/unpinned.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -33,8 +33,8 @@
// colophon
.colophon {
margin-right: flex-gutter(2);
width: flex-grid(6,12);
margin-right: flex-gutter();
width: flex-grid(8,12);
float: left;
.nav-colophon {
......@@ -71,7 +71,7 @@
p {
float: left;
width: 460px;
width: flex-grid(6,8);
margin-left: $baseline;
padding-left: $baseline;
font-size: em(13);
......@@ -91,7 +91,6 @@
text-align: right;
li {
margin-right: ($baseline/10);
display: inline-block;
&:last-child {
......@@ -154,9 +153,5 @@
.colophon-about img {
margin-top: ($baseline*1.5);
}
.colophon-about p {
width: 360px;
}
}
}
......@@ -14,7 +14,6 @@ header.global {
padding: 18px 10px 0px;
max-width: grid-width(12);
min-width: 760px;
width: flex-grid(12);
}
h1.logo {
......
......@@ -2,5 +2,5 @@
<section class="outside-app">
<h1>There has been a 500 error on the <em>edX</em> servers</h1>
<p>Our staff is currently working to get the site back up as soon as possible. Please email us at <a href="mailto:technical@edx.org">technical@edx.org</a> to report any problems or downtime.</p>
<p>Please wait a few seconds and then reload the page. If the problem persists, please email us at <a href="mailto:technical@edx.org">technical@edx.org</a>.</p>
</section>
......@@ -9,7 +9,7 @@
<div class="content">
<div class="log-in-form">
<h2>Log in to your courses</h2>
<form id="login_form" data-remote="true" method="post" action="/login">
<form id="login_form" data-remote="true" method="post" action="/login_ajax">
<div class="row">
<label>Email</label>
<input name="email" type="email" class="email-field" tabindex="1">
......
......@@ -22,10 +22,6 @@ urlpatterns = ('', # nopep8
url(r'^admin_dashboard$', 'dashboard.views.dashboard'),
# Adding to allow debugging issues when prod is mysteriously different from staging
# (specifically missing get parameters in certain cases)
url(r'^debug_request$', 'util.views.debug_request'),
url(r'^change_email$', 'student.views.change_email_request', name="change_email"),
url(r'^email_confirm/(?P<key>[^/]*)$', 'student.views.confirm_email_change'),
url(r'^change_name$', 'student.views.change_name_request', name="change_name"),
......@@ -334,6 +330,13 @@ if settings.DEBUG or settings.MITX_FEATURES.get('ENABLE_DJANGO_ADMIN_SITE'):
## Jasmine and admin
urlpatterns += (url(r'^admin/', include(admin.site.urls)),)
if settings.DEBUG:
# Originally added to allow debugging issues when prod is
# mysteriously different from staging (specifically missing get
# parameters in certain cases), but removing from prod because
# it's a security risk.
urlpatterns += (url(r'^debug_request$', 'util.views.debug_request'),)
if settings.MITX_FEATURES.get('AUTH_USE_OPENID'):
urlpatterns += (
url(r'^openid/login/$', 'django_openid_auth.views.login_begin', name='openid-login'),
......
......@@ -9,4 +9,4 @@
# Our libraries:
-e git+https://github.com/edx/XBlock.git@2144a25d#egg=XBlock
-e git+https://github.com/edx/codejail.git@72cf791#egg=codejail
-e git+https://github.com/edx/codejail.git@5fb5fa0#egg=codejail
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