From 9cd1162a60fa95eec10bd3c9c197180453e2efde Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Thu, 7 Feb 2013 14:45:24 -0500 Subject: [PATCH] Grading and details split out. Put the unimplemented tabs into a single file not used. --- cms/djangoapps/contentstore/views.py | 25 +- .../js/models/settings/course_details.js | 162 ++-- .../models/settings/course_grading_policy.js | 213 ++--- .../js/models/settings/course_settings.js | 75 +- .../js/views/settings/main_settings_view.js | 756 +++--------------- cms/templates/settings.html | 505 +----------- .../settings_discussions_faculty.html | 430 ++++++++++ cms/templates/settings_graders.html | 123 +++ cms/templates/widgets/header.html | 5 +- cms/urls.py | 1 + 10 files changed, 950 insertions(+), 1345 deletions(-) create mode 100644 cms/templates/settings_discussions_faculty.html create mode 100644 cms/templates/settings_graders.html diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index bd0dc2fb48..577492753b 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -1109,8 +1109,31 @@ def get_course_settings(request, org, course, name): course_details = CourseDetails.fetch(location) return render_to_response('settings.html', { - 'active_tab': 'settings', 'context_course': course_module, + 'course_location' : location, + 'course_details' : json.dumps(course_details, cls=CourseSettingsEncoder) + }) + +@login_required +@ensure_csrf_cookie +def course_config_graders_page(request, org, course, name): + """ + Send models and views as well as html for editing the course settings to the client. + + org, course, name: Attributes of the Location for the item to edit + """ + location = ['i4x', org, course, 'course', name] + + # check that logged in user has permissions to this item + if not has_access(request.user, location): + raise PermissionDenied() + + course_module = modulestore().get_item(location) + course_details = CourseGradingModel.fetch(location) + + return render_to_response('settings_graders.html', { + 'context_course': course_module, + 'course_location' : location, 'course_details' : json.dumps(course_details, cls=CourseSettingsEncoder) }) diff --git a/cms/static/js/models/settings/course_details.js b/cms/static/js/models/settings/course_details.js index bdbb46b3b1..5090b5006d 100644 --- a/cms/static/js/models/settings/course_details.js +++ b/cms/static/js/models/settings/course_details.js @@ -1,85 +1,85 @@ if (!CMS.Models['Settings']) CMS.Models.Settings = new Object(); CMS.Models.Settings.CourseDetails = Backbone.Model.extend({ - defaults: { - location : null, // the course's Location model, required - start_date: null, // maps to 'start' - end_date: null, // maps to 'end' - enrollment_start: null, - enrollment_end: null, - syllabus: null, - overview: "", - intro_video: null, - effort: null // an int or null - }, - - // When init'g from html script, ensure you pass {parse: true} as an option (2nd arg to reset) - parse: function(attributes) { - if (attributes['course_location']) { - attributes.location = new CMS.Models.Location(attributes.course_location, {parse:true}); - } - if (attributes['start_date']) { - attributes.start_date = new Date(attributes.start_date); - } - if (attributes['end_date']) { - attributes.end_date = new Date(attributes.end_date); - } - if (attributes['enrollment_start']) { - attributes.enrollment_start = new Date(attributes.enrollment_start); - } - if (attributes['enrollment_end']) { - attributes.enrollment_end = new Date(attributes.enrollment_end); - } - return attributes; - }, - - validate: function(newattrs) { - // Returns either nothing (no return call) so that validate works or an object of {field: errorstring} pairs - // A bit funny in that the video key validation is asynchronous; so, it won't stop the validation. - var errors = {}; - if (newattrs.start_date && newattrs.end_date && newattrs.start_date >= newattrs.end_date) { - errors.end_date = "The course end date cannot be before the course start date."; - } - if (newattrs.start_date && newattrs.enrollment_start && newattrs.start_date < newattrs.enrollment_start) { - errors.enrollment_start = "The course start date cannot be before the enrollment start date."; - } - if (newattrs.enrollment_start && newattrs.enrollment_end && newattrs.enrollment_start >= newattrs.enrollment_end) { - errors.enrollment_end = "The enrollment start date cannot be after the enrollment end date."; - } - if (newattrs.end_date && newattrs.enrollment_end && newattrs.end_date < newattrs.enrollment_end) { - errors.enrollment_end = "The enrollment end date cannot be after the course end date."; - } - if (newattrs.intro_video && newattrs.intro_video !== this.get('intro_video')) { - if (this._videokey_illegal_chars.exec(newattrs.intro_video)) { - errors.intro_video = "Key should only contain letters, numbers, _, or -"; - } - // TODO check if key points to a real video using google's youtube api - } - if (!_.isEmpty(errors)) return errors; - // NOTE don't return empty errors as that will be interpreted as an error state - }, - - url: function() { - var location = this.get('location'); - return '/' + location.get('org') + "/" + location.get('course') + '/settings/' + location.get('name') + '/section/details'; - }, - - _videokey_illegal_chars : /[^a-zA-Z0-9_-]/g, - save_videosource: function(newsource) { - // newsource either is