Commit e0849e8b by Don Mitchell

Cache to debug other branch

parent a39d609e
...@@ -167,6 +167,7 @@ def course_index(request, org, course, name): ...@@ -167,6 +167,7 @@ def course_index(request, org, course, name):
'active_tab': 'courseware', 'active_tab': 'courseware',
'context_course': course, 'context_course': course,
'sections': sections, 'sections': sections,
'course_graders': json.dumps(CourseGradingModel.fetch(course.location).graders),
'parent_location': course.location, 'parent_location': course.location,
'new_section_template': Location('i4x', 'edx', 'templates', 'chapter', 'Empty'), 'new_section_template': Location('i4x', 'edx', 'templates', 'chapter', 'Empty'),
'new_subsection_template': Location('i4x', 'edx', 'templates', 'sequential', 'Empty'), # for now they are the same, but the could be different at some point... 'new_subsection_template': Location('i4x', 'edx', 'templates', 'sequential', 'Empty'), # for now they are the same, but the could be different at some point...
...@@ -339,6 +340,25 @@ def preview_component(request, location): ...@@ -339,6 +340,25 @@ def preview_component(request, location):
'editor': wrap_xmodule(component.get_html, component, 'xmodule_edit.html')(), 'editor': wrap_xmodule(component.get_html, component, 'xmodule_edit.html')(),
}) })
@expect_json
@login_required
@ensure_csrf_cookie
def assignment_type_update(request, org, course, category, name):
'''
CRUD operations on assignment types for sections and subsections and anything else gradable.
'''
location = Location(['i4x', org, course, category, name])
if not has_access(request.user, location):
raise HttpResponseForbidden()
if request.method == 'GET':
# Cannot just do a get w/o knowing the course name :-(
return HttpResponse(json.dumps(CourseGradingModel.get_section_grader_type(location)),
mimetype="application/json")
elif request.method == 'POST': # post or put, doesn't matter.
return HttpResponse(json.dumps(CourseGradingModel.update_section_grader_type(location, request.POST)),
mimetype="application/json")
def user_author_string(user): def user_author_string(user):
'''Get an author string for commits by this user. Format: '''Get an author string for commits by this user. Format:
......
...@@ -203,6 +203,27 @@ class CourseGradingModel: ...@@ -203,6 +203,27 @@ class CourseGradingModel:
get_modulestore(course_location).update_metadata(course_location, descriptor.metadata) get_modulestore(course_location).update_metadata(course_location, descriptor.metadata)
@staticmethod @staticmethod
def get_section_grader_type(location):
"""
"""
if not isinstance(location, Location):
location = Location(location)
# TODO impl to return {grader-type, location, id (random)}
@staticmethod
def update_section_grader_type(location, jsondict):
"""
"""
if not isinstance(location, Location):
location = Location(location)
# TODO impl to return {grader-type, location, id (random)}
@staticmethod
def convert_set_grace_period(descriptor): def convert_set_grace_period(descriptor):
# 5 hours 59 minutes 59 seconds => converted to iso format # 5 hours 59 minutes 59 seconds => converted to iso format
rawgrace = descriptor.metadata.get('graceperiod', None) rawgrace = descriptor.metadata.get('graceperiod', None)
......
...@@ -8,11 +8,11 @@ CMS.Models.Location = Backbone.Model.extend({ ...@@ -8,11 +8,11 @@ CMS.Models.Location = Backbone.Model.extend({
}, },
toUrl: function(overrides) { toUrl: function(overrides) {
return return
(overrides['tag'] ? overrides['tag'] : this.get('tag')) + "://" + (overrides && overrides['tag'] ? overrides['tag'] : this.get('tag')) + "://" +
(overrides['org'] ? overrides['org'] : this.get('org')) + "/" + (overrides && overrides['org'] ? overrides['org'] : this.get('org')) + "/" +
(overrides['course'] ? overrides['course'] : this.get('course')) + "/" + (overrides && overrides['course'] ? overrides['course'] : this.get('course')) + "/" +
(overrides['category'] ? overrides['category'] : this.get('category')) + "/" + (overrides && overrides['category'] ? overrides['category'] : this.get('category')) + "/" +
(overrides['name'] ? overrides['name'] : this.get('name')) + "/"; (overrides && overrides['name'] ? overrides['name'] : this.get('name')) + "/";
}, },
_tagPattern : /[^:]+/g, _tagPattern : /[^:]+/g,
_fieldPattern : new RegExp('[^/]+','g'), _fieldPattern : new RegExp('[^/]+','g'),
...@@ -28,6 +28,7 @@ CMS.Models.Location = Backbone.Model.extend({ ...@@ -28,6 +28,7 @@ CMS.Models.Location = Backbone.Model.extend({
} }
} }
else if (_.isString(payload)) { else if (_.isString(payload)) {
this._tagPattern.lastIndex = 0; // odd regex behavior requires this to be reset sometimes
var foundTag = this._tagPattern.exec(payload); var foundTag = this._tagPattern.exec(payload);
if (foundTag) { if (foundTag) {
this._fieldPattern.lastIndex = this._tagPattern.lastIndex + 1; // skip over the colon this._fieldPattern.lastIndex = this._tagPattern.lastIndex + 1; // skip over the colon
...@@ -36,6 +37,7 @@ CMS.Models.Location = Backbone.Model.extend({ ...@@ -36,6 +37,7 @@ CMS.Models.Location = Backbone.Model.extend({
org: this._fieldPattern.exec(payload)[0], org: this._fieldPattern.exec(payload)[0],
course: this._fieldPattern.exec(payload)[0], course: this._fieldPattern.exec(payload)[0],
category: this._fieldPattern.exec(payload)[0], category: this._fieldPattern.exec(payload)[0],
// FIXME handle no trailing /
name: this._fieldPattern.exec(payload)[0] name: this._fieldPattern.exec(payload)[0]
} }
} }
......
...@@ -17,41 +17,23 @@ ...@@ -17,41 +17,23 @@
<script src="${static.url('js/vendor/timepicker/datepair.js')}"></script> <script src="${static.url('js/vendor/timepicker/datepair.js')}"></script>
<script src="${static.url('js/vendor/date.js')}"></script> <script src="${static.url('js/vendor/date.js')}"></script>
<script type="text/javascript" src="${static.url('js/models/settings/course_grading_policy.js')}"></script> <script type="text/javascript" src="${static.url('js/models/settings/course_grading_policy.js')}"></script>
<script type="text/javascript" src="${static.url('js/models/course_relative.js')}"></script>
<script type="text/javascript"> <script type="text/javascript">
(function() { $(document).ready(function(){
$body = $('body'); // TODO figure out whether these should be in window or someplace else?
$('.gradable-status .menu-toggle').bind('click', showGradeMenu); window.graderTypes = new CMS.Models.Settings.CourseGraderCollection();
$('.gradable-status .menu').bind('click', selectGradeType); window.graderTypes.reset(${course_graders|n});
})(); window.graderTypes.course_location(new CMS.Models.Location('${parent_location}'));
function showGradeMenu(e) { $(".gradable-status").each(function(index, ele) {
var gradeView = new CMS.Views.OverviewAssignmentGrader({
$section = $(this).closest('.gradable-status'); el : ele,
e.preventDefault(); graders : window.graderTypes
$section.toggleClass('is-active'); });
} });
});
function selectGradeType(e) {
e.preventDefault();
var $section = $(this).closest('.gradable-status');
$section.find('.menu li a').removeClass('is-selected');
var $target = $(e.target).addClass('is-selected');
var $label = $section.find('.status-label');
$section.removeClass('is-active');
$label.html($target.html());
if ($target.hasClass('gradable-status-notgraded')) {
$section.removeClass('is-set');
}
else {
$section.addClass('is-set');
}
}
</script> </script>
</%block> </%block>
...@@ -167,21 +149,7 @@ ...@@ -167,21 +149,7 @@
</div> </div>
</div> </div>
<div class="gradable-status"> <div class="gradable-status" data-initial-status="${section.metadata.get('format', 'Not Graded')}">
<h4 class="status-label">Not Graded</h4>
<a data-tooltip="Mark/unmark this section as graded" class="menu-toggle" href="#">
<span class="ss-icon ss-standard">&#x2713;</span>
</a>
<ul class="menu">
<li><a class="is-selected" href="#">Homework</a></li>
<li><a href="#">Finger Exercises</a></li>
<li><a href="#">Lab</a></li>
<li><a href="#">Midterm Exam</a></li>
<li><a href="#">Final Exam</a></li>
<li><a class="gradable-status-notgraded" href="#">Not Graded</a></li>
</ul>
</div> </div>
<div class="item-actions"> <div class="item-actions">
...@@ -207,21 +175,7 @@ ...@@ -207,21 +175,7 @@
</a> </a>
</div> </div>
<div class="gradable-status"> <div class="gradable-status" data-initial-status="${subsection.metadata.get('format', 'Not Graded')}">
<h4 class="status-label">Not Graded</h4>
<a data-tooltip="Mark/unmark this subsection as graded" class="menu-toggle" href="#">
<span class="ss-icon ss-standard">&#x2713;</span>
</a>
<ul class="menu">
<li><a class="is-selected" href="#">Homework</a></li>
<li><a href="#">Finger Exercises</a></li>
<li><a href="#">Lab</a></li>
<li><a href="#">Midterm Exam</a></li>
<li><a href="#">Final Exam</a></li>
<li><a class="gradable-status-notgraded" href="#">Not Graded</a></li>
</ul>
</div> </div>
<div class="item-actions"> <div class="item-actions">
......
...@@ -39,6 +39,9 @@ urlpatterns = ('', ...@@ -39,6 +39,9 @@ urlpatterns = ('',
url(r'^(?P<org>[^/]+)/(?P<course>[^/]+)/settings/(?P<name>[^/]+)$', 'contentstore.views.get_course_settings', name='course_settings'), url(r'^(?P<org>[^/]+)/(?P<course>[^/]+)/settings/(?P<name>[^/]+)$', 'contentstore.views.get_course_settings', name='course_settings'),
url(r'^(?P<org>[^/]+)/(?P<course>[^/]+)/settings/(?P<name>[^/]+)/section/(?P<section>[^/]+).*$', 'contentstore.views.course_settings_updates', name='course_settings'), url(r'^(?P<org>[^/]+)/(?P<course>[^/]+)/settings/(?P<name>[^/]+)/section/(?P<section>[^/]+).*$', 'contentstore.views.course_settings_updates', name='course_settings'),
url(r'^(?P<org>[^/]+)/(?P<course>[^/]+)/grades/(?P<name>[^/]+)/(?P<grader_index>.*)$', 'contentstore.views.course_grader_updates', name='course_settings'), url(r'^(?P<org>[^/]+)/(?P<course>[^/]+)/grades/(?P<name>[^/]+)/(?P<grader_index>.*)$', 'contentstore.views.course_grader_updates', name='course_settings'),
url(r'^(?P<org>[^/]+)/(?P<course>[^/]+)/(?P<category>[^/]+)/(?P<name>[^/]+)/gradeas.*$', 'contentstore.views.assignment_type_update', name='assignment_type_update'),
url(r'^pages/(?P<org>[^/]+)/(?P<course>[^/]+)/course/(?P<coursename>[^/]+)$', 'contentstore.views.static_pages', url(r'^pages/(?P<org>[^/]+)/(?P<course>[^/]+)/course/(?P<coursename>[^/]+)$', 'contentstore.views.static_pages',
name='static_pages'), name='static_pages'),
url(r'^edit_static/(?P<org>[^/]+)/(?P<course>[^/]+)/course/(?P<coursename>[^/]+)$', 'contentstore.views.edit_static', name='edit_static'), url(r'^edit_static/(?P<org>[^/]+)/(?P<course>[^/]+)/course/(?P<coursename>[^/]+)$', 'contentstore.views.edit_static', name='edit_static'),
......
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