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
e1fd6d73
Commit
e1fd6d73
authored
Nov 15, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor to be more clearly model-view
parent
b1d5273a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
29 deletions
+55
-29
lms/static/coffee/src/staff_grading/staff_grading.coffee
+54
-29
lms/static/coffee/src/staff_grading/test_grading.html
+1
-0
No files found.
lms/static/coffee/src/staff_grading/staff_grading.coffee
View file @
e1fd6d73
...
@@ -25,6 +25,7 @@ class StaffGradingBackend
...
@@ -25,6 +25,7 @@ class StaffGradingBackend
rubric
:
'A rubric!'
+
@
mock_cnt
rubric
:
'A rubric!'
+
@
mock_cnt
else
if
cmd
==
'save_grade'
else
if
cmd
==
'save_grade'
console
.
log
(
"eval:
#{
data
.
score
}
pts, Feedback:
#{
data
.
feedback
}
"
)
response
=
response
=
success
:
true
success
:
true
submission
:
'another submission! '
+
@
mock_cnt
submission
:
'another submission! '
+
@
mock_cnt
...
@@ -60,6 +61,7 @@ class StaffGrading
...
@@ -60,6 +61,7 @@ class StaffGrading
constructor
:
(
backend
)
->
constructor
:
(
backend
)
->
@
backend
=
backend
@
backend
=
backend
# all the jquery selectors
@
error_container
=
$
(
'.error-container'
)
@
error_container
=
$
(
'.error-container'
)
@
message_container
=
$
(
'.message-container'
)
@
message_container
=
$
(
'.message-container'
)
@
submission_container
=
$
(
'.submission-container'
)
@
submission_container
=
$
(
'.submission-container'
)
...
@@ -67,75 +69,98 @@ class StaffGrading
...
@@ -67,75 +69,98 @@ class StaffGrading
@
submission_wrapper
=
$
(
'.submission-wrapper'
)
@
submission_wrapper
=
$
(
'.submission-wrapper'
)
@
rubric_wrapper
=
$
(
'.rubric-wrapper'
)
@
rubric_wrapper
=
$
(
'.rubric-wrapper'
)
@
button
=
$
(
'.submit-button'
)
@
button
=
$
(
'.submit-button'
)
@
button
.
click
@
clicked
# model state
@
state
=
state_no_data
@
state
=
state_no_data
@
submission
=
''
@
rubric
=
''
@
error_msg
=
''
@
message
=
''
@
feedback
=
null
@
score
=
null
# action handlers
@
button
.
click
@
clicked
@
submission_wrapper
.
hide
()
# render intial state
@
r
ubric_wrapper
.
hide
()
@
r
ender_view
()
# send initial request automatically
@
get_next_submission
()
@
get_next_submission
()
set_button_text
:
(
text
)
->
set_button_text
:
(
text
)
->
@
button
.
prop
(
'value'
,
text
)
@
button
.
prop
(
'value'
,
text
)
ajax_callback
:
(
response
)
=>
ajax_callback
:
(
response
)
=>
if
response
.
success
# always clear out errors and messages on transition.
if
response
.
submission
@
error_msg
=
''
@
data_loaded
(
response
.
submission
,
response
.
rubric
)
@
message
=
''
else
@
no_more
()
if
response
.
success
if
response
.
submission
@
data_loaded
(
response
.
submission
,
response
.
rubric
)
else
else
@
error
(
response
.
error
)
@
no_more
()
else
@
error
(
response
.
error
)
@
render_view
()
get_next_submission
:
()
->
get_next_submission
:
()
->
@
backend
.
post
(
'get_next'
,
{},
@
ajax_callback
)
@
backend
.
post
(
'get_next'
,
{},
@
ajax_callback
)
submit_and_get_next
:
()
->
submit_and_get_next
:
()
->
data
=
{
eval
:
'123'
}
data
=
{
score
:
'1'
,
feedback
:
'Great!'
}
@
backend
.
post
(
'save_grade'
,
data
,
@
ajax_callback
)
@
backend
.
post
(
'save_grade'
,
data
,
@
ajax_callback
)
error
:
(
msg
)
->
error
:
(
msg
)
->
@
error_
container
.
html
(
msg
)
@
error_
msg
=
msg
@
state
=
state_error
@
state
=
state_error
@
update
()
data_loaded
:
(
submission
,
rubric
)
->
data_loaded
:
(
submission
,
rubric
)
->
@
submission
_container
.
html
(
submission
)
@
submission
=
submission
@
rubric
_container
.
html
(
rubric
)
@
rubric
=
rubric
@
state
=
state_grading
@
state
=
state_grading
@
update
()
no_more
:
()
->
no_more
:
()
->
@
submission
=
null
@
rubric
=
null
@
message
=
'Nothing to grade'
@
state
=
state_no_data
@
state
=
state_no_data
@
update
()
update
:
()
->
render_view
:
()
->
# make button and div state match the state. Idempotent.
# make the view elements match the state. Idempotent.
show_grading_elements
=
false
@
message_container
.
html
(
@
message
)
@
error_container
.
html
(
@
error_msg
)
if
@
state
==
state_error
if
@
state
==
state_error
@
set_button_text
(
'Try loading again'
)
@
set_button_text
(
'Try loading again'
)
else
if
@
state
==
state_grading
else
if
@
state
==
state_grading
@
submission_wrapper
.
show
()
@
submission_container
.
html
(
@
submission
)
@
rubric_wrapper
.
show
()
@
rubric_container
.
html
(
@
rubric
)
show_grading_elements
=
true
@
set_button_text
(
'Submit'
)
@
set_button_text
(
'Submit'
)
else
if
@
state
==
state_no_data
else
if
@
state
==
state_no_data
@
submission_wrapper
.
hide
()
@
message_container
.
html
(
@
message
)
@
rubric_wrapper
.
hide
()
@
message_container
.
html
(
'Nothing to grade'
)
@
set_button_text
(
'Re-check for submissions'
)
@
set_button_text
(
'Re-check for submissions'
)
else
else
@
error
(
'System got into invalid state '
+
@
state
)
@
error
(
'System got into invalid state '
+
@
state
)
@
submission_wrapper
.
toggle
(
show_grading_elements
)
@
rubric_wrapper
.
toggle
(
show_grading_elements
)
clicked
:
(
event
)
=>
clicked
:
(
event
)
=>
event
.
preventDefault
()
event
.
preventDefault
()
# always clear out errors and messages on transition...
@
message_container
.
html
(
''
)
@
error_container
.
html
(
''
)
if
@
state
==
state_error
if
@
state
==
state_error
@
get_next_submission
()
@
get_next_submission
()
else
if
@
state
==
state_grading
else
if
@
state
==
state_grading
...
...
lms/static/coffee/src/staff_grading/test_grading.html
View file @
e1fd6d73
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
<h3>
Rubric
</h3>
<h3>
Rubric
</h3>
<div
class=
"rubric-container"
>
<div
class=
"rubric-container"
>
</div>
</div>
</section>
</section>
<div
class=
"submission"
>
<div
class=
"submission"
>
...
...
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