Add CSS style for embeddable quiz - refs BT#16576

pull/3085/head
Angel Fernando Quiroz Campos 6 years ago
parent c315b77f52
commit 0135ecb154
  1. 8
      app/Resources/public/css/base.css
  2. 7
      main/exercise/exercise_result.php
  3. 57
      main/exercise/exercise_submit.php
  4. 1
      main/inc/lib/template.lib.php
  5. 2
      main/template/default/layout/page.tpl
  6. 2
      main/template/default/layout/show_header.tpl

@ -64,6 +64,14 @@ body {
margin-bottom: 60px;
}
body.page_origin_embeddable {
padding-top: 10px;
}
body.page_origin_embeddable #cm-content > .container {
margin-bottom: 0px;
padding-bottom: 0px;
}
.footer > .container {
padding-right: 15px;
padding-left: 15px;

@ -86,11 +86,6 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) {
// So we are not in learnpath tool
Display::display_header($nameTools, get_lang('Exercise'));
} else {
$htmlHeadXtra[] = "
<style>
body { background: none;}
</style>
";
Display::display_reduced_header();
}
@ -245,7 +240,7 @@ function showEmbeddableFinishButton()
{
echo '<script>
$(function () {
$(\'.btn-close-quiz\').on(\'click\', function () {
$(\'.btn-close-quiz\').on(\'click\', function () {
window.parent.$(\'video:not(.skip), audio:not(.skip)\').get(0).play();
});
});

@ -862,7 +862,6 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) { //so we are not in learnp
Display::display_header(null, 'Exercises');
} else {
$htmlHeadXtra[] = "<style> body { background: none;} </style> ";
Display::display_reduced_header();
echo '<div style="height:10px">&nbsp;</div>';
}
@ -1038,8 +1037,8 @@ if (!empty($error)) {
echo Display::return_message($error, 'error', false);
} else {
if (!empty($exercise_sound)) {
echo "<a
href=\"../document/download.php?doc_url=%2Faudio%2F".Security::remove_XSS($exercise_sound)."\"
echo "<a
href=\"../document/download.php?doc_url=%2Faudio%2F".Security::remove_XSS($exercise_sound)."\"
target=\"_blank\">";
echo "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound')."\" /></a>";
}
@ -1093,27 +1092,27 @@ if (!empty($error)) {
elm.attachEvent(\'on\' + evType, fn);
} else{
elm[\'on\'+evType] = fn;
}
}
return;
}
var calledUpdateDuration = false;
var calledUpdateDuration = false;
function updateDuration() {
if (calledUpdateDuration === false) {
var saveDurationUrl = "'.$saveDurationUrl.'";
// Logout of course just in case
$.ajax({
async: false,
async: false,
url: saveDurationUrl,
success: function (data) {
calledUpdateDuration = true;
return;
},
},
});
return;
}
}
$(function() {
//This pre-load the save.png icon
var saveImage = new Image();
@ -1123,14 +1122,14 @@ if (!empty($error)) {
$(".block_on_enter").keypress(function(event) {
return event.keyCode != 13;
});
$(".checkCalculatedQuestionOnEnter").keypress(function(event) {
if (event.keyCode === 13) {
event.preventDefault();
var id = $(this).attr("id");
var parts = id.split("_");
var buttonId = "button_" + parts[1];
document.getElementById(buttonId).click();
document.getElementById(buttonId).click();
}
});
@ -1146,7 +1145,7 @@ if (!empty($error)) {
$(".no_remind_highlight").hide();
// if the users validates the form using return key,
// if the users validates the form using return key,
// prevent form action and simulates click on validation button
/*$("#exercise_form").submit(function(){
$(".question-validate-btn").first().trigger("click");
@ -1154,10 +1153,10 @@ if (!empty($error)) {
});*/
$("form#exercise_form").prepend($("#exercise-description"));
$(\'button[name="previous_question_and_save"]\').on("touchstart click", function (e) {
e.preventDefault();
e.stopPropagation();
e.stopPropagation();
var
$this = $(this),
previousId = parseInt($this.data(\'prev\')) || 0,
@ -1178,7 +1177,7 @@ if (!empty($error)) {
$(\'button[name="save_now"]\').on(\'touchstart click\', function (e) {
e.preventDefault();
e.stopPropagation();
var
$this = $(this),
questionId = parseInt($this.data(\'question\')) || 0,
@ -1190,13 +1189,13 @@ if (!empty($error)) {
$(\'button[name="validate_all"]\').on(\'touchstart click\', function (e) {
e.preventDefault();
e.stopPropagation();
validate_all();
});
// Save attempt duration
addExerciseEvent(window, \'unload\', updateDuration , false);
addExerciseEvent(window, \'beforeunload\', updateDuration , false);
addExerciseEvent(window, \'unload\', updateDuration , false);
addExerciseEvent(window, \'beforeunload\', updateDuration , false);
});
function previous_question(question_num) {
@ -1222,11 +1221,11 @@ if (!empty($error)) {
url = "exercise_submit.php?'.$params.'&num='.$current_question.'&remind_question_id='.$remind_question_id.'&reminder=2";
} else {
url = "exercise_submit.php?'.$params.'&num='.$current_question.'&remind_question_id='.$remind_question_id.'";
}
}
window.location = url;
}
function redirectExerciseToResult()
function redirectExerciseToResult()
{
window.location = "'.$script_php.'?'.$params.'";
}
@ -1234,13 +1233,13 @@ if (!empty($error)) {
function save_now(question_id, url_extra, validate) {
// 1. Normal choice inputs
var my_choice = $(\'*[name*="choice[\'+question_id+\']"]\').serialize();
// 2. Reminder checkbox
var remind_list = $(\'*[name*="remind_list"]\').serialize();
// 3. Hotspots
var hotspot = $(\'*[name*="hotspot[\'+question_id+\']"]\').serialize();
// 4. choice for degree of certainty
var my_choiceDc = $(\'*[name*="choiceDegreeCertainty[\'+question_id+\']"]\').serialize();
@ -1253,7 +1252,7 @@ if (!empty($error)) {
my_choice = $.param(my_choice);
}
}
if ($(\'input[name="remind_list[\'+question_id+\']"]\').is(\':checked\')) {
$("#question_div_"+question_id).addClass("remind_highlight");
} else {
@ -1263,7 +1262,7 @@ if (!empty($error)) {
// Only for the first time
var dataparam = "'.$params.'&type=simple&question_id="+question_id;
dataparam += "&"+my_choice+"&"+hotspot+"&"+remind_list+"&"+my_choiceDc;
$("#save_for_now_"+question_id).html(\''.
Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin').'\');
$.ajax({
@ -1274,7 +1273,7 @@ if (!empty($error)) {
success: function(return_value) {
if (return_value == "ok") {
$("#save_for_now_"+question_id).html(\''.
Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\');
Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\');
} else if (return_value == "error") {
$("#save_for_now_"+question_id).html(\''.
Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_SMALL).'\');
@ -1316,7 +1315,7 @@ if (!empty($error)) {
// 3. Hotspots.
var hotspot = $(\'*[name*="hotspot"]\').serialize();
// Question list.
var question_list = ['.implode(',', $questionList).'];
var free_answers = {};
@ -1369,7 +1368,7 @@ if (!empty($error)) {
<input type="hidden" name="origin" value="'.$origin.'" />
<input type="hidden" name="reminder" value="'.$reminder.'" />
<input type="hidden" name="learnpath_id" value="'.$learnpath_id.'" />
<input type="hidden" name="learnpath_item_id" value="'.$learnpath_item_id.'" />
<input type="hidden" name="learnpath_item_id" value="'.$learnpath_item_id.'" />
<input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id.'" />';
// Show list of questions

@ -963,6 +963,7 @@ class Template
*/
public function display($template, $clearFlashMessages = true)
{
$this->assign('page_origin', api_get_origin());
$this->assign('flash_messages', Display::getFlashToString());
if ($clearFlashMessages) {

@ -9,7 +9,7 @@
{% include 'layout/head.tpl'|get_template %}
{% endblock %}
</head>
<body>
<body class="{{ 'page_origin' ? ('page_origin_' ~ page_origin) : '' }}">
<!-- START MAIN -->
<main id="main" dir="{{ text_direction }}" class="{{ section_name }} {{ login_class }}">
<noscript>{{ "NoJavascript"|get_lang }}</noscript>

@ -9,7 +9,7 @@
{% include 'layout/head.tpl'|get_template %}
{% endblock %}
</head>
<body>
<body class="{{ 'page_origin' ? ('page_origin_' ~ page_origin) : '' }}">
<!-- START MAIN -->
<main id="main" dir="{{ text_direction }}" class="{{ section_name }} {{ login_class }}">

Loading…
Cancel
Save