// cnt_storyboard
function show_div(num) {
for (i = 0; i < num; i++) {
("#fld_" + i.toString()).show();
}
}
function one_div(idx, num) {
for (i = 0; i < num; i++) {
if (idx == i) {
$("#fld_" + i.toString()).show();
} else {
$("#fld_" + i.toString()).hide();
}
}
}
function sound(txt) {
const synth = window.speechSynthesis;
slang = "en";
slang = slang + "-" + slang.toUpperCase();
sentences = txt.replace(/\$/g, '').replace(/<[^>]*>?/gm, '').split(/[\\.!?]/);
for (i = 0; i < sentences.length; i++) {
var utterThis = new SpeechSynthesisUtterance(sentences[i]);
utterThis.lang = slang;
synth.speak(utterThis);
}
}
// adapt
function content_adapt() {
// keys
var language = ['','en','es','de','pt','fr'];
// keys
var code = getCookie('druyd1');
if(code == '' || code == '[]'){
code = '{}';
setCookie('druyd1',code,365);
}
var obj = JSON.parse(code);
// base
var cookie = getCookie('druyd0');
if(cookie != '' && cookie.length > 0){
url_structure = window.location.href.split('/');
structure_arr = url_structure[url_structure.length-2].split('-');
dim = structure_arr.length;
slang = url_structure[url_structure.length-1];
nlang = language.indexOf(slang);
if(nlang == undefined){ nlang = 1; }
var code = getCookie('druyd1');
var obj = JSON.parse(code);
student = obj.student;
if(student == ''){
student = user_data[0];
}
if(dim == 1){
$('#title').text("Subject");
$('#cb_main').prop('disabled', true);
$('#review').removeAttr('hidden');
$('#review').prop('disabled', true);
$('#eva').removeAttr('hidden');
$('#clear').removeAttr('hidden');
main_id = obj.id_subjet;
$.ajax({
type:'POST',
url: '/getSubjectModel',
data: JSON.stringify(["Select",nlang]),
contentType:'application/json',
dataType: 'json',
success: function(data){
main_idx = getIdxComboBox(main_id, data);
setupCombobox($('#cb_main'), '100%', data, main_idx, false);
if(main_idx == 0){
id_type = 0;
} else {
id_type = 1;
}
loadMap(main_id, id_type);
}
});
} else if(dim == 2){
semester = url_structure[url_structure.length-2].split('-')[1];
$('#title').text("Test");
$('#cb_main').prop('disabled', true);
$('#review').removeAttr('hidden');
$('#clear').removeAttr('hidden');
$('#return').removeAttr('hidden');
$('#eva').removeAttr('hidden');
main_id = obj.id_test;
$('body').css('cursor', 'progress');
$.ajax({
type:'POST',
url: '/getSemesterTests',
data: JSON.stringify([semester,"Select",nlang]),
contentType:'application/json',
dataType: 'json',
success: function(data){
main_idx = getIdxComboBox(main_id, data[0]);
setupCombobox($('#cb_main'), '100%', data[0], main_idx, false);
id_type = 2;
loadMap(main_id, id_type);
}
});
$('body').css('cursor', 'default');
} else {
// user
en_user_cookie = getCookie('druyd');
if(en_user_cookie != '' && en_user_cookie.length > 0){
if(structure_arr.length == 3){
semester = url_structure[url_structure.length-2].split('-')[1];
arr = url_structure[url_structure.length-2].split('-')[2].split('#');
test = arr[0];
if(arr[1] > 1){
subtest = arr[1];
} else {
subtest = test;
}
$('#title').text("Problem");
$('body').css('cursor', 'progress');
$('#cb_main').prop('disabled', true);
$('#generate').hide();
$.ajax({
type:'POST',
url: '/getMap',
data: JSON.stringify([semester, subtest, 3, nlang]),
contentType:'application/json',
dataType: 'json',
success: function(data){
setdata(data);
getCbs("Select");
$.ajax({
type:"POST",
url:"/setupProblem",
data: JSON.stringify([semester, test, student, "Select", "Exercise"]),
contentType:"application/json",
dataType: 'json',
success:function (data) {
test_work = data[0];
problem_ctrl = data[1];
setupCombobox($('#cb_main'), '100%', data[2], 0, false);
if(test_work < 2){
$('#send').removeAttr('hidden');
$('#password').removeAttr('hidden');
$('#save').removeAttr('hidden');
$('#clear').removeAttr('hidden');
} else {
$('#return').removeAttr('hidden');
$('#eva').removeAttr('hidden');
}
$('body').css('cursor', 'default');
$('#cb_main').prop('disabled', false);
}
});
}
});
}
} else {
window.location = window.location.href+'/login';
}
}
}
en_user_cookie = getCookie('druyd');
if(de_user_cookie != '' && de_user_cookie.length > 0){
user_data = JSON.parse(de_user_cookie);
if(user_data[0] == 1){
$('#save_clipboard').removeAttr('hidden');
$('#load_clipboard').removeAttr('hidden');
}
if(dim < 3){
$('#savefile').removeAttr('hidden');
$('#loadfile').removeAttr('hidden');
}
}
}
// actions
(document).ready(function () {
content_adapt()
// content_action in cnt_storyboard
$('#cb_main').on('select',function(event){
$('#problem_text').html('');
clearForm();
if(structure_arr.length == 1){
main_idx =
('#cb_main').jqxComboBox('getSelectedIndex') - 1;
main_id = ('#cb_main').val();
var code = getCookie('druyd1');
if(code == '[]'){ code = '{}'; }
var obj = JSON.parse(code);
obj.id_subject = main_id;
code = JSON.stringify(obj);
setCookie('druyd1',code,365);
if(main_idx == 0){
loadMap(main_id, 0);
} else {
loadMap(main_id, 1);
}
} else if(structure_arr.length == 2){
main_idx =
('#cb_main').jqxComboBox('getSelectedIndex') - 1;
main_id = ('#cb_main').val();
var code = getCookie('druyd1');
if(code == '[]'){ code = '{}'; }
var obj = JSON.parse(code);
obj.id_test = main_id;
code = JSON.stringify(obj);
setCookie('druyd1',code,365);
loadMap(main_id,2);
} else {
var code = getCookie('druyd1');
if(code == '[]'){ code = '{}'; }
var obj = JSON.parse(code);
obj.problem =
('#cb_main').val();
answer_id = ('#cb_main').jqxComboBox('getSelectedIndex');
main_idx = answer_id - 1;
var code2 = JSON.stringify(obj);
setCookie('druyd1',code2,365);
if(problem_ctrl[main_idx] == 0){
var pnew = genProblem(pproblem, cb_converts);
var xml = buildProblemXml(pnew);
problem_ctrl[main_idx] = 1;
} else {
var xml = '';
}
$.ajax({
type:"POST",
url:"/getProblemXml",
data: JSON.stringify([semester, test, student, obj.problem, xml]),
contentType:"application/json",
dataType: 'json',
success:function (data) {
// help
if(select_eq[0] == -1){ setupCombobox(
('#equation_0'), '100%', cb_eq_list, 0, false); ('#clip0').removeAttr('hidden'); }
if(select_eq[1] == -1){ setupCombobox(
('#equation_1'), '100%', cb_eq_list, 0, false); ('#clip1').removeAttr('hidden'); }
if(select_eq[2] == -1){ setupCombobox(
('#equation_2'), '100%', cb_eq_list, 0, false); ('#clip2').removeAttr('hidden'); }
if(select_eq[3] == -1){ setupCombobox(
('#equation_3'), '100%', cb_eq_list, 0, false); ('#clip3').removeAttr('hidden'); }
/*
html = getModelEquation(model_idx);
('#equations').html(html);
MathJax.Hub.Queue(['Typeset',MathJax.Hub,'equations']);
('#problem-content2').hide();
('#problem-content1').show();
('#help-content2').hide();
('#help-content1').show();
*/
// problem
pproblem = loadProblemToStructure(pproblem,data[0],0);
var text = writeQuestion(pproblem, 1, nlang);
('#problem_text').html(text);
clearForm();
writeForm(pproblem);
loadResponceXml1(data[1]);
if(test_work == 2){
loadEvaluateXml1(data[2]);
writeReviewManForm();
mark = Math.round(100*data[3]);
$('#eva').html('
'+mark+'%
');
}
}
});
}
});
$('#model2').on('select',function(event){
model_idx2 = $('#model2').jqxComboBox('getSelectedIndex') - 1;
arr = cb_model_list[model_idx2+1].value.split('@');
if(model_idx2 > -1){
$('#description').html(arr[1]);
var html = '';
html = html + "
";
html = html + "
";
html = html + "
";
('#desimage').html(html);
("
![]()
").attr('src', '/static/domains/gphysics.net/images/'+arr[2])
.on('load', function() {
('#desimage').height(this.height);
});
var pardata = par_list[model_idx2][1];
if(arr[4] == 2){
$('#getnet2').removeAttr('hidden');
$('#getnet2').show();
} else {
$('#getnet2').hide();
}
html = getModelParameter(model_idx2,"Symbol","Text","Parameter","Unit");
('#parameters2').html(html);
MathJax.Hub.Queue(['Typeset',MathJax.Hub,parameters2]);
// network
draw2();
html = getModelEquation(model_idx2,"Symbol","Text","Equation","Variables","Unit",2);
('#equations2').html(html);
MathJax.Hub.Queue(['Typeset',MathJax.Hub,'equations2']);
('#model-content').show();
} else {
('#model-content').hide();
}
});
('#probdemo').click(function(){
pproblem = genDemo(pproblem, problem_list, convert_list);
var text = writeQuestion(pproblem, 1, nlang);
('#problem_text').html(text);
clearForm();
writeForm(pproblem);
('#review').prop('disabled',false);
('#eva').html('');
setupReview();
});
('#generate').click(function(){
if(main_idx > -1){
pproblem = genProblem(pproblem, convert_list);
if(pproblem != {}){
var text = writeQuestion(pproblem, 1, nlang);
('#problem_text').html(text);
clearForm();
writeForm(pproblem);
('#review').prop('disabled',false);
('#eva').html('');
setupReview();
}
} else {
Swal.fire({icon:'error',title: "Error",text: "No topic has been selected."});
}
});
('#send').click(function(){
if(
('#password').val().length == 0){
Swal.fire({icon:'error',title: "Error",text: "No password given."});
} else {
var url_structure = window.location.href.split('/');
url = '/';
for(var i = 3;i < url_structure.length - 2;i++){
url = url + url_structure[i] + '/';
}
$.ajax({
type:"POST",
url:"/sendTest",
data: JSON.stringify([user_data[1], $('#password').val(), semester, test, student]),
contentType:"application/json",
dataType: 'json',
success:function (data) {
if(data == 1){
Swal.fire({icon:'success',title: "Success",text: "Test delivered successfully."});
window.location.href = url + 'tests-'+semester+'/' + slang;
} else {
Swal.fire({icon:'error',title: "Error",text: "Wrong password, test not delivered."});
}
}
});
}
});
('#conditions').on('select',function(event){
html = getMainEquation("Symbol","Text","Equation","Variables","Unit");
('#equations').html(html);
MathJax.Hub.Queue(['Typeset',MathJax.Hub,'equations']);
});
('#return').click(function(){
window.location.href = '/work/tools/solving.problems/generating.problems/tests-'+semester+'/'+slang;
});
('#eva_save').click(function(){
if(pproblem != {}){
answer = $('#cb_main').jqxComboBox('getSelectedIndex');
en_user_cookie = getCookie('druyd');
if(de_user_cookie != '' && de_user_cookie.length > 0){
var user_data = JSON.parse(de_user_cookie);
de_user = user_data[0];
de_code = user_data[4];
var score = reviewNet(pproblem);
$.ajax({
type:"POST",
url:"/saveScore",
data: JSON.stringify([de_user, de_code, semester, test, student, answer, score]),
contentType:"application/json",
dataType: 'json',
success:function (data) {
Swal.fire({icon:'success',title: "Success",text: "Stored successfully."});
}
});
}
}
});
('#corr').click(function(){
if(test_work == 0 || test_work == 2){
var mark = reviewNet(pproblem);
writeReviewNet();
eva = Math.round(100*mark);
$('#eva').html('
'+eva+'%
');
('#mark').val(mark);
}
});
('#corr_save').click(function(){
if(pproblem != {}){
answer =
('#cb_main').jqxComboBox('getSelectedIndex');
en_user_cookie = getCookie('druyd');
if(de_user_cookie != '' && de_user_cookie.length > 0){
var user_data = JSON.parse(de_user_cookie);
de_user = user_data[0];
de_code = user_data[4];
var score = reviewNet(pproblem);
var xml_evaluate = buildEvaluateXml3();
$.ajax({
type:"POST",
url:"/saveEvaluation",
data: JSON.stringify([de_user, de_code, semester, test, student, answer, xml_evaluate, score]),
contentType:"application/json",
dataType: 'json',
success:function (data) {
Swal.fire({icon:'success',title: "Success",text: "Stored successfully."});
}
});
}
}
});
('#review').click(function(){
if(test_work == 0 || test_work == 2){
// var eva = reviewManForm(pproblem);
var eva = 0;
writeReviewManForm();
mark = Math.round(100*eva);
$('#eva').html('
'+mark+'%
');
}
});
('#clear').click(function(){
clearForm();
});
('#equation_0').on('select',function(event){
select_eq[0] =
('#equation_0').jqxComboBox('getSelectedIndex') - 1;
if(main_idx > -1){
if(select_eq[0] > -1){
setupCombobox($('#int_0'), '100%', cb_eqvar_list[select_eq[0]][1], 0, false);
} else {
$('#int_0').jqxComboBox('clear');
}
}
});
('#clip0').click(function(){
('#cleared_0').val(('#equation_0').jqxComboBox('getSelectedItem').label);
});
('#equation_1').on('select',function(event){
select_eq[1] = $('#equation_1').jqxComboBox('getSelectedIndex') - 1;
if(main_idx > -1){
if(select_eq[1] > -1){
setupCombobox($('#int_1'), '100%', cb_eqvar_list[select_eq[1]][1], 0, false);
} else {
$('#int_1').jqxComboBox('clear');
}
}
});
('#clip1').click(function(){
('#cleared_1').val(('#equation_1').jqxComboBox('getSelectedItem').label);
});
('#equation_2').on('select',function(event){
select_eq[2] = $('#equation_2').jqxComboBox('getSelectedIndex') - 1;
if(main_idx > -1){
if(select_eq[2] > -1){
setupCombobox($('#int_2'), '100%', cb_eqvar_list[select_eq[2]][1], 0, false);
} else {
$('#int_2').jqxComboBox('clear');
}
}
});
('#clip2').click(function(){
('#cleared_2').val(('#equation_2').jqxComboBox('getSelectedItem').label);
});
('#equation_3').on('select',function(event){
select_eq[3] = $('#equation_3').jqxComboBox('getSelectedIndex') - 1;
if(main_idx > -1){
if(select_eq[3] > -1){
setupCombobox($('#int_3'), '100%', cb_eqvar_list[select_eq[3]][1], 0, false);
} else {
$('#int_3').jqxComboBox('clear');
}
}
});
('#clip3').click(function(){
('#cleared_3').val(('#equation_3').jqxComboBox('getSelectedItem').label);
});
('#save').click(function(){
if(pproblem != {}){
//score = reviewManForm(pproblem);
score = 0;
answer = $('#cb_main').jqxComboBox('getSelectedIndex');
en_user_cookie = getCookie('druyd');
if(de_user_cookie != '' && de_user_cookie.length > 0){
var user_data = JSON.parse(de_user_cookie);
de_user = user_data[0];
de_code = user_data[4];
var xml_responce = buildResponceXml1();
var xml_evaluate = buildEvaluateXml1();
$.ajax({
type:"POST",
url:"/saveAnswer",
data: JSON.stringify([de_user, de_code, semester, test, answer, xml_responce, xml_evaluate, score]),
contentType:"application/json",
dataType: 'json',
success:function (data) {
if(data['processed'] == 'true'){
Swal.fire({icon:'success',title: "Success",text: "Stored successfully."});
} else if(data['meassage'] == 'exercise do not exist'){
Swal.fire({icon:'error',title: "Error",text: "Exercise do not exist." });
} else if(data['meassage'] == 'test not open'){
Swal.fire({icon:'error',title: "Error",text: "Test not open." });
} else if(data['meassage'] == 'test not generated'){
Swal.fire({icon:'error',title: "Error",text: "Test not generated." });
}
}
});
}
}
});
('#load').click(function(){
if(main_idx > -1){
.ajax({
type:"POST",
url:"/loadClipboard",
data: '1',
contentType:"application/json",
dataType: 'json',
success:function (data) {
loadResponceXml1(pproblem,data);
}
});
} else {
Swal.fire({icon:'error',title: "Error",text: "No topic has been selected."});
}
});
('#save_clipboard').click(function(){
if(pproblem != {}){
en_user_cookie = getCookie('druyd');
if(de_user_cookie != '' && de_user_cookie.length > 0){
var user_data = JSON.parse(de_user_cookie);
de_user = user_data[0];
de_code = user_data[4];
var xml = buildProblemXml(pproblem);
.ajax({
type:"POST",
url:"/saveClipboard",
data: JSON.stringify([de_user, de_code, xml, semester, 1]),
contentType:"application/json",
dataType: 'json',
success:function (data) {
//
}
});
}
}
});
('#load_clipboard').click(function(){
if(main_idx > -1){
.ajax({
type:"POST",
url:"/loadClipboard",
data: JSON.stringify([semester, 1]),
contentType:"application/json",
dataType: 'json',
success:function (data) {
pproblem = loadProblemToStructure(pproblem,data);
var text = writeQuestion(pproblem, 1, nlang);
$('#problem_text').html(text);
clearForm();
writeForm(pproblem);
$('#review').prop('disabled',false);
$('#eva').html('');
}
});
} else {
Swal.fire({icon:'error',title: "Error",text: "No topic has been selected."});
}
});
('#savefile').click(function(){
var xml = '
gPhysicsSolver1.0'+id_main+''+id_type+'';
var xml_problem = buildProblemXml(pproblem);
var xml_responce = buildResponceXml1();
saveFile(xml+'@#@#@'+xml_problem+'@#@#@'+xml_responce);
});
('#loadfile').click(function(){
loadFile();
});
var idx = 0;
var num = "1";
("#lr").hide()
("#content").css({ 'height': (window.innerHeight - $('#head').height() - 16) + 'px' });
('#select input[type=radio]').change(function () {
("#content").css({ 'height': (window.innerHeight - $('#head').height() - 16) + 'px' });
if ((this).val() == 2) {
("#lr").show(num);
cnt = idx + 1
('#cnt').text(cnt.toString() + ' of ' + num.toString());
one_div(idx, num);
("#fld_video").hide();
} else {
$("#lr").hide();
if ($(this).val() == 3) {
one_div(-1, num);
$("#fld_video").show();
} else {
show_div(num);
$("#fld_video").hide();
}
}
});
('#select input[type=label]').click(function () {
});
("#left").click(function () {
idx--;
if (idx < 0) { idx = num - 1; }
cnt = idx + 1
$('#cnt').text(cnt.toString() + ' of ' + num.toString());
one_div(idx, num);
});
("#right").click(function () {
idx++;
if (idx > num - 1) { idx = 0; }
cnt = idx + 1
('#cnt').text(cnt.toString() + ' of ' + num.toString());
one_div(idx, num);
});
("#ctrl").click(function () {
if (
("#index-panel").is(":visible") == true) {
$("#index-panel").hide();
$('#mainSplitter').jqxSplitter({ panels: [{ size: '0%' }, { size: '100%' }] });
$("#arrow").attr("src", "/static/icons/chevronright32b.png");
} else {
$("#index-panel").show();
$('#mainSplitter').jqxSplitter({ panels: [{ size: '25%' }, { size: '75%' }] });
$("#arrow").attr("src", "/static/icons/chevronleft32b.png");
}
});
// radiobuttons of Model
('#networkEquation').on("click", function () {
setNetworkEquation(vgraph_network);
});
$('#networkNumber').on("click", function () {
setNetworkNumber(vgraph_network);
});
});