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
57e6b421
Commit
57e6b421
authored
Oct 09, 2014
by
dragonfi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have all resource loading go trough utils.loader instance
parent
e6e914ec
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
32 additions
and
47 deletions
+32
-47
mentoring/answer.py
+4
-4
mentoring/dataexport.py
+2
-2
mentoring/mcq.py
+2
-2
mentoring/mentoring.py
+6
-6
mentoring/message.py
+2
-2
mentoring/mrq.py
+2
-2
mentoring/questionnaire.py
+3
-3
mentoring/table.py
+5
-5
mentoring/tip.py
+2
-2
mentoring/utils.py
+4
-19
No files found.
mentoring/answer.py
View file @
57e6b421
...
...
@@ -32,7 +32,7 @@ from xblock.fragment import Fragment
from
.light_children
import
LightChild
,
Boolean
,
Scope
,
String
,
Integer
,
Float
from
.step
import
StepMixin
from
.models
import
Answer
from
.utils
import
render_js_template
from
.utils
import
loader
# Globals ###########################################################
...
...
@@ -92,11 +92,11 @@ class AnswerBlock(LightChild, StepMixin):
def
mentoring_view
(
self
,
context
=
None
):
if
not
self
.
read_only
:
html
=
render_js_template
(
'templates/html/answer_editable.html'
,
{
html
=
loader
.
custom_
render_js_template
(
'templates/html/answer_editable.html'
,
{
'self'
:
self
,
})
else
:
html
=
render_js_template
(
'templates/html/answer_read_only.html'
,
{
html
=
loader
.
custom_
render_js_template
(
'templates/html/answer_read_only.html'
,
{
'self'
:
self
,
})
...
...
@@ -108,7 +108,7 @@ class AnswerBlock(LightChild, StepMixin):
return
fragment
def
mentoring_table_view
(
self
,
context
=
None
):
html
=
render_js_template
(
'templates/html/answer_table.html'
,
{
html
=
loader
.
custom_
render_js_template
(
'templates/html/answer_table.html'
,
{
'self'
:
self
,
})
fragment
=
Fragment
(
html
)
...
...
mentoring/dataexport.py
View file @
57e6b421
...
...
@@ -32,7 +32,7 @@ from xblock.fields import String, Scope
from
xblock.fragment
import
Fragment
from
.models
import
Answer
from
.utils
import
list2csv
,
render_template
from
.utils
import
list2csv
,
loader
# Globals ###########################################################
...
...
@@ -50,7 +50,7 @@ class MentoringDataExportBlock(XBlock):
scope
=
Scope
.
settings
)
def
student_view
(
self
,
context
):
html
=
render_template
(
'templates/html/dataexport.html'
,
{
html
=
loader
.
render_template
(
'templates/html/dataexport.html'
,
{
'self'
:
self
,
})
...
...
mentoring/mcq.py
View file @
57e6b421
...
...
@@ -28,7 +28,7 @@ import logging
from
.light_children
import
Scope
,
String
from
.questionnaire
import
QuestionnaireAbstractBlock
from
.utils
import
render_template
from
.utils
import
loader
# Globals ###########################################################
...
...
@@ -59,7 +59,7 @@ class MCQBlock(QuestionnaireAbstractBlock):
if
submission
in
tip
.
display_with_defaults
:
tips_fragments
.
append
(
tip
.
render
())
formatted_tips
=
render_template
(
'templates/html/tip_choice_group.html'
,
{
formatted_tips
=
loader
.
render_template
(
'templates/html/tip_choice_group.html'
,
{
'self'
:
self
,
'tips_fragments'
:
tips_fragments
,
'completed'
:
correct
,
...
...
mentoring/mentoring.py
View file @
57e6b421
...
...
@@ -40,7 +40,7 @@ from .header import SharedHeaderBlock
from
.html
import
HTMLBlock
from
.message
import
MentoringMessageBlock
from
.step
import
StepParentMixin
from
.utils
import
get_scenarios_from_path
,
load_resource
,
render_template
from
.utils
import
loader
# Globals ###########################################################
...
...
@@ -127,7 +127,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
not_instance_of
=
self
.
FLOATING_BLOCKS
,
)
fragment
.
add_content
(
render_template
(
'templates/html/mentoring.html'
,
{
fragment
.
add_content
(
loader
.
render_template
(
'templates/html/mentoring.html'
,
{
'self'
:
self
,
'named_children'
:
named_children
,
'missing_dependency_url'
:
self
.
has_missing_dependency
and
self
.
next_step_url
,
...
...
@@ -145,8 +145,8 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
)
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/mentoring.js'
))
fragment
.
add_resource
(
load
_resourc
e
(
'templates/html/mentoring_attempts.html'
),
"text/html"
)
fragment
.
add_resource
(
load
_resourc
e
(
'templates/html/mentoring_grade.html'
),
"text/html"
)
fragment
.
add_resource
(
load
er
.
load_unicod
e
(
'templates/html/mentoring_attempts.html'
),
"text/html"
)
fragment
.
add_resource
(
load
er
.
load_unicod
e
(
'templates/html/mentoring_grade.html'
),
"text/html"
)
fragment
.
initialize_js
(
'MentoringBlock'
)
...
...
@@ -374,7 +374,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
Editing view in Studio
"""
fragment
=
Fragment
()
fragment
.
add_content
(
render_template
(
'templates/html/mentoring_edit.html'
,
{
fragment
.
add_content
(
loader
.
render_template
(
'templates/html/mentoring_edit.html'
,
{
'self'
:
self
,
'xml_content'
:
self
.
xml_content
,
}))
...
...
@@ -442,4 +442,4 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
"""
Scenarios displayed by the workbench. Load them from external (private) repository
"""
return
get
_scenarios_from_path
(
'templates/xml'
)
return
loader
.
load
_scenarios_from_path
(
'templates/xml'
)
mentoring/message.py
View file @
57e6b421
...
...
@@ -26,7 +26,7 @@
import
logging
from
.light_children
import
LightChild
,
Scope
,
String
from
.utils
import
render_template
from
.utils
import
loader
# Globals ###########################################################
...
...
@@ -47,7 +47,7 @@ class MentoringMessageBlock(LightChild):
def
mentoring_view
(
self
,
context
=
None
):
fragment
,
named_children
=
self
.
get_children_fragment
(
context
,
view_name
=
'mentoring_view'
)
fragment
.
add_content
(
render_template
(
'templates/html/message.html'
,
{
fragment
.
add_content
(
loader
.
render_template
(
'templates/html/message.html'
,
{
'self'
:
self
,
'named_children'
:
named_children
,
}))
...
...
mentoring/mrq.py
View file @
57e6b421
...
...
@@ -28,7 +28,7 @@ import logging
from
.light_children
import
List
,
Scope
,
Boolean
from
.questionnaire
import
QuestionnaireAbstractBlock
from
.utils
import
render_template
from
.utils
import
loader
# Globals ###########################################################
...
...
@@ -73,7 +73,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
# Only include tips/results in returned response if we want to display them
if
not
self
.
hide_results
:
choice_result
[
'completed'
]
=
choice_completed
choice_result
[
'tips'
]
=
render_template
(
'templates/html/tip_choice_group.html'
,
{
choice_result
[
'tips'
]
=
loader
.
render_template
(
'templates/html/tip_choice_group.html'
,
{
'self'
:
self
,
'tips_fragments'
:
choice_tips_fragments
,
'completed'
:
choice_completed
,
...
...
mentoring/questionnaire.py
View file @
57e6b421
...
...
@@ -31,7 +31,7 @@ from .choice import ChoiceBlock
from
.step
import
StepMixin
from
.light_children
import
LightChild
,
Scope
,
String
,
Float
from
.tip
import
TipBlock
from
.utils
import
render_template
,
render_js_template
from
.utils
import
loader
# Globals ###########################################################
...
...
@@ -82,14 +82,14 @@ class QuestionnaireAbstractBlock(LightChild, StepMixin):
template_path
=
'templates/html/{}_{}.html'
.
format
(
name
.
lower
(),
self
.
type
)
render_function
=
render_js_template
if
as_template
else
render_template
render_function
=
loader
.
custom_render_js_template
if
as_template
else
loader
.
render_template
html
=
render_function
(
template_path
,
{
'self'
:
self
,
'custom_choices'
:
self
.
custom_choices
})
fragment
=
Fragment
(
html
)
fragment
.
add_css
(
render_template
(
'public/css/questionnaire.css'
,
{
fragment
.
add_css
(
loader
.
render_template
(
'public/css/questionnaire.css'
,
{
'self'
:
self
}))
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
.
xblock_container
,
...
...
mentoring/table.py
View file @
57e6b421
...
...
@@ -29,7 +29,7 @@ import logging
from
xblock.fields
import
Scope
from
.light_children
import
LightChild
,
String
from
.utils
import
load
_resource
,
render_template
from
.utils
import
load
er
# Globals ###########################################################
...
...
@@ -58,14 +58,14 @@ class MentoringTableBlock(LightChild):
# Load an optional description for the background image, for accessibility
try
:
bg_image_description
=
load
_resourc
e
(
'static/text/table-{}.txt'
.
format
(
self
.
type
))
bg_image_description
=
load
er
.
load_unicod
e
(
'static/text/table-{}.txt'
.
format
(
self
.
type
))
except
IOError
as
e
:
if
e
.
errno
==
errno
.
ENOENT
:
bg_image_description
=
''
else
:
raise
fragment
.
add_content
(
render_template
(
'templates/html/mentoring-table.html'
,
{
fragment
.
add_content
(
loader
.
render_template
(
'templates/html/mentoring-table.html'
,
{
'self'
:
self
,
'columns_frags'
:
columns_frags
,
'header_frags'
:
header_frags
,
...
...
@@ -101,7 +101,7 @@ class MentoringTableColumnBlock(LightChild):
fragment
,
named_children
=
self
.
get_children_fragment
(
context
,
view_name
=
'mentoring_table_view'
,
not_instance_of
=
MentoringTableColumnHeaderBlock
)
fragment
.
add_content
(
render_template
(
'templates/html/mentoring-table-column.html'
,
{
fragment
.
add_content
(
loader
.
render_template
(
'templates/html/mentoring-table-column.html'
,
{
'self'
:
self
,
'named_children'
:
named_children
,
}))
...
...
@@ -114,7 +114,7 @@ class MentoringTableColumnBlock(LightChild):
fragment
,
named_children
=
self
.
get_children_fragment
(
context
,
view_name
=
'mentoring_table_header_view'
,
instance_of
=
MentoringTableColumnHeaderBlock
)
fragment
.
add_content
(
render_template
(
'templates/html/mentoring-table-header.html'
,
{
fragment
.
add_content
(
loader
.
render_template
(
'templates/html/mentoring-table-header.html'
,
{
'self'
:
self
,
'named_children'
:
named_children
,
}))
...
...
mentoring/tip.py
View file @
57e6b421
...
...
@@ -26,7 +26,7 @@
import
logging
from
.light_children
import
LightChild
,
Scope
,
String
from
.utils
import
render_template
from
.utils
import
loader
# Globals ###########################################################
...
...
@@ -65,7 +65,7 @@ class TipBlock(LightChild):
Returns a fragment containing the formatted tip
"""
fragment
,
named_children
=
self
.
get_children_fragment
({})
fragment
.
add_content
(
render_template
(
'templates/html/tip.html'
,
{
fragment
.
add_content
(
loader
.
render_template
(
'templates/html/tip.html'
,
{
'self'
:
self
,
'named_children'
:
named_children
,
}))
...
...
mentoring/utils.py
View file @
57e6b421
...
...
@@ -36,27 +36,12 @@ from xblockutils.resources import ResourceLoader
log
=
logging
.
getLogger
(
__name__
)
loader
=
ResourceLoader
(
__name__
)
class
MentoringResourceLoader
(
ResourceLoader
):
def
custom_render_js_template
(
self
,
template_path
,
context
=
{}):
return
self
.
render_js_template
(
template_path
,
'light-child-template'
,
context
)
def
load_resource
(
resource_path
):
return
loader
.
load_unicode
(
resource_path
)
def
render_template
(
template_path
,
context
=
{}):
return
loader
.
render_template
(
template_path
,
context
)
def
render_js_template
(
template_path
,
context
=
{},
unique_id
=
'light-child-template'
):
return
loader
.
render_js_template
(
template_path
,
unique_id
,
context
)
def
get_scenarios_from_path
(
scenarios_path
,
include_identifier
=
False
):
return
loader
.
load_scenarios_from_path
(
scenarios_path
,
include_identifier
)
def
load_scenarios_from_path
(
scenarios_path
):
return
loader
.
load_scenarios_from_path
(
scenarios_path
,
include_identifier
=
True
)
loader
=
MentoringResourceLoader
(
__name__
)
def
list2csv
(
row
):
...
...
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