Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
79b3af87
Commit
79b3af87
authored
Sep 06, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tabs to spaces
parent
1b4f9c66
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
82 deletions
+82
-82
cms/static/js/views/grader-select-view.js
+82
-82
No files found.
cms/static/js/views/grader-select-view.js
View file @
79b3af87
CMS
.
Models
.
AssignmentGrade
=
Backbone
.
Model
.
extend
({
defaults
:
{
graderType
:
null
,
// the type label (string). May be "Not Graded" which implies None. I'd like to use id but that's ephemeral
location
:
null
// A location object
},
initialize
:
function
(
attrs
)
{
if
(
attrs
[
'assignmentUrl'
])
{
this
.
set
(
'location'
,
new
CMS
.
Models
.
Location
(
attrs
[
'assignmentUrl'
],
{
parse
:
true
}));
}
},
parse
:
function
(
attrs
)
{
if
(
attrs
&&
attrs
[
'location'
])
{
attrs
.
location
=
new
CMS
.
Models
.
Location
(
attrs
[
'location'
],
{
parse
:
true
});
}
},
urlRoot
:
function
()
{
if
(
this
.
has
(
'location'
))
{
var
location
=
this
.
get
(
'location'
);
return
'/'
+
location
.
get
(
'org'
)
+
"/"
+
location
.
get
(
'course'
)
+
'/'
+
location
.
get
(
'category'
)
+
'/'
+
location
.
get
(
'name'
)
+
'/gradeas/'
;
}
else
return
""
;
}
defaults
:
{
graderType
:
null
,
// the type label (string). May be "Not Graded" which implies None. I'd like to use id but that's ephemeral
location
:
null
// A location object
},
initialize
:
function
(
attrs
)
{
if
(
attrs
[
'assignmentUrl'
])
{
this
.
set
(
'location'
,
new
CMS
.
Models
.
Location
(
attrs
[
'assignmentUrl'
],
{
parse
:
true
}));
}
},
parse
:
function
(
attrs
)
{
if
(
attrs
&&
attrs
[
'location'
])
{
attrs
.
location
=
new
CMS
.
Models
.
Location
(
attrs
[
'location'
],
{
parse
:
true
});
}
},
urlRoot
:
function
()
{
if
(
this
.
has
(
'location'
))
{
var
location
=
this
.
get
(
'location'
);
return
'/'
+
location
.
get
(
'org'
)
+
"/"
+
location
.
get
(
'course'
)
+
'/'
+
location
.
get
(
'category'
)
+
'/'
+
location
.
get
(
'name'
)
+
'/gradeas/'
;
}
else
return
""
;
}
});
CMS
.
Views
.
OverviewAssignmentGrader
=
Backbone
.
View
.
extend
({
// instantiate w/ { graders : CourseGraderCollection, el : <the gradable-status div> }
events
:
{
"click .menu-toggle"
:
"showGradeMenu"
,
"click .menu li"
:
"selectGradeType"
},
initialize
:
function
()
{
// call template w/ {assignmentType : formatname, graders : CourseGraderCollection instance }
this
.
template
=
_
.
template
(
// 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="#">'
+
'<% if (!hideSymbol) {%><i class="icon-ok"></i><%};%>'
+
'</a>'
+
'<ul class="menu">'
+
'<% graders.each(function(option) { %>'
+
'<li><a <% if (option.get("type") == assignmentType) {%>class="is-selected" <%}%> href="#"><%= option.get("type") %></a></li>'
+
'<% }) %>'
+
'<li><a class="gradable-status-notgraded" href="#">Not Graded</a></li>'
+
'</ul>'
);
this
.
assignmentGrade
=
new
CMS
.
Models
.
AssignmentGrade
({
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'
];
var
cachethis
=
this
;
// defining here to get closure around this
this
.
removeMenu
=
function
(
e
)
{
e
.
preventDefault
();
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
,
hideSymbol
:
this
.
hideSymbol
}));
if
(
this
.
assignmentGrade
.
has
(
'graderType'
)
&&
this
.
assignmentGrade
.
get
(
'graderType'
)
!=
"Not Graded"
)
{
this
.
$el
.
addClass
(
'is-set'
);
}
else
{
this
.
$el
.
removeClass
(
'is-set'
);
}
},
showGradeMenu
:
function
(
e
)
{
e
.
preventDefault
();
// I sure hope this doesn't break anything but it's needed to keep the removeMenu from activating
e
.
stopPropagation
();
// nasty global event trap :-(
$
(
document
).
on
(
'click'
,
this
.
removeMenu
);
this
.
$el
.
addClass
(
'is-active'
);
},
selectGradeType
:
function
(
e
)
{
e
.
preventDefault
();
// instantiate w/ { graders : CourseGraderCollection, el : <the gradable-status div> }
events
:
{
"click .menu-toggle"
:
"showGradeMenu"
,
"click .menu li"
:
"selectGradeType"
},
initialize
:
function
()
{
// call template w/ {assignmentType : formatname, graders : CourseGraderCollection instance }
this
.
template
=
_
.
template
(
// 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="#">'
+
'<% if (!hideSymbol) {%><i class="icon-ok"></i><%};%>'
+
'</a>'
+
'<ul class="menu">'
+
'<% graders.each(function(option) { %>'
+
'<li><a <% if (option.get("type") == assignmentType) {%>class="is-selected" <%}%> href="#"><%= option.get("type") %></a></li>'
+
'<% }) %>'
+
'<li><a class="gradable-status-notgraded" href="#">Not Graded</a></li>'
+
'</ul>'
);
this
.
assignmentGrade
=
new
CMS
.
Models
.
AssignmentGrade
({
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'
];
var
cachethis
=
this
;
// defining here to get closure around this
this
.
removeMenu
=
function
(
e
)
{
e
.
preventDefault
();
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
,
hideSymbol
:
this
.
hideSymbol
}));
if
(
this
.
assignmentGrade
.
has
(
'graderType'
)
&&
this
.
assignmentGrade
.
get
(
'graderType'
)
!=
"Not Graded"
)
{
this
.
$el
.
addClass
(
'is-set'
);
}
else
{
this
.
$el
.
removeClass
(
'is-set'
);
}
},
showGradeMenu
:
function
(
e
)
{
e
.
preventDefault
();
// I sure hope this doesn't break anything but it's needed to keep the removeMenu from activating
e
.
stopPropagation
();
// nasty global event trap :-(
$
(
document
).
on
(
'click'
,
this
.
removeMenu
);
this
.
$el
.
addClass
(
'is-active'
);
},
selectGradeType
:
function
(
e
)
{
e
.
preventDefault
();
this
.
removeMenu
(
e
);
this
.
removeMenu
(
e
);
var
saving
=
new
CMS
.
Views
.
Notification
.
Mini
({
title
:
gettext
(
'Saving'
)
+
'…'
});
saving
.
show
();
// TODO I'm not happy with this string fetch via the html for what should be an id. I'd rather use the id attr
// of the CourseGradingPolicy model or null for Not Graded (NOTE, change template's if check for is-selected accordingly)
this
.
assignmentGrade
.
save
(
// TODO I'm not happy with this string fetch via the html for what should be an id. I'd rather use the id attr
// of the CourseGradingPolicy model or null for Not Graded (NOTE, change template's if check for is-selected accordingly)
this
.
assignmentGrade
.
save
(
'graderType'
,
$
(
e
.
target
).
text
(),
{
success
:
function
()
{
saving
.
hide
();
}}
);
this
.
render
();
}
this
.
render
();
}
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment