Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
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
problem-builder
Commits
f8cda89b
Commit
f8cda89b
authored
Mar 07, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow editing of mentoring XML content from Studio
parent
5a5f3632
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
1 deletions
+54
-1
mentoring/mentoring.py
+25
-1
mentoring/public/js/mentoring_edit.js
+12
-0
mentoring/templates/html/mentoring_edit.html
+17
-0
No files found.
mentoring/mentoring.py
View file @
f8cda89b
...
...
@@ -27,6 +27,7 @@ import logging
from
xblock.core
import
XBlock
from
xblock.fields
import
Boolean
,
Scope
,
String
from
xblock.fragment
import
Fragment
from
.light_children
import
XBlockWithLightChildren
from
.message
import
MentoringMessageBlock
...
...
@@ -63,7 +64,6 @@ class MentoringBlock(XBlockWithLightChildren):
default
=
True
,
scope
=
Scope
.
content
)
display_submit
=
Boolean
(
help
=
"Allow to submit current block?"
,
default
=
True
,
scope
=
Scope
.
content
)
xml_content
=
String
(
help
=
"XML content"
,
default
=
''
,
scope
=
Scope
.
content
)
has_children
=
True
icon_class
=
'problem'
def
student_view
(
self
,
context
):
...
...
@@ -156,6 +156,30 @@ class MentoringBlock(XBlockWithLightChildren):
else
:
return
''
def
studio_view
(
self
,
context
):
"""
Editing view in Studio
"""
fragment
=
Fragment
()
fragment
.
add_content
(
render_template
(
'templates/html/mentoring_edit.html'
,
{
'self'
:
self
,
}))
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/mentoring_edit.js'
))
fragment
.
initialize_js
(
'MentoringEditBlock'
)
return
fragment
@XBlock.json_handler
def
studio_submit
(
self
,
submissions
,
suffix
=
''
):
log
.
info
(
u'Received submissions: {}'
.
format
(
submissions
))
# TODO-MRQ: Add XML validation
self
.
xml_content
=
submissions
[
'xml_content'
]
return
{
'result'
:
'success'
,
}
@staticmethod
def
workbench_scenarios
():
"""
...
...
mentoring/public/js/mentoring_edit.js
0 → 100644
View file @
f8cda89b
function
MentoringEditBlock
(
runtime
,
element
)
{
$
(
'.save-button'
).
bind
(
'click'
,
function
()
{
var
data
=
{
'xml_content'
:
$
(
'#mentoring-xml-content'
).
val
(),
};
var
handlerUrl
=
runtime
.
handlerUrl
(
element
,
'studio_submit'
);
$
.
post
(
handlerUrl
,
JSON
.
stringify
(
data
)).
complete
(
function
()
{
// TODO-MRQ: Error handling
window
.
location
.
reload
(
false
);
});
});
}
mentoring/templates/html/mentoring_edit.html
0 → 100644
View file @
f8cda89b
<!-- TODO: Replace by default edit view once available in Studio -->
<div
class=
"wrapper-comp-settings is-active"
id=
"settings-tab"
>
<script
id=
"metadata-editor-tpl"
type=
"text/template"
>
// JS crashes when empty //
</script>
<ul
class=
"list-input settings-list"
>
<li
class=
"field comp-setting-entry is-set"
>
<div
class=
"wrapper-comp-setting"
>
<label
class=
"label setting-label"
for=
"mentoring-xml-content"
>
XML content
</label>
<input
class=
"input setting-input"
id=
"mentoring-xml-content"
value=
"{{ self.xml_content }}"
type=
"text"
>
</div>
<span
class=
"tip setting-help"
>
XML source of the mentoring block
</span>
</li>
</ul>
</div>
<div
class=
"row module-actions"
>
<a
href=
"#"
class=
"save-button action-primary action"
>
Save
</a>
<a
href=
"#"
class=
"cancel-button action-secondary action"
>
Cancel
</a>
</div>
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