Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-drag-and-drop-v2
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
OpenEdx
xblock-drag-and-drop-v2
Commits
27dcf96e
Commit
27dcf96e
authored
Aug 20, 2014
by
dragonfi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add completed flag to only publish the grade once
parent
f0215eec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
drag_and_drop_v2/drag_and_drop_v2.py
+19
-10
No files found.
drag_and_drop_v2/drag_and_drop_v2.py
View file @
27dcf96e
...
@@ -10,7 +10,7 @@ import copy
...
@@ -10,7 +10,7 @@ import copy
import
urllib
import
urllib
from
xblock.core
import
XBlock
from
xblock.core
import
XBlock
from
xblock.fields
import
Scope
,
String
,
Dict
,
Float
from
xblock.fields
import
Scope
,
String
,
Dict
,
Float
,
Boolean
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
from
.utils
import
render_template
,
load_resource
from
.utils
import
render_template
,
load_resource
...
@@ -62,6 +62,12 @@ class DragAndDropBlock(XBlock):
...
@@ -62,6 +62,12 @@ class DragAndDropBlock(XBlock):
default
=
{}
default
=
{}
)
)
completed
=
Boolean
(
help
=
"The student has completed the problem at least once"
,
scope
=
Scope
.
user_state
,
default
=
False
)
has_score
=
True
has_score
=
True
def
student_view
(
self
,
context
):
def
student_view
(
self
,
context
):
...
@@ -173,15 +179,18 @@ class DragAndDropBlock(XBlock):
...
@@ -173,15 +179,18 @@ class DragAndDropBlock(XBlock):
if
self
.
_is_finished
():
if
self
.
_is_finished
():
final_feedback
=
self
.
data
[
'feedback'
][
'finish'
]
final_feedback
=
self
.
data
[
'feedback'
][
'finish'
]
try
:
# only publish the grade once
self
.
runtime
.
publish
(
self
,
'grade'
,
{
if
not
self
.
completed
:
'value'
:
len
(
self
.
item_state
)
/
float
(
tot_items
)
*
self
.
weight
,
self
.
completed
=
True
'max_value'
:
self
.
weight
,
try
:
})
self
.
runtime
.
publish
(
self
,
'grade'
,
{
except
NotImplementedError
:
'value'
:
len
(
self
.
item_state
)
/
float
(
tot_items
)
*
self
.
weight
,
# Note, this publish method is unimplemented in Studio runtimes,
'max_value'
:
self
.
weight
,
# so we have to figure that we're running in Studio for now
})
pass
except
NotImplementedError
:
# Note, this publish method is unimplemented in Studio runtimes,
# so we have to figure that we're running in Studio for now
pass
self
.
runtime
.
publish
(
self
,
'xblock.drag-and-drop-v2.item.dropped'
,
{
self
.
runtime
.
publish
(
self
,
'xblock.drag-and-drop-v2.item.dropped'
,
{
'item_id'
:
item
[
'id'
],
'item_id'
:
item
[
'id'
],
...
...
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