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
546096e8
Commit
546096e8
authored
Nov 15, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split out mock backend, fix out-of-data bug
parent
3d0ef758
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
32 deletions
+52
-32
lms/static/coffee/src/staff_grading/staff_grading.coffee
+52
-32
No files found.
lms/static/coffee/src/staff_grading/staff_grading.coffee
View file @
546096e8
...
@@ -8,48 +8,47 @@ state_grading = "have_data"
...
@@ -8,48 +8,47 @@ state_grading = "have_data"
state_no_data
=
"no_data"
state_no_data
=
"no_data"
state_error
=
"error"
state_error
=
"error"
class
StaffGrading
class
StaffGradingBackend
constructor
:
(
mock_backend
)
->
constructor
:
(
ajax_url
,
mock_backend
)
->
@
el
=
$
(
'.staff-grading'
)
@
ajax_url
=
ajax_url
@
ajax_url
=
@
el
.
data
(
'ajax_url'
)
@
error_container
=
$
(
'.error-container'
)
@
submission_container
=
$
(
'.submission-container'
)
@
rubric_container
=
$
(
'.rubric-container'
)
@
button
=
$
(
'.submit-button'
)
@
button
.
click
@
clicked
@
state
=
state_no_data
@
mock_backend
=
mock_backend
@
mock_backend
=
mock_backend
if
@
mock_backend
if
@
mock_backend
@
mock_cnt
=
0
@
mock_cnt
=
0
@
get_next_submission
()
mock
:
(
cmd
,
data
)
->
mock
:
(
cmd
,
data
)
->
# Return a mock response to cmd and data
# Return a mock response to cmd and data
@
mock_cnt
++
@
mock_cnt
++
if
cmd
==
'get_next'
if
cmd
==
'get_next'
response
=
response
=
'success'
:
true
success
:
true
'submission'
:
'submission! '
+
@
mock_cnt
submission
:
'submission! '
+
@
mock_cnt
'rubric'
:
'A rubric!'
+
@
mock_cnt
rubric
:
'A rubric!'
+
@
mock_cnt
else
if
cmd
==
'save_grade'
else
if
cmd
==
'save_grade'
response
=
response
=
'success'
:
true
success
:
true
'submission'
:
'another submission! '
+
@
mock_cnt
submission
:
'another submission! '
+
@
mock_cnt
'rubric'
:
'A rubric!'
+
@
mock_cnt
rubric
:
'A rubric!'
+
@
mock_cnt
else
else
response
=
response
=
'success'
:
false
success
:
false
'error'
:
'Unknown command '
+
cmd
error
:
'Unknown command '
+
cmd
return
response
if
@
mock_cnt
%
5
==
0
response
=
success
:
true
message
:
'No more submissions'
if
@
mock_cnt
%
7
==
0
response
=
success
:
false
error
:
'An error for testing'
return
response
set_button_text
:
(
text
)
->
@
button
.
prop
(
'value'
,
text
)
_
post
:
(
cmd
,
data
,
callback
)
->
post
:
(
cmd
,
data
,
callback
)
->
if
@
mock_backend
if
@
mock_backend
callback
(
@
mock
(
cmd
,
data
))
callback
(
@
mock
(
cmd
,
data
))
else
else
...
@@ -57,6 +56,24 @@ class StaffGrading
...
@@ -57,6 +56,24 @@ class StaffGrading
$
.
post
(
@
ajax_url
+
cmd
,
data
,
callback
)
$
.
post
(
@
ajax_url
+
cmd
,
data
,
callback
)
class
StaffGrading
constructor
:
(
backend
)
->
@
backend
=
backend
@
error_container
=
$
(
'.error-container'
)
@
submission_container
=
$
(
'.submission-container'
)
@
rubric_container
=
$
(
'.rubric-container'
)
@
button
=
$
(
'.submit-button'
)
@
button
.
click
@
clicked
@
state
=
state_no_data
@
get_next_submission
()
set_button_text
:
(
text
)
->
@
button
.
prop
(
'value'
,
text
)
ajax_callback
:
(
response
)
=>
ajax_callback
:
(
response
)
=>
if
response
.
success
if
response
.
success
if
response
.
submission
if
response
.
submission
...
@@ -67,11 +84,11 @@ class StaffGrading
...
@@ -67,11 +84,11 @@ class StaffGrading
@
error
(
response
.
error
)
@
error
(
response
.
error
)
get_next_submission
:
()
->
get_next_submission
:
()
->
@
_
post
(
'get_next'
,
{},
@
ajax_callback
)
@
backend
.
post
(
'get_next'
,
{},
@
ajax_callback
)
submit_and_get_next
:
()
->
submit_and_get_next
:
()
->
data
=
{
eval
:
'123'
}
data
=
{
eval
:
'123'
}
@
_
post
(
'save_grade'
,
data
,
@
ajax_callback
)
@
backend
.
post
(
'save_grade'
,
data
,
@
ajax_callback
)
error
:
(
msg
)
->
error
:
(
msg
)
->
@
error_container
.
html
(
msg
)
@
error_container
.
html
(
msg
)
...
@@ -85,8 +102,8 @@ class StaffGrading
...
@@ -85,8 +102,8 @@ class StaffGrading
@
update
()
@
update
()
no_more
:
()
->
no_more
:
()
->
@
submission_container
.
html
(
submission
)
@
submission_container
.
html
(
''
)
@
rubric_container
.
html
(
rubric
)
@
rubric_container
.
html
(
''
)
@
state
=
state_no_data
@
state
=
state_no_data
@
update
()
@
update
()
...
@@ -117,5 +134,8 @@ class StaffGrading
...
@@ -117,5 +134,8 @@ class StaffGrading
# for now, just create an instance and load it...
# for now, just create an instance and load it...
mock_backend
=
true
mock_backend
=
true
$
(
document
).
ready
(()
->
new
StaffGrading
(
mock_backend
))
ajax_url
=
$
(
'.staff-grading'
).
data
(
'ajax_url'
)
backend
=
new
StaffGradingBackend
(
ajax_url
,
mock_backend
)
$
(
document
).
ready
(()
->
new
StaffGrading
(
backend
))
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