From b3d0abbd0555f85b0ff7e4717c19a1fcd1d0eaa3 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Fri, 1 Mar 2013 13:31:54 -0500 Subject: [PATCH 01/23] Start to move around templates --- .../combined_open_ended_modulev1.py | 7 +++++-- .../{ => combinedopenended}/combined_open_ended.html | 0 2 files changed, 5 insertions(+), 2 deletions(-) rename lms/templates/{ => combinedopenended}/combined_open_ended.html (100%) diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py index 171441c562..4fc1d1fec5 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py @@ -79,6 +79,9 @@ class CombinedOpenEndedV1Module(): INTERMEDIATE_DONE = 'intermediate_done' DONE = 'done' + #Where the templates live for this problem + TEMPLATE_DIR = "combinedopenended" + def __init__(self, system, location, definition, descriptor, instance_state=None, shared_state=None, metadata = None, static_data = None, **kwargs): @@ -343,7 +346,7 @@ class CombinedOpenEndedV1Module(): Output: rendered html """ context = self.get_context() - html = self.system.render_template('combined_open_ended.html', context) + html = self.system.render_template('{0}/combined_open_ended.html'.format(self.TEMPLATE_DIR), context) return html def get_html_nonsystem(self): @@ -354,7 +357,7 @@ class CombinedOpenEndedV1Module(): Output: HTML rendered directly via Mako """ context = self.get_context() - html = self.system.render_template('combined_open_ended.html', context) + html = self.system.render_template('{0}/combined_open_ended.html'.format(self.TEMPLATE_DIR), context) return html def get_html_base(self): diff --git a/lms/templates/combined_open_ended.html b/lms/templates/combinedopenended/combined_open_ended.html similarity index 100% rename from lms/templates/combined_open_ended.html rename to lms/templates/combinedopenended/combined_open_ended.html From b0c2559de8fb8a67da009e9b73432d7e8888f6a0 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Fri, 1 Mar 2013 13:43:01 -0500 Subject: [PATCH 02/23] Switch around template locations --- .../combined_open_ended_modulev1.py | 10 +++++----- .../combined_open_ended_rubric.py | 8 +++++--- .../open_ended_grading_classes/open_ended_module.py | 10 ++++++---- .../combined_open_ended_legend.html | 0 .../combined_open_ended_results.html | 0 .../combined_open_ended_status.html | 0 .../open_ended_result_table.html | 0 .../{ => combinedopenended/openended}/open_ended.html | 0 .../openended}/open_ended_combined_rubric.html | 0 .../openended}/open_ended_error.html | 0 .../openended}/open_ended_evaluation.html | 0 .../openended}/open_ended_feedback.html | 0 .../openended}/open_ended_rubric.html | 0 .../openended}/open_ended_view_only_rubric.html | 0 14 files changed, 16 insertions(+), 12 deletions(-) rename lms/templates/{ => combinedopenended}/combined_open_ended_legend.html (100%) rename lms/templates/{ => combinedopenended}/combined_open_ended_results.html (100%) rename lms/templates/{ => combinedopenended}/combined_open_ended_status.html (100%) rename lms/templates/{ => combinedopenended}/open_ended_result_table.html (100%) rename lms/templates/{ => combinedopenended/openended}/open_ended.html (100%) rename lms/templates/{ => combinedopenended/openended}/open_ended_combined_rubric.html (100%) rename lms/templates/{ => combinedopenended/openended}/open_ended_error.html (100%) rename lms/templates/{ => combinedopenended/openended}/open_ended_evaluation.html (100%) rename lms/templates/{ => combinedopenended/openended}/open_ended_feedback.html (100%) rename lms/templates/{ => combinedopenended/openended}/open_ended_rubric.html (100%) rename lms/templates/{ => combinedopenended/openended}/open_ended_view_only_rubric.html (100%) diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py index 4fc1d1fec5..5c3bfa5b2a 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py @@ -534,7 +534,7 @@ class CombinedOpenEndedV1Module(): 'task_name' : 'Scored Rubric', 'class_name' : 'combined-rubric-container' } - html = self.system.render_template('combined_open_ended_results.html', context) + html = self.system.render_template('{0}/combined_open_ended_results.html'.format(self.TEMPLATE_DIR), context) return {'html': html, 'success': True} def get_legend(self, get): @@ -546,7 +546,7 @@ class CombinedOpenEndedV1Module(): context = { 'legend_list' : LEGEND_LIST, } - html = self.system.render_template('combined_open_ended_legend.html', context) + html = self.system.render_template('{0}/combined_open_ended_legend.html'.format(self.TEMPLATE_DIR), context) return {'html': html, 'success': True} def get_results(self, get): @@ -577,7 +577,7 @@ class CombinedOpenEndedV1Module(): 'submission_id' : ri['submission_ids'][i], } context_list.append(context) - feedback_table = self.system.render_template('open_ended_result_table.html', { + feedback_table = self.system.render_template('{0}/open_ended_result_table.html'.format(self.TEMPLATE_DIR), { 'context_list' : context_list, 'grader_type_image_dict' : GRADER_TYPE_IMAGE_DICT, 'human_grader_types' : HUMAN_GRADER_TYPE, @@ -589,7 +589,7 @@ class CombinedOpenEndedV1Module(): 'task_name' : "Feedback", 'class_name' : "result-container", } - html = self.system.render_template('combined_open_ended_results.html', context) + html = self.system.render_template('{0}/combined_open_ended_results.html'.format(self.TEMPLATE_DIR), context) return {'html': html, 'success': True} def get_status_ajax(self, get): @@ -703,7 +703,7 @@ class CombinedOpenEndedV1Module(): 'legend_list' : LEGEND_LIST, 'render_via_ajax' : render_via_ajax, } - status_html = self.system.render_template("combined_open_ended_status.html", context) + status_html = self.system.render_template("{0}/combined_open_ended_status.html".format(self.TEMPLATE_DIR), context) return status_html diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_rubric.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_rubric.py index f756b2b853..8d1bd376fb 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_rubric.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_rubric.py @@ -30,6 +30,8 @@ class RubricParsingError(Exception): class CombinedOpenEndedRubric(object): + TEMPLATE_DIR = "combinedopenended/openended" + def __init__ (self, system, view_only = False): self.has_score = False self.view_only = view_only @@ -57,9 +59,9 @@ class CombinedOpenEndedRubric(object): rubric_scores = [cat['score'] for cat in rubric_categories] max_scores = map((lambda cat: cat['options'][-1]['points']), rubric_categories) max_score = max(max_scores) - rubric_template = 'open_ended_rubric.html' + rubric_template = '{0}/open_ended_rubric.html'.format(self.TEMPLATE_DIR) if self.view_only: - rubric_template = 'open_ended_view_only_rubric.html' + rubric_template = '{0}/open_ended_view_only_rubric.html'.format(self.TEMPLATE_DIR) html = self.system.render_template(rubric_template, {'categories': rubric_categories, 'has_score': self.has_score, @@ -207,7 +209,7 @@ class CombinedOpenEndedRubric(object): for grader_type in tuple[3]: rubric_categories[i]['options'][j]['grader_types'].append(grader_type) - html = self.system.render_template('open_ended_combined_rubric.html', + html = self.system.render_template('{0}/open_ended_combined_rubric.html'.format(self.TEMPLATE_DIR), {'categories': rubric_categories, 'has_score': True, 'view_only': True, diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py index 974d23965f..aa805a5290 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py @@ -40,6 +40,8 @@ class OpenEndedModule(openendedchild.OpenEndedChild): """ + TEMPLATE_DIR = "combinedopenended/openended" + def setup_response(self, system, location, definition, descriptor): """ Sets up the response type. @@ -397,10 +399,10 @@ class OpenEndedModule(openendedchild.OpenEndedChild): rubric_scores = rubric_dict['rubric_scores'] if not response_items['success']: - return system.render_template("open_ended_error.html", + return system.render_template("{0}/open_ended_error.html".format(self.TEMPLATE_DIR), {'errors': feedback}) - feedback_template = system.render_template("open_ended_feedback.html", { + feedback_template = system.render_template("{0}/open_ended_feedback.html".format(self.TEMPLATE_DIR), { 'grader_type': response_items['grader_type'], 'score': "{0} / {1}".format(response_items['score'], self.max_score()), 'feedback': feedback, @@ -558,7 +560,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild): @return: Rendered html """ context = {'msg': feedback, 'id': "1", 'rows': 50, 'cols': 50} - html = system.render_template('open_ended_evaluation.html', context) + html = system.render_template('{0}/open_ended_evaluation.html'.format(self.TEMPLATE_DIR), context) return html def handle_ajax(self, dispatch, get, system): @@ -692,7 +694,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild): 'accept_file_upload': self.accept_file_upload, 'eta_message' : eta_string, } - html = system.render_template('open_ended.html', context) + html = system.render_template('{0}/open_ended.html'.format(self.TEMPLATE_DIR), context) return html diff --git a/lms/templates/combined_open_ended_legend.html b/lms/templates/combinedopenended/combined_open_ended_legend.html similarity index 100% rename from lms/templates/combined_open_ended_legend.html rename to lms/templates/combinedopenended/combined_open_ended_legend.html diff --git a/lms/templates/combined_open_ended_results.html b/lms/templates/combinedopenended/combined_open_ended_results.html similarity index 100% rename from lms/templates/combined_open_ended_results.html rename to lms/templates/combinedopenended/combined_open_ended_results.html diff --git a/lms/templates/combined_open_ended_status.html b/lms/templates/combinedopenended/combined_open_ended_status.html similarity index 100% rename from lms/templates/combined_open_ended_status.html rename to lms/templates/combinedopenended/combined_open_ended_status.html diff --git a/lms/templates/open_ended_result_table.html b/lms/templates/combinedopenended/open_ended_result_table.html similarity index 100% rename from lms/templates/open_ended_result_table.html rename to lms/templates/combinedopenended/open_ended_result_table.html diff --git a/lms/templates/open_ended.html b/lms/templates/combinedopenended/openended/open_ended.html similarity index 100% rename from lms/templates/open_ended.html rename to lms/templates/combinedopenended/openended/open_ended.html diff --git a/lms/templates/open_ended_combined_rubric.html b/lms/templates/combinedopenended/openended/open_ended_combined_rubric.html similarity index 100% rename from lms/templates/open_ended_combined_rubric.html rename to lms/templates/combinedopenended/openended/open_ended_combined_rubric.html diff --git a/lms/templates/open_ended_error.html b/lms/templates/combinedopenended/openended/open_ended_error.html similarity index 100% rename from lms/templates/open_ended_error.html rename to lms/templates/combinedopenended/openended/open_ended_error.html diff --git a/lms/templates/open_ended_evaluation.html b/lms/templates/combinedopenended/openended/open_ended_evaluation.html similarity index 100% rename from lms/templates/open_ended_evaluation.html rename to lms/templates/combinedopenended/openended/open_ended_evaluation.html diff --git a/lms/templates/open_ended_feedback.html b/lms/templates/combinedopenended/openended/open_ended_feedback.html similarity index 100% rename from lms/templates/open_ended_feedback.html rename to lms/templates/combinedopenended/openended/open_ended_feedback.html diff --git a/lms/templates/open_ended_rubric.html b/lms/templates/combinedopenended/openended/open_ended_rubric.html similarity index 100% rename from lms/templates/open_ended_rubric.html rename to lms/templates/combinedopenended/openended/open_ended_rubric.html diff --git a/lms/templates/open_ended_view_only_rubric.html b/lms/templates/combinedopenended/openended/open_ended_view_only_rubric.html similarity index 100% rename from lms/templates/open_ended_view_only_rubric.html rename to lms/templates/combinedopenended/openended/open_ended_view_only_rubric.html From c24ba23e548666e063a563eadb70cc67d27c7443 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Fri, 1 Mar 2013 13:45:55 -0500 Subject: [PATCH 03/23] Move self assessment templates --- .../open_ended_grading_classes/self_assessment_module.py | 8 +++++--- .../selfassessment}/self_assessment_hint.html | 0 .../selfassessment}/self_assessment_prompt.html | 0 .../selfassessment}/self_assessment_rubric.html | 0 4 files changed, 5 insertions(+), 3 deletions(-) rename lms/templates/{ => combinedopenended/selfassessment}/self_assessment_hint.html (100%) rename lms/templates/{ => combinedopenended/selfassessment}/self_assessment_prompt.html (100%) rename lms/templates/{ => combinedopenended/selfassessment}/self_assessment_rubric.html (100%) diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py index 7ecb3c4d5e..f4be426667 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py @@ -32,6 +32,8 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild): """ + TEMPLATE_DIR = "combinedopenended/selfassessment" + def setup_response(self, system, location, definition, descriptor): """ Sets up the module @@ -68,7 +70,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild): 'accept_file_upload': self.accept_file_upload, } - html = system.render_template('self_assessment_prompt.html', context) + html = system.render_template('{0}/self_assessment_prompt.html'.format(self.TEMPLATE_DIR), context) return html @@ -129,7 +131,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild): #This is a dev_facing_error raise ValueError("Self assessment module is in an illegal state '{0}'".format(self.state)) - return system.render_template('self_assessment_rubric.html', context) + return system.render_template('{0}/self_assessment_rubric.html'.format(self.TEMPLATE_DIR), context) def get_hint_html(self, system): """ @@ -155,7 +157,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild): #This is a dev_facing_error raise ValueError("Self Assessment module is in an illegal state '{0}'".format(self.state)) - return system.render_template('self_assessment_hint.html', context) + return system.render_template('{0}/self_assessment_hint.html'.format(self.TEMPLATE_DIR), context) def save_answer(self, get, system): diff --git a/lms/templates/self_assessment_hint.html b/lms/templates/combinedopenended/selfassessment/self_assessment_hint.html similarity index 100% rename from lms/templates/self_assessment_hint.html rename to lms/templates/combinedopenended/selfassessment/self_assessment_hint.html diff --git a/lms/templates/self_assessment_prompt.html b/lms/templates/combinedopenended/selfassessment/self_assessment_prompt.html similarity index 100% rename from lms/templates/self_assessment_prompt.html rename to lms/templates/combinedopenended/selfassessment/self_assessment_prompt.html diff --git a/lms/templates/self_assessment_rubric.html b/lms/templates/combinedopenended/selfassessment/self_assessment_rubric.html similarity index 100% rename from lms/templates/self_assessment_rubric.html rename to lms/templates/combinedopenended/selfassessment/self_assessment_rubric.html From a81819129719c311c0547810d91eb3c3ff3ce736 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Fri, 1 Mar 2013 14:12:04 -0500 Subject: [PATCH 04/23] Prelim support for combinedopenended and peergrading types --- cms/djangoapps/contentstore/views.py | 3 +- .../templates/combinedopenended/default.yaml | 54 +++++++++++++++++++ .../templates/peer_grading/default.yaml | 12 +++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml create mode 100644 common/lib/xmodule/xmodule/templates/peer_grading/default.yaml diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index b55dc13e58..700f7b6ad4 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -66,7 +66,7 @@ from cms.djangoapps.models.settings.course_metadata import CourseMetadata log = logging.getLogger(__name__) -COMPONENT_TYPES = ['customtag', 'discussion', 'html', 'problem', 'video'] +COMPONENT_TYPES = ['customtag', 'discussion', 'html', 'problem', 'video', 'peergrading', 'combinedopenended'] # cdodge: these are categories which should not be parented, they are detached from the hierarchy DETACHED_CATEGORIES = ['about', 'static_tab', 'course_info'] @@ -282,6 +282,7 @@ def edit_unit(request, location): component_templates = defaultdict(list) templates = modulestore().get_items(Location('i4x', 'edx', 'templates')) + log.debug(templates) for template in templates: if template.location.category in COMPONENT_TYPES: component_templates[template.location.category].append(( diff --git a/common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml b/common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml new file mode 100644 index 0000000000..48daa6f139 --- /dev/null +++ b/common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml @@ -0,0 +1,54 @@ +--- +metadata: + display_name: Open Ended Response + rerandomize: never + showanswer: never + weight: "" + attempts: 10 + max_score: 2 + is_graded: False + version: 1 + display_name: Test Question +data: | + + + + + Category 1 + + + + + Hydrophobia + + + + + + +

