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
47fc6791
Commit
47fc6791
authored
Jul 04, 2014
by
Filippo Valsorda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce grading
parent
cf3b5f1c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
3 deletions
+31
-3
drag_and_drop_v2/drag_and_drop_v2.py
+26
-2
drag_and_drop_v2/public/js/drag_and_drop_edit.js
+1
-0
drag_and_drop_v2/templates/html/drag_and_drop.html
+1
-1
drag_and_drop_v2/templates/html/drag_and_drop_edit.html
+3
-0
No files found.
drag_and_drop_v2/drag_and_drop_v2.py
View file @
47fc6791
...
...
@@ -9,7 +9,7 @@ import webob
import
copy
from
xblock.core
import
XBlock
from
xblock.fields
import
Scope
,
String
,
Dict
from
xblock.fields
import
Scope
,
String
,
Dict
,
Float
from
xblock.fragment
import
Fragment
from
.utils
import
render_template
...
...
@@ -40,6 +40,13 @@ class DragAndDropBlock(XBlock):
default
=
""
)
weight
=
Float
(
display_name
=
"Weight"
,
help
=
"This is the maximum score that the user receives when he/she successfully completes the problem"
,
scope
=
Scope
.
settings
,
default
=
1
)
data
=
Dict
(
display_name
=
"Drag and Drop"
,
help
=
"JSON spec as generated by the builder"
,
...
...
@@ -61,14 +68,20 @@ class DragAndDropBlock(XBlock):
default
=
{}
)
has_score
=
True
def
student_view
(
self
,
context
):
"""
Player view, displayed to the student
"""
max_score_string
=
'({0} Point{1} Possible)'
.
format
(
int
(
self
.
weight
),
's'
if
self
.
weight
>
1
else
''
)
if
self
.
weight
else
''
context
=
{
'title'
:
self
.
display_name
,
'question_text'
:
self
.
question_text
'question_text'
:
self
.
question_text
,
'max_score_string'
:
max_score_string
}
fragment
=
Fragment
()
...
...
@@ -116,6 +129,7 @@ class DragAndDropBlock(XBlock):
def
studio_submit
(
self
,
submissions
,
suffix
=
''
):
self
.
display_name
=
submissions
[
'display_name'
]
self
.
question_text
=
submissions
[
'question_text'
]
self
.
weight
=
float
(
submissions
[
'weight'
])
try
:
self
.
data
=
json
.
loads
(
submissions
[
'data'
])
...
...
@@ -159,6 +173,16 @@ class DragAndDropBlock(XBlock):
else
:
final_feedback
=
None
try
:
self
.
runtime
.
publish
(
self
,
'grade'
,
{
'value'
:
len
(
self
.
item_state
)
/
float
(
tot_items
)
*
self
.
weight
,
'max_value'
:
self
.
weight
,
})
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
return
{
'correct'
:
True
,
'final_feedback'
:
final_feedback
,
...
...
drag_and_drop_v2/public/js/drag_and_drop_edit.js
View file @
47fc6791
...
...
@@ -411,6 +411,7 @@ function DragAndDropEditBlock(runtime, element) {
var
data
=
{
'display_name'
:
$
(
element
).
find
(
'.display-name'
).
val
(),
'weight'
:
$
(
element
).
find
(
'.weight'
).
val
(),
'question_text'
:
$
(
element
).
find
(
'.question-text'
).
val
(),
'data'
:
JSON
.
stringify
(
_fn
.
data
),
};
...
...
drag_and_drop_v2/templates/html/drag_and_drop.html
View file @
47fc6791
...
...
@@ -3,7 +3,7 @@
{{ title }}
</h2>
<div
class=
"problem-progress"
>
(1 point possible)
</div>
<div
class=
"problem-progress"
>
{{ max_score_string }}
</div>
<section
class=
"problem"
role=
"application"
>
<p>
...
...
drag_and_drop_v2/templates/html/drag_and_drop_edit.html
View file @
47fc6791
...
...
@@ -9,6 +9,9 @@
<h3>
Question title
</h3>
<input
class=
"display-name"
/>
<h3>
Maximum score
</h3>
<input
class=
"weight"
value=
"1"
/>
<h3>
Question text
</h3>
<textarea
class=
"question-text"
></textarea>
...
...
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