Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions recommender/recommender.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,6 @@ def get_client_configuration(self):
result = self.client_configuration.copy()
result['is_user_staff'] = self.get_user_is_staff()
result['intro'] = not self.seen and self.intro_enabled
if not self.seen:
# Mark the user who interacted with the XBlock first time as seen,
# in order not to show the usage tutorial in future.
self.seen = True
tracker.emit('get_client_configuration', result)
return result

Expand Down Expand Up @@ -1008,6 +1004,11 @@ def student_view(self, _context=None): # pylint: disable=unused-argument
frag.add_javascript(self.resource_string("static/js/src/cats.js"))
frag.add_javascript(self.resource_string("static/js/src/recommender.js"))
frag.initialize_js('RecommenderXBlock', self.get_client_configuration())
# First student view delivered the intro, mark seen so it doesn't
# show again. Must happen after get_client_configuration to avoid
# writing Scope.user_info during studio_view render (auto-save
# rejects user_info).
self.seen = True
return frag

def studio_view(self, _context=None): # pylint: disable=unused-argument
Expand All @@ -1016,8 +1017,14 @@ def studio_view(self, _context=None): # pylint: disable=unused-argument
course staff when editing a course in studio.
"""
frag = Fragment()
configurations = self.get_client_configuration()
frag.add_content(resource_loader.render_django_template(
"templates/recommenderstudio.html",
"templates/recommenderstudio.html", {
'configurations': configurations,
'intro_enabled': self.intro_enabled,
'entries_per_page_options': range(1, 11),
'page_span_options': range(1, 6),
},
i18n_service=self.runtime.service(self, "i18n")
))
frag.add_css(load("static/css/recommenderstudio.css"))
Expand Down
29 changes: 10 additions & 19 deletions recommender/templates/recommenderstudio.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,30 @@
<div class="recommender_setRecommenderConfigTitle">{% trans "Set the student-view, client side configurations for RecommenderXblock." %}</div>
<div class="config">
<select name='introEnable' class='introEnable'>
<option value='true'>{% trans "Yes" %}</option>
<option value='false'>{% trans "No" %}</option></select>
<option value='true'{% if intro_enabled %} selected='selected'{% endif %}>{% trans "Yes" %}</option>
<option value='false'{% if not intro_enabled %} selected='selected'{% endif %}>{% trans "No" %}</option></select>
<span>{% trans "Do you want to take users on a little tour when they see the RecommenderXBlock first time?" %}</span>
</div>
<div class="config">
<select name='developedUXDisable' class='developedUXDisable'>
<option value='true'>{% trans "Yes" %}</option>
<option value='false'>{% trans "No" %}</option>
<option value='true'{% if configurations.disable_dev_ux %} selected='selected'{% endif %}>{% trans "Yes" %}</option>
<option value='false'{% if not configurations.disable_dev_ux %} selected='selected'{% endif %}>{% trans "No" %}</option>
</select>
<span>{% trans "Do you want to disable the UX functions which are under development?" %}</span>
</div>
<div class="config">
<select name='entriesPerPage' class='entriesPerPage'>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option selected='selected' value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
{% for i in entries_per_page_options %}
<option value='{{ i }}'{% if configurations.entries_per_page == i %} selected='selected'{% endif %}>{{ i }}</option>
{% endfor %}
</select>
<span>{% trans "How many resources you want to show in each page of the resource list?" %}</span>
</div>
<div class="config">
<select name='pageSpan' class='pageSpan'>
<option value='1'>1</option>
<option selected='selected' value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
{% for i in page_span_options %}
<option value='{{ i }}'{% if configurations.page_span == i %} selected='selected'{% endif %}>{{ i }}</option>
{% endfor %}
</select>
<span>{% trans "How many page icons in pagination control (i.e., page range)? The icons for pages from (current page - page range) to (current page + page range) will be shown." %}</span>
</div>
Expand Down