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
d4b54cec
Commit
d4b54cec
authored
May 20, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update open ended editor to parse tasks properly
parent
986999c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
57 deletions
+77
-57
cms/templates/widgets/open-ended-edit.html
+20
-2
common/lib/xmodule/xmodule/js/src/combinedopenended/edit.coffee
+57
-55
No files found.
cms/templates/widgets/open-ended-edit.html
View file @
d4b54cec
...
@@ -22,6 +22,16 @@
...
@@ -22,6 +22,16 @@
</div>
</div>
</section>
</section>
<script
type=
"text/template"
id=
"open-ended-template"
>
<
openended
%
min_max_string
%>
<
openendedparam
>
<
initial_display
>
Enter
essay
here
.
<
/initial_display
>
<
answer_display
>
This
is
the
answer
.
<
/answer_display
>
<
grader_payload
>
{
"grader_settings"
:
"%grading_config%"
,
"problem_id"
:
"6.002x/Welcome/OETest"
}
<
/grader_payload
>
<
/openendedparam
>
<
/openended
>
</script>
<script
type=
"text/template"
id=
"simple-editor-cheatsheet"
>
<script
type=
"text/template"
id=
"simple-editor-cheatsheet"
>
<
article
class
=
"simple-editor-cheatsheet"
>
<
article
class
=
"simple-editor-cheatsheet"
>
<
div
class
=
"cheatsheet-wrapper"
>
<
div
class
=
"cheatsheet-wrapper"
>
...
@@ -41,7 +51,11 @@
...
@@ -41,7 +51,11 @@
<
div
class
=
"col prompt"
>
<
div
class
=
"col prompt"
>
<
/div
>
<
/div
>
<
div
class
=
"col"
>
<
div
class
=
"col"
>
<
pre
><
code
>
[
prompt
]
Why
is
the
sky
blue
?[
prompt
]
<
/code></
pre
>
<
pre
><
code
>
[
prompt
]
Why
is
the
sky
blue
?
[
prompt
]
<
/code></
pre
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
class
=
"row"
>
<
div
class
=
"row"
>
...
@@ -67,7 +81,11 @@
...
@@ -67,7 +81,11 @@
<
div
class
=
"col sample tasks"
>
<
div
class
=
"col sample tasks"
>
<
/div
>
<
/div
>
<
div
class
=
"col"
>
<
div
class
=
"col"
>
<
pre
><
code
>
[
tasks
](
Self
),
({
0
,
1
}
AI
),
({
1
,
3
}
Peer
)[
tasks
]
<
/code></
pre
>
<
pre
><
code
>
[
tasks
]
(
Self
),
({
0
-
1
}
AI
),
({
1
-
3
}
Peer
)
[
tasks
]
<
/code></
pre
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
...
common/lib/xmodule/xmodule/js/src/combinedopenended/edit.coffee
View file @
d4b54cec
class
@
OpenEndedMarkdownEditingDescriptor
extends
XModule
.
Descriptor
class
@
OpenEndedMarkdownEditingDescriptor
extends
XModule
.
Descriptor
# TODO really, these templates should come from or also feed the cheatsheet
# TODO really, these templates should come from or also feed the cheatsheet
@
rubricTemplate
:
"[rubric]
\n
+ Color Identification
\n
- Incorrect
\n
- Correct
\n
+ Grammar
\n
- Poor
\n
- Acceptable
\n
- Superb
\n
[rubric]
\n
"
@
rubricTemplate
:
"[rubric]
\n
+ Color Identification
\n
- Incorrect
\n
- Correct
\n
+ Grammar
\n
- Poor
\n
- Acceptable
\n
- Superb
\n
[rubric]
\n
"
@
tasksTemplate
:
"[tasks]
\n
(Self), ({0
,1}AI), ({1,
3}Peer)
\n
[tasks]
\n
"
@
tasksTemplate
:
"[tasks]
\n
(Self), ({0
-1}AI), ({1-
3}Peer)
\n
[tasks]
\n
"
@
promptTemplate
:
"[prompt]
\n
Why is the sky blue?
\n
[prompt]
\n
"
@
promptTemplate
:
"[prompt]
\n
Why is the sky blue?
\n
[prompt]
\n
"
constructor
:
(
element
)
->
constructor
:
(
element
)
->
...
@@ -138,78 +138,80 @@ class @OpenEndedMarkdownEditingDescriptor extends XModule.Descriptor
...
@@ -138,78 +138,80 @@ class @OpenEndedMarkdownEditingDescriptor extends XModule.Descriptor
@
markdownToXml
:
(
markdown
)
->
@
markdownToXml
:
(
markdown
)
->
toXml
=
`
function
(
markdown
)
{
toXml
=
`
function
(
markdown
)
{
function
template
(
template_html
,
data
){
return
template_html
.
replace
(
/%(\w*)%/g
,
function
(
m
,
key
){
return
data
.
hasOwnProperty
(
key
)
?
data
[
key
]
:
""
;});
}
var
xml
=
markdown
;
var
xml
=
markdown
;
//
group
rubrics
//
group
rubrics
xml
=
xml
.
replace
(
/\[rubric\]\n?([^\]]*)\[\/?rubric\]/gmi
,
function
(
match
,
p
)
{
xml
=
xml
.
replace
(
/\[rubric\]\n?([^\]]*)\[\/?rubric\]/gmi
,
function
(
match
,
p
)
{
var
groupString
=
'<multiplechoiceresponse>
\n
'
;
var
groupString
=
'<rubric>
\n
<rubric>
\n
'
;
groupString
+=
' <choicegroup type="MultipleChoice">
\n
'
;
var
options
=
p
.
split
(
'
\n
'
);
var
options
=
match
.
split
(
'
\n
'
);
for
(
var
i
=
0
;
i
<
options
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
options
.
length
;
i
++
)
{
if
(
options
[
i
].
length
>
0
)
{
if
(
options
[
i
].
length
>
0
)
{
var
value
=
options
[
i
].
split
(
/^\s*\(.?\)\s*/
)[
1
];
var
value
=
options
[
i
].
replace
(
/^\s+|\s+$/g
,
''
);
var
correct
=
/^\s*\(x\)/i
.
test
(
options
[
i
]);
if
(
value
.
charAt
(
0
)
==
"+"
)
{
groupString
+=
' <choice correct="'
+
correct
+
'">'
+
value
+
'</choice>
\n
'
;
if
(
i
>
0
){
groupString
+=
"</category>
\n
"
;
}
groupString
+=
"<category>
\n
<description>
\n
"
;
text
=
value
.
substr
(
1
);
text
=
text
.
replace
(
/^\s+|\s+$/g
,
''
);
groupString
+=
text
;
groupString
+=
"
\n
</description>
\n
"
;
}
else
if
(
value
.
charAt
(
0
)
==
"-"
)
{
groupString
+=
"<option>
\n
"
;
text
=
value
.
substr
(
1
);
text
=
text
.
replace
(
/^\s+|\s+$/g
,
''
);
groupString
+=
text
;
groupString
+=
"
\n
</option>
\n
"
;
}
}
}
}
}
groupString
+=
' </choicegroup>
\n
'
;
groupString
+=
'</rubric>
\n
</rubric>
\n
'
;
groupString
+=
'</multiplechoiceresponse>
\n\n
'
;
return
groupString
;
return
groupString
;
});
});
//
group
check
answer
s
//
group
task
s
xml
=
xml
.
replace
(
/
(^\s*\[.?\].*?$\n*)+/gm
,
function
(
match
,
p
)
{
xml
=
xml
.
replace
(
/
\[tasks\]\n?([^\]]*)\[\/?tasks\]/gmi
,
function
(
match
,
p
)
{
var
groupString
=
'<choiceresponse>
\n
'
;
var
open_ended_template
=
$
(
'#open-ended-template'
).
html
()
groupString
+=
' <checkboxgroup direction="vertical">
\n
'
;
var
groupString
=
'
'
;
var
options
=
match
.
split
(
'
\n
'
);
var
options
=
p
.
split
(
","
);
for
(
var
i
=
0
;
i
<
options
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
options
.
length
;
i
++
)
{
if
(
options
[
i
].
length
>
0
)
{
if
(
options
[
i
].
length
>
0
)
{
var
value
=
options
[
i
].
split
(
/^\s*\[.?\]\s*/
)[
1
];
var
value
=
options
[
i
].
replace
(
/^\s+|\s+$/g
,
''
);
var
correct
=
/^\s*\[x\]/i
.
test
(
options
[
i
]);
var
lower_option
=
value
.
toLowerCase
();
groupString
+=
' <choice correct="'
+
correct
+
'">'
+
value
+
'</choice>
\n
'
;
type
=
lower_option
.
match
(
/(peer|self|ai)/gmi
)
if
(
type
!=
null
)
{
type
=
type
[
0
]
var
min_max
=
value
.
match
(
/\{\n?([^\]]*)\}/gmi
);
var
min_max_string
=
""
;
if
(
min_max
!=
null
)
{
min_max
=
min_max
[
0
].
replace
(
/^{|}/gmi
,
''
);
min_max
=
min_max
.
split
(
"-"
);
min
=
min_max
[
0
];
max
=
min_max
[
1
];
min_max_string
=
'min_score_to_attempt="'
+
min
+
'" max_score_to_attempt="'
+
max
+
'" '
;
}
groupString
+=
"<task>
\n
"
if
(
type
==
"self"
)
{
groupString
+=
"<selfassessment"
+
min_max_string
+
"/>"
}
else
if
(
type
==
"peer"
)
{
config
=
"peer_grading.conf"
groupString
+=
template
(
open_ended_template
,{
min_max_string
:
min_max_string
,
grading_config
:
config
});
}
else
if
(
type
==
"ai"
)
{
config
=
"ml_grading.conf"
groupString
+=
template
(
open_ended_template
,{
min_max_string
:
min_max_string
,
grading_config
:
config
});
}
groupString
+=
"</task>
\n
"
}
}
}
}
}
groupString
+=
' </checkboxgroup>
\n
'
;
groupString
+=
'</choiceresponse>
\n\n
'
;
return
groupString
;
return
groupString
;
});
});
//
replace
string
and
numerical
xml
=
xml
.
replace
(
/^\=\s*(.*?$)/gm
,
function
(
match
,
p
)
{
var
string
;
var
floatValue
=
parseFloat
(
p
);
if
(
!
isNaN
(
floatValue
))
{
var
params
=
/(.*?)\+\-\s*(.*?$)/
.
exec
(
p
);
if
(
params
)
{
string
=
'<numericalresponse answer="'
+
floatValue
+
'">
\n
'
;
string
+=
' <responseparam type="tolerance" default="'
+
params
[
2
]
+
'" />
\n
'
;
}
else
{
string
=
'<numericalresponse answer="'
+
floatValue
+
'">
\n
'
;
}
string
+=
' <textline />
\n
'
;
string
+=
'</numericalresponse>
\n\n
'
;
}
else
{
string
=
'<stringresponse answer="'
+
p
+
'" type="ci">
\n
<textline size="20"/>
\n
</stringresponse>
\n\n
'
;
}
return
string
;
});
//
replace
selects
xml
=
xml
.
replace
(
/\[\[(.+?)\]\]/g
,
function
(
match
,
p
)
{
var
selectString
=
'
\n
<optionresponse>
\n
'
;
selectString
+=
' <optioninput options="('
;
var
options
=
p
.
split
(
/\,\s*/g
);
for
(
var
i
=
0
;
i
<
options
.
length
;
i
++
)
{
selectString
+=
"'"
+
options
[
i
].
replace
(
/(?:^|,)\s*\((.*?)\)\s*(?:$|,)/g
,
'$1'
)
+
"'"
+
(
i
<
options
.
length
-
1
?
','
:
''
);
}
selectString
+=
')" correct="'
;
var
correct
=
/(?:^|,)\s*\((.*?)\)\s*(?:$|,)/g
.
exec
(
p
);
if
(
correct
)
selectString
+=
correct
[
1
];
selectString
+=
'"></optioninput>
\n
'
;
selectString
+=
'</optionresponse>
\n\n
'
;
return
selectString
;
});
//
replace
prompts
//
replace
prompts
xml
=
xml
.
replace
(
/\[prompt\]\n?([^\]]*)\[\/?prompt\]/gmi
,
function
(
match
,
p1
)
{
xml
=
xml
.
replace
(
/\[prompt\]\n?([^\]]*)\[\/?prompt\]/gmi
,
function
(
match
,
p1
)
{
var
selectString
=
'<prompt>
\n
'
+
p1
+
'
\n
</prompt>'
;
var
selectString
=
'<prompt>
\n
'
+
p1
+
'
\n
</prompt>'
;
...
...
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