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
06c53a4f
Commit
06c53a4f
authored
Sep 30, 2014
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed unused utils moudle
parent
5b8a8465
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
75 deletions
+0
-75
tests/utils.py
+0
-75
No files found.
tests/utils.py
deleted
100644 → 0
View file @
5b8a8465
import
os
import
json
import
pkg_resources
from
xml.sax.saxutils
import
escape
def
load_resource
(
resource_path
):
"""
Gets the content of a resource
"""
resource_content
=
pkg_resources
.
resource_string
(
__name__
,
resource_path
)
return
unicode
(
resource_content
)
def
make_scenario_from_data
(
data
,
display_name
,
question_text
,
completed
):
parameters
=
{
'data'
:
data
,
'display_name'
:
display_name
,
'question_text'
:
question_text
,
'completed'
:
completed
,
'weight'
:
'1'
}
attributes
=
[
"{0}='{1}'"
.
format
(
key
,
escape
(
value
))
for
key
,
value
in
parameters
.
items
()
if
value
]
attributes_str
=
" "
.
join
(
attributes
)
return
"""<vertical_demo><drag-and-drop-v2 {attrs}/></vertical_demo>"""
.
format
(
attrs
=
attributes_str
)
def
format_name
(
raw_name
):
return
raw_name
.
replace
(
'_'
,
' '
)
.
title
()
def
get_scenarios_from_path
(
scenarios_path
,
include_identifier
=
False
):
"""
Returns an array of (title, xmlcontent) from files contained in a specified directory,
formatted as expected for the return value of the workbench_scenarios() method
"""
base_fullpath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
scenarios_fullpath
=
os
.
path
.
join
(
base_fullpath
,
scenarios_path
)
scenarios
=
[]
if
os
.
path
.
isdir
(
scenarios_fullpath
):
for
template
in
os
.
listdir
(
scenarios_fullpath
):
if
not
template
.
endswith
(
'.json'
):
continue
identifier
,
title
,
scenario
=
get_scenario_from_file
(
scenarios_path
,
template
)
if
not
include_identifier
:
scenarios
.
append
((
title
,
scenario
))
else
:
scenarios
.
append
((
identifier
,
title
,
scenario
))
return
scenarios
def
get_scenario_from_file
(
scenarios_path
,
filename
):
identifier
=
filename
[:
-
5
]
block_title
,
question_text
=
map
(
format_name
,
identifier
.
split
(
'-'
))
title
=
identifier
.
replace
(
'_'
,
' '
)
.
replace
(
'-'
,
' '
)
.
title
()
scenario_file
=
os
.
path
.
join
(
scenarios_path
,
filename
)
scenario_data
=
json
.
loads
(
load_resource
(
scenario_file
))
scenario
=
make_scenario_from_data
(
scenario_data
,
block_title
,
question_text
,
False
)
return
identifier
,
title
,
scenario
def
load_scenarios_from_path
(
scenarios_path
):
"""
Load all xml files contained in a specified directory, as workbench scenarios
"""
return
get_scenarios_from_path
(
scenarios_path
,
include_identifier
=
True
)
def
load_scenario_from_file
(
filename
):
scenario_path
,
template
=
os
.
path
.
split
(
filename
)
return
get_scenario_from_file
(
scenario_path
,
template
)
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