Why is the sky blue?

+
+ + + + + + + Enter essay here. + This is the answer. + {"grader_settings" : "peer_grading.conf", "problem_id" : "700x/Demo"} + + + +
+ + +children: [] diff --git a/common/lib/xmodule/xmodule/templates/peer_grading/default.yaml b/common/lib/xmodule/xmodule/templates/peer_grading/default.yaml new file mode 100644 index 0000000000..3ffb5cff2f --- /dev/null +++ b/common/lib/xmodule/xmodule/templates/peer_grading/default.yaml @@ -0,0 +1,12 @@ +--- +metadata: + display_name: Peer Grading Interface + rerandomize: never + showanswer: never + weight: "" + attempts: "" +data: | + + + +children: [] From 9f020e228b9c9d39cb7c25db46a726b854b10185 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Fri, 1 Mar 2013 14:50:40 -0500 Subject: [PATCH 05/23] Add in some dummy values --- cms/djangoapps/contentstore/views.py | 15 +++++++++++++-- cms/static/sass/_graphics.scss | 8 ++++++++ common/lib/xmodule/xmodule/peer_grading_module.py | 4 ++++ .../templates/combinedopenended/default.yaml | 13 ++----------- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 700f7b6ad4..d300562358 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -66,7 +66,11 @@ from cms.djangoapps.models.settings.course_metadata import CourseMetadata log = logging.getLogger(__name__) -COMPONENT_TYPES = ['customtag', 'discussion', 'html', 'problem', 'video', 'peergrading', 'combinedopenended'] +COMPONENT_TYPES = ['customtag', 'discussion', 'html', 'problem', 'video', 'combinedopenended', 'peergrading'] + +ADVANCED_COMPONENT_TYPES = { + 'openended' : ['combinedopenended', 'peergrading'] +} # cdodge: these are categories which should not be parented, they are detached from the hierarchy DETACHED_CATEGORIES = ['about', 'static_tab', 'course_info'] @@ -285,7 +289,14 @@ def edit_unit(request, location): log.debug(templates) for template in templates: if template.location.category in COMPONENT_TYPES: - component_templates[template.location.category].append(( + #This is a hack to create categories for different xmodules + category = template.location.category + for key in ADVANCED_COMPONENT_TYPES: + if template.location.category in ADVANCED_COMPONENT_TYPES[key]: + category = key + break + + component_templates[category].append(( template.display_name, template.location.url(), 'markdown' in template.metadata, diff --git a/cms/static/sass/_graphics.scss b/cms/static/sass/_graphics.scss index 4ed22c570d..619c66a919 100644 --- a/cms/static/sass/_graphics.scss +++ b/cms/static/sass/_graphics.scss @@ -254,6 +254,14 @@ background: url(../img/html-icon.png) center no-repeat; } +.large-openended-icon { + display: inline-block; + width: 100px; + height: 60px; + margin-right: 5px; + background: url(../img/large-problem-icon.png) center no-repeat; +} + .large-textbook-icon { display: inline-block; width: 100px; diff --git a/common/lib/xmodule/xmodule/peer_grading_module.py b/common/lib/xmodule/xmodule/peer_grading_module.py index 16c118a434..067834a7a0 100644 --- a/common/lib/xmodule/xmodule/peer_grading_module.py +++ b/common/lib/xmodule/xmodule/peer_grading_module.py @@ -456,6 +456,7 @@ class PeerGradingModule(XModule): try: problem_list_json = self.peer_gs.get_problem_list(self.system.course_id, self.system.anonymous_student_id) problem_list_dict = problem_list_json + log.debug(problem_list_dict) success = problem_list_dict['success'] if 'error' in problem_list_dict: error_text = problem_list_dict['error'] @@ -471,6 +472,9 @@ class PeerGradingModule(XModule): #This is a student_facing_error error_text = "Could not get list of problems to peer grade. Please notify course staff." success = False + except: + log.exception("Could not contact peer grading service.") + success = False def _find_corresponding_module_for_location(location): diff --git a/common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml b/common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml index 48daa6f139..d60e576a21 100644 --- a/common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml +++ b/common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml @@ -5,12 +5,12 @@ metadata: showanswer: never weight: "" attempts: 10 - max_score: 2 + max_score: 1 is_graded: False version: 1 display_name: Test Question data: | - + @@ -22,15 +22,6 @@ data: | The response is correct for category 1. - - Hydrophobia - - - From 67b73242ea1d2789d284159ef39edf1c0f2e2c37 Mon Sep 17 00:00:00 2001 From: Arthur Barrett Date: Fri, 1 Mar 2013 15:11:42 -0500 Subject: [PATCH 06/23] added advanced component button with ability to specify components in course policy. --- cms/djangoapps/contentstore/views.py | 33 +++++++++++++++++++++------- cms/templates/unit.html | 2 +- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index b55dc13e58..4b925d53e0 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -66,7 +66,12 @@ from cms.djangoapps.models.settings.course_metadata import CourseMetadata log = logging.getLogger(__name__) -COMPONENT_TYPES = ['customtag', 'discussion', 'html', 'problem', 'video'] +COMPONENT_TYPES = ['customtag', 'discussion', 'html', 'problem', 'video', 'advanced'] + +# advanced/beta components that can be enabled for all courses or per-course in the policy file +ADVANCED_COMPONENT_TYPES = [] +ADVANCED_COMPONENT_CATEGORY = 'advanced' +ADVANCED_COMPONENT_POLICY_KEY = 'enable_advanced_modules' # cdodge: these are categories which should not be parented, they are detached from the hierarchy DETACHED_CATEGORIES = ['about', 'static_tab', 'course_info'] @@ -281,15 +286,26 @@ def edit_unit(request, location): component_templates = defaultdict(list) + # check if there are any advanced modules specified in the course policy + advanced_component_types = list(ADVANCED_COMPONENT_TYPES) + course_metadata = CourseMetadata.fetch(course.location) + advanced_component_types.extend(course_metadata.get(ADVANCED_COMPONENT_POLICY_KEY, [])) + templates = modulestore().get_items(Location('i4x', 'edx', 'templates')) for template in templates: - if template.location.category in COMPONENT_TYPES: - component_templates[template.location.category].append(( - template.display_name, - template.location.url(), - 'markdown' in template.metadata, - 'empty' in template.metadata - )) + component_template = ( + template.display_name, + template.location.url(), + 'markdown' in template.metadata, + 'empty' in template.metadata + ) + if template.location.category in COMPONENT_TYPES: + component_templates[template.location.category].append(component_template) + elif template.location.category in advanced_component_types: + component_templates[ADVANCED_COMPONENT_CATEGORY].append(component_template) + + # order of component types for display purposes + component_template_types = [type for type in COMPONENT_TYPES if type in component_templates.keys()] components = [ component.location.url() @@ -341,6 +357,7 @@ def edit_unit(request, location): 'unit_location': location, 'components': components, 'component_templates': component_templates, + 'component_template_types': component_template_types, 'draft_preview_link': preview_lms_link, 'published_preview_link': lms_link, 'subsection': containing_subsection, diff --git a/cms/templates/unit.html b/cms/templates/unit.html index c529f5863a..686aaa9ba1 100644 --- a/cms/templates/unit.html +++ b/cms/templates/unit.html @@ -53,7 +53,7 @@
Add New Component