Minor - format code.

1.9.x
Julio Montoya 10 years ago
parent d7c34ee927
commit b23428a48f
  1. 306
      main/exercice/exercise_submit.php

@ -838,182 +838,182 @@ if (!empty($error)) {
}
echo '<script>
$(function() {
//$(".exercise_save_now_button").hide();
$(".main_question").mouseover(function() {
//$(this).find(".exercise_save_now_button").show();
//$(this).addClass("question_highlight");
});
$(".main_question").mouseout(function() {
//$(this).find(".exercise_save_now_button").hide();
$(this).removeClass("question_highlight");
});
$(".no_remind_highlight").hide();
// 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");
return false;
});*/
});
$(function() {
//$(".exercise_save_now_button").hide();
$(".main_question").mouseover(function() {
//$(this).find(".exercise_save_now_button").show();
//$(this).addClass("question_highlight");
});
$(".main_question").mouseout(function() {
//$(this).find(".exercise_save_now_button").hide();
$(this).removeClass("question_highlight");
});
$(".no_remind_highlight").hide();
// 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");
return false;
});*/
});
function previous_question(question_num) {
url = "exercise_submit.php?'.$params.'&num="+question_num;
window.location = url;
}
function previous_question_and_save(previous_question_id, question_id_to_save) {
url = "exercise_submit.php?'.$params.'&num="+previous_question_id;
//Save the current question
save_now(question_id_to_save, url);
function previous_question_and_save(previous_question_id, question_id_to_save) {
url = "exercise_submit.php?'.$params.'&num="+previous_question_id;
//Save the current question
save_now(question_id_to_save, url);
}
function save_question_list(question_list) {
$.each(question_list, function(key, question_id) {
save_now(question_id, null, false);
});
var url = "";
if ('.$reminder.' == 1 ) {
url = "exercise_reminder.php?'.$params.'&num='.$current_question.'";
} else if ('.$reminder.' == 2 ) {
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.'";
}
//$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL)).'");
window.location = url;
}
function save_question_list(question_list) {
$.each(question_list, function(key, question_id) {
save_now(question_id, null, false);
});
function save_now(question_id, url_extra) {
//1. Normal choice inputs
var my_choice = $(\'*[name*="choice[\'+question_id+\']"]\').serialize();
var url = "";
if ('.$reminder.' == 1 ) {
url = "exercise_reminder.php?'.$params.'&num='.$current_question.'";
} else if ('.$reminder.' == 2 ) {
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.'";
//2. Reminder checkbox
var remind_list = $(\'*[name*="remind_list"]\').serialize();
//3. Hotspots
var hotspot = $(\'*[name*="hotspot[\'+question_id+\']"]\').serialize();
//Checking FCK
if (typeof(FCKeditorAPI) !== "undefined") {
var oEditor = FCKeditorAPI.GetInstance("choice["+question_id+"]") ;
var fck_content = "";
if (oEditor) {
fck_content = oEditor.GetHTML();
my_choice = {};
my_choice["choice["+question_id+"]"] = fck_content;
my_choice = $.param(my_choice);
}
//$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL)).'");
window.location = url;
}
function save_now(question_id, url_extra) {
//1. Normal choice inputs
var my_choice = $(\'*[name*="choice[\'+question_id+\']"]\').serialize();
if ($(\'input[name="remind_list[\'+question_id+\']"]\').is(\':checked\')) {
$("#question_div_"+question_id).addClass("remind_highlight");
} else {
$("#question_div_"+question_id).removeClass("remind_highlight");
}
//2. Reminder checkbox
var remind_list = $(\'*[name*="remind_list"]\').serialize();
// Only for the first time
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('loading1.gif')).'");
$.ajax({
type:"post",
async: false,
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=save_exercise_by_now",
data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list,
success: function(return_value) {
if (return_value == "ok") {
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL)).'");
} else if (return_value == "error") {
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL)).'");
} else if (return_value == "one_per_page") {
var url = "";
if ('.$reminder.' == 1 ) {
url = "exercise_reminder.php?'.$params.'&num='.$current_question.'";
} else if ('.$reminder.' == 2 ) {
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.'";
}
//3. Hotspots
var hotspot = $(\'*[name*="hotspot[\'+question_id+\']"]\').serialize();
if (url_extra) {
url = url_extra;
}
//Checking FCK
if (typeof(FCKeditorAPI) !== "undefined") {
var oEditor = FCKeditorAPI.GetInstance("choice["+question_id+"]") ;
var fck_content = "";
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL)).'");
if (oEditor) {
fck_content = oEditor.GetHTML();
my_choice = {};
my_choice["choice["+question_id+"]"] = fck_content;
my_choice = $.param(my_choice);
}
window.location = url;
}
},
error: function() {
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL)).'");
}
});
return false;
}
if ($(\'input[name="remind_list[\'+question_id+\']"]\').is(\':checked\')) {
$("#question_div_"+question_id).addClass("remind_highlight");
} else {
$("#question_div_"+question_id).removeClass("remind_highlight");
}
function save_now_all(validate) {
// 1. Input choice.
var my_choice = $(\'*[name*="choice"]\').serialize();
// Only for the first time
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('loading1.gif')).'");
$.ajax({
type:"post",
async: false,
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=save_exercise_by_now",
data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list,
success: function(return_value) {
if (return_value == "ok") {
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL)).'");
} else if (return_value == "error") {
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL)).'");
} else if (return_value == "one_per_page") {
var url = "";
if ('.$reminder.' == 1 ) {
url = "exercise_reminder.php?'.$params.'&num='.$current_question.'";
} else if ('.$reminder.' == 2 ) {
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.'";
}
if (url_extra) {
url = url_extra;
}
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL)).'");
window.location = url;
}
},
error: function() {
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL)).'");
}
});
return false;
}
// 2. Reminder.
var remind_list = $(\'*[name*="remind_list"]\').serialize();
// 3. Hotspots.
var hotspot = $(\'*[name*="hotspot"]\').serialize();
// Question list.
var question_list = ['.implode(',', $questionList).'];
function save_now_all(validate) {
// 1. Input choice.
var my_choice = $(\'*[name*="choice"]\').serialize();
// 2. Reminder.
var remind_list = $(\'*[name*="remind_list"]\').serialize();
// 3. Hotspots.
var hotspot = $(\'*[name*="hotspot"]\').serialize();
// Question list.
var question_list = ['.implode(',', $questionList).'];
var free_answers = {};
$.each(question_list, function(index, my_question_id) {
//Checking FCK
if (typeof(FCKeditorAPI) !== "undefined") {
var oEditor = FCKeditorAPI.GetInstance("choice["+my_question_id+"]") ;
var fck_content = "";
if (oEditor) {
fck_content = oEditor.GetHTML();
//alert(index + " " +my_question_id + " " +fck_content);
free_answers["free_choice["+my_question_id+"]"] = fck_content;
}
}
});
// lok+(fgt)= data base
free_answers = $.param(free_answers);
$("#save_all_reponse").html("'.addslashes(Display::return_icon('loading1.gif')).'");
$.ajax({
type:"post",
async: false,
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=save_exercise_by_now",
data: "'.$params.'&type=all&"+my_choice+"&"+hotspot+"&"+free_answers+"&"+remind_list,
success: function(return_value) {
if (return_value == "ok") {
//$("#save_all_reponse").html("'.addslashes(Display::return_icon('accept.png')).'");
if (validate == "validate") {
window.location = "'.$script_php.'?'.$params.'";
} else {
$("#save_all_reponse").html("'.addslashes(Display::return_icon('accept.png')).'");
}
} else {
$("#save_all_reponse").html("'.addslashes(Display::return_icon('wrong.gif')).'");
var free_answers = {};
$.each(question_list, function(index, my_question_id) {
//Checking FCK
if (typeof(FCKeditorAPI) !== "undefined") {
var oEditor = FCKeditorAPI.GetInstance("choice["+my_question_id+"]") ;
var fck_content = "";
if (oEditor) {
fck_content = oEditor.GetHTML();
//alert(index + " " +my_question_id + " " +fck_content);
free_answers["free_choice["+my_question_id+"]"] = fck_content;
}
}
});
// lok+(fgt)= data base
free_answers = $.param(free_answers);
$("#save_all_reponse").html("'.addslashes(Display::return_icon('loading1.gif')).'");
$.ajax({
type:"post",
async: false,
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=save_exercise_by_now",
data: "'.$params.'&type=all&"+my_choice+"&"+hotspot+"&"+free_answers+"&"+remind_list,
success: function(return_value) {
if (return_value == "ok") {
//$("#save_all_reponse").html("'.addslashes(Display::return_icon('accept.png')).'");
if (validate == "validate") {
window.location = "'.$script_php.'?'.$params.'";
} else {
$("#save_all_reponse").html("'.addslashes(Display::return_icon('accept.png')).'");
}
} else {
$("#save_all_reponse").html("'.addslashes(Display::return_icon('wrong.gif')).'");
}
});
return false;
}
}
});
return false;
}
function validate_all() {
save_now_all("validate");
return false;
}
</script>';
function validate_all() {
save_now_all("validate");
return false;
}
</script>';
echo '<form id="exercise_form" method="post" action="'.api_get_self().'?'.api_get_cidreq().'&autocomplete=off&gradebook='.$gradebook."&exerciseId=" . $exerciseId .'" name="frm_exercise" '.$onsubmit.'>
<input type="hidden" name="formSent" value="1" />

Loading…
Cancel
Save