Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set the value of popup_on_launch field #63

Merged
Merged
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
7 changes: 6 additions & 1 deletion openedxscorm/scormxblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def student_view(self, context=None):
"can_view_student_reports": self.can_view_student_reports,
"scorm_xblock": self,
"navigation_menu": self.navigation_menu,
"popup_on_launch": self.popup_on_launch
}
student_context.update(context or {})
template = self.render_template("static/html/scormxblock.html", student_context)
Expand Down Expand Up @@ -260,6 +261,7 @@ def studio_view(self, context=None):
"field_popup_on_launch": self.fields["popup_on_launch"],
"field_enable_navigation_menu": self.fields["enable_navigation_menu"],
"field_navigation_menu_width": self.fields["navigation_menu_width"],
"popup_on_launch": self.fields["popup_on_launch"],
"scorm_xblock": self,
}
studio_context.update(context or {})
Expand Down Expand Up @@ -319,6 +321,9 @@ def popup_window(self, request, _suffix):
"index_page_url": self.index_page_url,
"width": self.width or 800,
"height": self.height or 800,
"navigation_menu": self.navigation_menu,
"navigation_menu_width": self.navigation_menu_width,
"enable_navigation_menu": self.enable_navigation_menu
},
)
return Response(body=rendered)
Expand Down Expand Up @@ -450,7 +455,7 @@ def set_value(self, data):

self.scorm_data[name] = value
if name == "cmi.core.lesson_status":
lesson_status = data.get("value")
lesson_status = value
if lesson_status in ["passed", "failed"]:
success_status = lesson_status
elif lesson_status in ["completed", "incomplete"]:
Expand Down
50 changes: 50 additions & 0 deletions openedxscorm/static/html/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,62 @@
iframe {
border: 0;
}
.scorm-xblock {
display: flex;
flex-direction: row;
justify-content: center;
margin: 4%;
border: 1px solid gray;
}
.navigational-panel {
width: 100%;
}
.scorm-embedded {
width: 100%;
height: 500px;
border: none;
}
.navigation-title:hover {
cursor: pointer;
text-decoration: underline;
}

/* Responsive styles */
@media screen and (min-width: 768px) {
.scorm-xblock {
flex-direction: row;
}
.navigational-panel {
width: 30%;
}
.scorm-embedded {
width: 70%;
height: 700px;
}
}
</style>
</head>
<body>
<div class="scorm-xblock">
<div class="navigational-panel" style="width: {% if scorm_xblock.navigation_menu_width %}{{scorm_xblock.navigation_menu_width}}px{% else %}30%{% endif %};">
<h4>Table of contents</h4>
<ul>
{{navigation_menu|safe }}
</ul>
</div>
<iframe class="scorm-embedded" src="{{ index_page_url }}" width="{{ width }}" height="{{ height }}"></iframe>
<script>
window.resizeTo({{ width }} + 20, {{ height }} + 20);
window.onload = function () {
var navigationTitles = document.getElementsByClassName("navigation-title");
for (let i = 0; i < navigationTitles.length; i++) {
navigationTitle = navigationTitles[i];
navigationTitle.onclick = function () {
let path = navigationTitle.getAttribute('href');
document.getElementsByClassName("scorm-embedded")[0].src = this.getAttribute('href');
}
}
}
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion openedxscorm/static/html/scormxblock.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<div class="scorm-panel">

{% if scorm_xblock.enable_navigation_menu %}
{% if scorm_xblock.enable_navigation_menu and not scorm_xblock.popup_on_launch%}
<div class="navigation-pane" style="width: {% if scorm_xblock.navigation_menu_width %}{{scorm_xblock.navigation_menu_width}}px{% else %}30%{% endif %};">
<h4>Table of contents</h4>

Expand Down
10 changes: 10 additions & 0 deletions openedxscorm/static/html/studio.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@
</div>
<span class="tip setting-help">{% trans field_navigation_menu_width.help %}</span>
</li>
<li class="field comp-setting-entry is-set">
<div class="wrapper-comp-setting">
<label class="label setting-label" for="popup_on_launch">{% trans field_popup_on_launch.display_name %}</label>
<select name="popup_on_launch" id="popup_on_launch">
<option value="1" {% if scorm_xblock.popup_on_launch %}selected{% endif %}>{% trans "True" %}</option>
<option value="0" {% if not scorm_xblock.popup_on_launch %}selected{% endif %}>{% trans "False" %}</option>
</select>
</div>
<span class="tip setting-help">{% trans field_popup_on_launch.help %}</span>
</li>
</ul>

<div class="xblock-actions">
Expand Down