Commit e37180e0 by Don Mitchell

Generalized the grader drop down and applied to edit_subsection

parent 08d5ab0a
......@@ -226,6 +226,8 @@ def edit_subsection(request, location):
'create_new_unit_template': Location('i4x', 'edx', 'templates', 'vertical', 'Empty'),
'lms_link': lms_link,
'preview_link': preview_link,
'course_graders': json.dumps(CourseGradingModel.fetch(course.location).graders),
'parent_location': course.location,
'parent_item': parent,
'policy_metadata' : policy_metadata,
'subsection_units' : subsection_units,
......
......@@ -35,7 +35,7 @@ CMS.Views.OverviewAssignmentGrader = Backbone.View.extend({
// TODO move to a template file
'<h4 class="status-label"><%= assignmentType %></h4>' +
'<a data-tooltip="Mark/unmark this subsection as graded" class="menu-toggle" href="#">' +
'<span class="ss-icon ss-standard">&#x2713;</span>' +
'<% if (!hideSymbol) {%><span class="ss-icon ss-standard">&#x2713;</span><%};%>' +
'</a>' +
'<ul class="menu">' +
'<% graders.each(function(option) { %>' +
......@@ -44,7 +44,7 @@ CMS.Views.OverviewAssignmentGrader = Backbone.View.extend({
'<li><a class="gradable-status-notgraded" href="#">Not Graded</a></li>' +
'</ul>');
this.assignmentGrade = new CMS.Models.AssignmentGrade({
assignmentUrl : this.$el.closest('.branch').data('id'),
assignmentUrl : this.$el.closest('.id-holder').data('id'),
graderType : this.$el.data('initial-status')});
// TODO throw exception if graders is null
this.graders = this.options['graders'];
......@@ -55,10 +55,12 @@ CMS.Views.OverviewAssignmentGrader = Backbone.View.extend({
cachethis.$el.removeClass('is-active');
$(document).off('click', cachethis.removeMenu);
}
this.hideSymbol = this.options['hideSymbol'];
this.render();
},
render : function() {
this.$el.html(this.template({ assignmentType : this.assignmentGrade.get('graderType'), graders : this.graders }));
this.$el.html(this.template({ assignmentType : this.assignmentGrade.get('graderType'), graders : this.graders,
hideSymbol : this.hideSymbol }));
if (this.assignmentGrade.has('graderType') && this.assignmentGrade.get('graderType') != "Not Graded") {
this.$el.addClass('is-set');
}
......
......@@ -47,7 +47,7 @@
</div>
<div class="sidebar">
<div class="unit-settings window">
<div class="unit-settings window id-holder" data-id="${subsection.location}">
<h4>Subsection Settings</h4>
<div class="window-contents">
<div class="scheduled-date-input row">
......@@ -70,26 +70,11 @@
% endif
</div>
<!-- <div class="row gradable">
<div class="row gradable">
<label>Graded as:</label>
<div class="gradable-status">
<h4 class="status-label">Not Graded</h4>
<a class="menu-toggle" href="#">
</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="gradable-status" data-initial-status="${subsection.metadata.get('format', 'Not Graded')}">
</div>
<div class="due-date-input row">
<label>Due date:</label>
......@@ -123,13 +108,11 @@
<script src="${static.url('js/vendor/timepicker/jquery.timepicker.js')}"></script>
<script src="${static.url('js/vendor/timepicker/datepair.js')}"></script>
<script src="${static.url('js/vendor/date.js')}"></script>
<script type="text/javascript">
// (function() {
// $body = $('body');
// $('.gradable-status .menu-toggle').bind('click', showGradeMenu);
// $('.gradable-status .menu').bind('click', selectGradeType);
// })();
<script type="text/javascript" src="${static.url('js/models/course_relative.js')}"></script>
<script type="text/javascript" src="${static.url('js/views/grader-select-view.js')}"></script>
<script type="text/javascript" src="${static.url('js/models/settings/course_grading_policy.js')}"></script>
<script type="text/javascript">
$(document).ready(function() {
// expand the due-date area if the values are set
if ($('#due_date').val() != '') {
......@@ -137,28 +120,23 @@
$('.set-date').hide();
$block.find('.date-setter').show();
}
// TODO figure out whether these should be in window or someplace else or whether they're only needed as local vars
// I believe that current (New Section/New Subsection) cause full page reloads which means these aren't needed globally
// but we really should change that behavior.
if (!window.graderTypes) {
window.graderTypes = new CMS.Models.Settings.CourseGraderCollection();
window.graderTypes.course_location = new CMS.Models.Location('${parent_location}');
window.graderTypes.reset(${course_graders|n});
}
$(".gradable-status").each(function(index, ele) {
var gradeView = new CMS.Views.OverviewAssignmentGrader({
el : ele,
graders : window.graderTypes,
hideSymbol : true
});
});
})
// grading status
// 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>
</%block>
......@@ -25,9 +25,11 @@
// TODO figure out whether these should be in window or someplace else or whether they're only needed as local vars
// I believe that current (New Section/New Subsection) cause full page reloads which means these aren't needed globally
// but we really should change that behavior.
window.graderTypes = new CMS.Models.Settings.CourseGraderCollection();
window.graderTypes.course_location = new CMS.Models.Location('${parent_location}');
window.graderTypes.reset(${course_graders|n});
if (!window.graderTypes) {
window.graderTypes = new CMS.Models.Settings.CourseGraderCollection();
window.graderTypes.course_location = new CMS.Models.Location('${parent_location}');
window.graderTypes.reset(${course_graders|n});
}
$(".gradable-status").each(function(index, ele) {
var gradeView = new CMS.Views.OverviewAssignmentGrader({
......@@ -153,10 +155,6 @@
</div>
</div>
<!-- temporarily disable until we figure out inheritance
<div class="gradable-status" data-initial-status="${section.metadata.get('format', 'Not Graded')}">
</div> -->
<div class="item-actions">
<a href="#" data-tooltip="Delete this section" class="delete-button delete-section-button"><span class="delete-icon"></span></a>
<a href="#" data-tooltip="Drag to reorder" class="drag-handle"></a>
......@@ -170,7 +168,7 @@
</div>
<ol data-section-id="${section.location.url()}">
% for subsection in section.get_children():
<li class="branch collapsed" data-id="${subsection.location}">
<li class="branch collapsed id-holder" data-id="${subsection.location}">
<div class="section-item">
<div class="details">
<a href="#" data-tooltip="Expand/collapse this subsection" class="expand-collapse-icon expand"></a>
......
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