// 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);
}
arrcode = 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];
}
$('#panel').show();
if(dim == 1){
// models by subject (combobox) /network
$('#title').text("Subject");
$('#cb_main').prop('disabled', true);
$('#review').removeAttr('hidden');
$('#eva').removeAttr('hidden');
$('#clear').removeAttr('hidden');
$('#select_variables').hide();
$('#header').show();
id_main = obj.id_subjet;
$.ajax({
type:'POST',
url: '/getSubjectModel',
data: JSON.stringify(["Select",nlang]),
contentType:'application/json',
dataType: 'json',
success: function(data){
main_idx = getIdxComboBox(id_main, data);
setupCombobox($('#cb_main'), '100%', data, main_idx, false);
if(main_idx == 0){
id_type = 0;
} else {
id_type = 1;
}
loadMap(id_main, id_type);
}
});
} else if(dim == 2){
// models for course by test (combobox) /network-53
semester = url_structure[url_structure.length-2].split('-')[1];
$('#title').text("Test");
$('#cb_main').prop('disabled', true);
$('#eva').removeAttr('hidden');
$('#clear').removeAttr('hidden');
$('#return').removeAttr('hidden');
$('#select_variables').hide();
$('#header').show();
$('#solution').hide();
$('#review').removeAttr('hidden');
$('#review').prop('disabled', true);
$('#generate').removeAttr('hidden');
$('#generate').prop('disabled', true);
var en = getCookie('druyd');
if(en != ''){ de = base64DecodeUnicode(en); }
else { de = ''; }
if(de != '' && de.length > 0){
da = JSON.parse(de);
if(da[0] == 1){
$('#solve').removeAttr('hidden');
$('#solve').prop('disabled', true);
}
}
$.ajax({
type:'POST',
url: '/getSemesterTests',
data: JSON.stringify([semester,"Select",nlang]),
contentType:'application/json',
dataType: 'json',
success: function(data){
main_idx = getIdxComboBox(id_main, data[0]);
setupCombobox($('#cb_main'), '100%', data[0], main_idx, false);
id_type = 2;
loadMap(id_main, id_type);
}
});
} else {
// models by course, test and exercise (combobox) /network-53-2
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;
}
if(semester > 0){
en_user_cookie = getCookie('druyd');
if(en_user_cookie != '' && en_user_cookie.length > 0){
$('#title').text("Problem");
$('body').css('cursor', 'progress');
$('#cb_main').prop('disabled', true);
$('#header').show();
if(user_data[0] == 1){
$('#correct').removeAttr('hidden');
$('#correct').show();
$('#ctl_model').removeAttr('hidden');
$('#ctl_model').show();
}
$.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){
$('#save').removeAttr('hidden');
$('#send').removeAttr('hidden');
$('#password').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';
}
} else {
$('#title').text("Model");
$('#header').hide();
$('#panel').hide();
$.ajax({
type:'POST',
url: '/getMap',
data: JSON.stringify([semester, subtest, 0, nlang]),
contentType:'application/json',
dataType: 'json',
success: function(data){
model_idx = -1;
setdata(data);
//getCbs("Select");
$('#model-content').show();
$('#model').html('');
$('#description').html('');
$('#desimage').html('');
$('#probdemo').hide();
$('#problem-content1').show();
$('#help-content1').show();
}
});
}
}
}
}
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('');
clearAll();
corr = 0;
if(dim == 1){
main_idx =
('#cb_main').jqxComboBox('getSelectedIndex');
id_main = ('#cb_main').val();
var code = getCookie('druyd1');
if(code == '[]'){ code = '{}'; }
var obj = JSON.parse(code);
obj.id_subject = id_main;
code = JSON.stringify(obj);
setCookie('druyd1',code,365);
if(main_idx == 0){
id_type = 0;
} else {
id_type = 1;
}
loadMap(semester,id_main, id_type);
} else if(dim == 2){
main_idx =
('#cb_main').jqxComboBox('getSelectedIndex');
id_main = ('#cb_main').val();
var code = getCookie('druyd1');
if(code == '[]'){ code = '{}'; }
var obj = JSON.parse(code);
obj.id_test = id_main;
code = JSON.stringify(obj);
setCookie('druyd1',code,365);
id_type = 2;
loadMap(semester,id_main,id_type);
if(id_main > 0){
('#generate').prop('disabled', false);
('#solve').prop('disabled', false);
} else {
('#generate').prop('disabled', true);
('#solve').prop('disabled', true);
}
} else if(dim > 2){
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){
// generate problem
var pnew = getProbQuestion(problem_list, eqpar_list);
var xml = JSON.stringify(pnew);
problem_ctrl[main_idx] = 1;
} else {
var xml = '';
}
// save
$.ajax({
type:"POST",
url:"/getProblemXml",
data: JSON.stringify([semester, test, student, obj.problem, xml]),
contentType:"application/json",
dataType: 'json',
success:function (data) {
clearAll();
question = JSON.parse(data[0]);
('#problem_text').html(question['problem']);
('#parameter_text').html(question['parameters']);
vgraph_network = loadResponceXml3(data[1]);
network_graph_calc('graph_network',vgraph_network,$('#graph_network').width(),800);
if(test_work == 2){
loadEvaluateXml3(data[2]);
mark = Math.round(100*data[3]);
$('#eva').html('
'+mark+'%
');
('#mark').val(data[3]);
('#solution_text').html(question['solution']);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown){
Swal.fire({icon:'error',title: "Error",text: "{{no_internet_connection}}" });
}
});
}
if(main_idx > -1){
setupCombobox(
('#model'), '100%', cb_model_list, 0, false);
}
});
('#save').click(function(){
var evaluate;
var review = {};
if(pproblem != {}){
answer_id =
('#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 responce = buildResponceXml3(vgraph_network);
try {
evaluate = buildEvaluateXml3();
review = JSON.parse(evaluate);
} catch (error) {
evaluate = '';
review['score'] = 0;
}
$.ajax({
type:"POST",
url:"/saveAnswer",
data: JSON.stringify([de_user, de_code, semester, test, student, answer_id, responce, evaluate, review['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." });
}
},
error: function(XMLHttpRequest, textStatus, errorThrown){
Swal.fire({icon:'error',title: "Error",text: "{{no_internet_connection}}" });
}
});
}
}
});
('#model').on('select',function(event){
// select model
model_idx =
('#model').jqxComboBox('getSelectedIndex') - 1;
if(model_idx > -1){
$('#model-content').show();
// build parameter table (netmanual.js)
getModelParameter('parameters', par_list[model_idx][1], units_list[model_idx][1]);
// draw network (network_graph.js)
vgraph_network = setupNetworkModel(model_idx, par_list[model_idx][1], eqcnt_list[model_idx][1], eqpar_list[model_idx][1], units_list[model_idx][1]);
network_graph_calc('graph_network',vgraph_network,$('#graph_network').width(),800);
// list related equations (netmanual.js)
getModelEquation('equations', eqcnt_list[model_idx][1], eqpar_list[model_idx][1], 2);
// build auxiliary network (network_graph.js)
vgraph_strategy = setupNetworkModel(model_idx, par_list[model_idx][1], eqcnt_list[model_idx][1], eqpar_list[model_idx][1], units_list[model_idx][1]);
drawStrategy('graph_strategy',vgraph_strategy,$('#graph_strategy').width(),800);
} else {
$('#model-content').hide();
}
});
('#generate').click(function(){
('#eva').text('');
('#solution').hide();
clearAll();
// read selected topic
main_idx =
('#cb_main').jqxComboBox('getSelectedIndex');
if(main_idx == 0){
Swal.fire({icon:'error', title: "Error",text: "No topic or test was selected."});
} else {
// select and build problem (netmanual.js)
question = getProblemQuestion('problem_text', 'parameter_text', problem_list, eqpar_list);
$('#select_variables').show();
$('#review').prop('disabled', false);
}
});
('#review').click(function(){
('#eva').text('');
('#solution').show();
var var_no = 0;
var var_yes = 0;
var dat_no = 0;
var dat_yes = 0;
var cal_no = 0;
var cal_yes = 0;
var eva = 0;
var ok = 1;
model_id =
('#model').jqxComboBox('getSelectedItem').value.split('@')[0];
if(question['model_id'] == model_id){
$('#rev_model').attr("src", "/static/icons/yes.png");
var num = vgraph_network.calcs.length - 1;
if(question['result_id'] != vgraph_network.calcs[num]['id']){
$('#rev_result').attr("src", "/static/icons/no.png");
$('#rev_result').attr("title", "102"); // wrong target
ok = 0;
} else {
$('#rev_result').attr("src", "/static/icons/yes.png");
}
} else {
$('#rev_model').attr("src", "/static/icons/no.png");
$('#rev_model').attr("title", "101"); // wrong model
$('#rev_result').attr("src", "/static/icons/no.png");
$('#rev_result').attr("title", "102"); // wrong target
ok = 0;
}
if(ok == 1){
// check model variables
for(var i = 0;i < par_list[model_idx][1].length;i++){
var fld = par_list[model_idx][1][i];
if($('#val_value_'+fld[3]).val() != ''){
if($('#mks_value_'+fld[3]).text() == ''){
$('#rev_var_'+fld[3]).attr("src", "/static/icons/no.png");
$('#rev_var_'+fld[3]).attr("title", "201"); // no converted value
var_no++;
} else {
var value = parseFloat($('#mks_value_'+fld[3]).text());
var idx = getQuestionIndex(fld[3]);
if(idx < question['values'].length){
var qvalue = parseFloat(question['values'][idx]['mks_value']);
if(value + qvalue != 0){
err = Math.abs(2*(value - qvalue)/(value + qvalue));
} else if(value == qvalue){
err = 0;
} else {
err = 1;
}
if(err <= 0.01 && question['values'][idx]['request']){
$('#rev_var_'+fld[3]).attr("src", "/static/icons/yes.png");
$('#rev_data_'+fld[3]).attr("src", "/static/icons/yes.png");
var_yes++;
dat_yes++;
} else {
$('#rev_var_'+fld[3]).attr("src", "/static/icons/no.png");
$('#rev_var_'+fld[3]).attr("title", "202"); // error in trascription or variable asociation
var_no++;
}
}
}
} else {
$('#rev_var_'+fld[3]).attr("src", "/static/icons/ask20g.png");
}
}
// check for not used requested values
for(var i = 0;i < question['values'].length;i++){
fld = question['values'][i]['symbol'];
img = $('#rev_data_'+fld).attr("src");
if(question['values'][i]['show'] == 1 && question['values'][i]['request'] == 1 && img == '/static/icons/ask20g.png'){
$('#rev_data_'+fld).attr("src", "/static/icons/no.png");
$('#rev_data_'+fld).attr("title", "301"); // requeted but not used or wrong associated
dat_no++;
}
}
var i = 0;
//Swal.fire({icon:'error',title: "Error",text: JSON.stringify(vgraph_network.calcs)});
while(i < vgraph_network.calcs.length){
var afld = vgraph_network.calcs[i]['vars'];
var tag = '';
var j = 0;
while(j < afld.length){
if($('#rev_data_'+afld[j]).attr("src") == "/static/icons/no.png"){
ok = 0;
tag = '401'; // source values with errors
break;
}
j++;
}
i++;
// second line; check if variable was offered
var idx = getQuestionIndex(vgraph_network.calcs[i]['symbol']);
if(idx > -1 && question['values'][idx]['show'] == 1 && question['values'][idx]['request'] == 0){
if(tag.length > 0){ tag = tag + ','; }
tag = '402'; // calculated value can be requested
ok = 0;
}
// check if variable is not used
if(vgraph_network.calcs[i]['id'] != question['result_id']){
var sta = 0;
var j = i+1;
while(j < vgraph_network.calcs.length && sta == 0){
if(vgraph_network.calcs[j]['vars'].indexOf(vgraph_network.calcs[i]['symbol']) > -1){
sta = 1;
}
j = j + 2;
}
if(sta == 0){
if(tag.length > 0){ tag = tag + ','; }
tag = '403'; // calculated value not used
ok = 0;
}
}
// check last conversion is done
sybl = vgraph_network.calcs[i]['symbol'];
if(ok == 1){
$('#rev_calc_'+sybl+'_c').attr("src","/static/icons/yes.png");
cal_yes++;
} else {
$('#rev_calc_'+sybl+'_c').attr("src","/static/icons/no.png");
$('#rev_calc_'+sybl+'_c').attr("title",tag);
cal_no++;
}
i++;
}
// end conversion
tag = '';
if($('#val_value_'+sybl+'_c').text().length == 0){
tag = '404'; // no conversion of enresult
}
var unit = parseInt($('#val_unit_'+sybl+'_c').val().split('@')[0]);
var funit = question['result_unit'];
if(funit != unit){
if(tag.length > 0){ tag = tag + ','; }
tag = '405'; // wrong conversion
}
if(tag.length > 0){
$('#rev_conv_'+sybl+'_c').attr("src","/static/icons/no.png");
$('#rev_conv_'+sybl+'_c').attr("title",tag);
cal_no++;
} else {
$('#rev_conv_'+sybl+'_c').attr("src","/static/icons/yes.png");
cal_yes++;
}
}
if(var_no + var_yes > 0){
eva = eva + 25*var_yes/(var_no+var_yes);
}
if(dat_no + dat_yes > 0){
eva = eva + 25*dat_yes/(dat_no+dat_yes);
}
if(cal_no + cal_yes > 0){
eva = eva + 50*cal_yes/(cal_no+cal_yes);
}
var seva = gNiceFormat(eva)+'% ('+gNiceFormat(1 + 6*eva/100)+')';
('#eva').show();
('#eva').text(seva);
('#solution_text').html(question['solution']);
});
('#solve').click(function(){
$('#eva').text('');
var model_idx = 0;
while(model_idx < cb_model_list.length){
item = cb_model_list[model_idx].value.split('@')[0];
if(item == question['model_id']){
break;
}
model_idx++
}
if(model_idx < cb_model_list.length){
// ofered variables
$('#model').jqxComboBox('selectIndex', model_idx );
var request = [];
for(var i = 0;i < question['values'].length;i++){
if(question['values'][i]['show'] == 1){
request.push(question['values'][i]['symbol']);
}
}
// find eqpar_list
var idx = 0;
while(idx < eqpar_list.length){
if(eqpar_list[idx][0] == question['model_id']){
break;
}
idx++;
}
// model data
arr = eqpar_list[idx][1];
var arr_eq = [];
var arr_cnt = [];
var arr_id = [];
var arr_var = [];
var arr_uni = [];
for(var i = 0;i < arr.length;i++){
arr_eq.push(arr[i][0]);
arr_cnt.push(arr[i][1]);
arr_id.push([]);
arr_var.push([]);
arr_uni.push([]);
for(var j = 0;j < arr[i][2].length;j++){
arr_id[i].push(arr[i][2][j][0]);
arr_var[i].push(arr[i][2][j][11]);
arr_uni[i].push(arr[i][2][j][2]);
}
}
var resids = question['result_id'];
var resymb = question['result_symbol'];
var reunit = question['result_unit'];
var relab = question['result_lab'];
var solution = getEqSolution(arr_eq,arr_cnt,arr_id,arr_var,arr_uni,request,resids,resymb,reunit);
for(var i = 0;i < solution.sva.length;i++){
var symbol = solution.sva[i];
var unit = solution.sun[i];
if(symbol != resymb){
$('#req_'+symbol).click();
$('#val_value_'+symbol).val($('#fld_'+symbol).text());
idx = findUnits(unit,$('#fld_unit_'+symbol).text())
$('#val_unit_'+symbol).jqxComboBox('selectIndex', idx );
$('#conv_'+symbol).click();
}
}
for(var i = 0;i < solution.eqs.length;i++){
var pos = 0;
while(pos < vgraph_network.keys.length){
if(vgraph_network.keys[pos] == 'e@'+solution.eqs[i]){
clickNodeCalc(pos,null,vgraph_network);
network_graph_calc('graph_network',vgraph_network,$('#graph_network').width(),800);
break;
}
pos++;
}
var pos = 0;
while(pos < vgraph_network.keys.length){
if(vgraph_network.keys[pos] == 'v@'+solution.ids[i]){
clickNodeCalc(pos,null,vgraph_network);
network_graph_calc('graph_network',vgraph_network,$('#graph_network').width(),800);
break;
}
pos++;
}
}
if(solution.eqs.length > 0){
var items = $('#val_unit_'+resymb+'_c').jqxComboBox('getItems');
var idx = 0;
while(idx < items.length){
if(items[idx].label == relab){
break;
}
idx++;
}
$('#val_unit_'+resymb+'_c').jqxComboBox('selectIndex', idx );
$('#conv_'+resymb+'_c').click();
}
}
});
('#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."});
}
},
error: function(XMLHttpRequest, textStatus, errorThrown){
Swal.fire({icon:'error',title: "Error",text: "{{no_internet_connection}}" });
}
});
}
});
('#return').click(function(){
window.location.href = '/work/tools/solving.problems/generating.problems/tests-'+semester+'/'+slang;
});
('#answer_save').click(function(){
if(pproblem != {}){
answer_id = $('#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 responce = buildResponceXml3(vgraph_network);
var evaluate = buildEvaluateXml3();
var review = JSON.parse(evaluate);
$.ajax({
type:"POST",
url:"/saveAnswer",
data: JSON.stringify([de_user, de_code, semester, test, student, answer_id, responce, evaluate, review['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." });
}
},
error: function(XMLHttpRequest, textStatus, errorThrown){
Swal.fire({icon:'error',title: "Error",text: "{{no_internet_connection}}" });
}
});
}
}
});
('#eva_save').click(function(){
if(pproblem != {}){
answer_id =
('#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 evaluate = buildEvaluateXml3();
var review = JSON.parse(evaluate);
$.ajax({
type:"POST",
url:"/saveScore",
data: JSON.stringify([de_user, de_code, semester, test, student, answer_id, review['score']]),
contentType:"application/json",
dataType: 'json',
success:function (data) {
if(data['processed'] == 'true'){
Swal.fire({icon:'success',title: "Success",text: "Stored successfully."});
}
},
error: function(XMLHttpRequest, textStatus, errorThrown){
Swal.fire({icon:'error',title: "Error",text: "{{no_internet_connection}}" });
}
});
}
}
});
('#corr').click(function(){
if(test_work == 0 || test_work == 2){
var evaluate = buildEvaluateXml3();
Swal.fire({icon:'success',title: "Success",text: evaluate});
loadEvaluateXml3(evaluate);
var review = JSON.parse(evaluate);
/*
var mark = reviewNet();
writeReviewNet();
eva = Math.round(100*mark);
$('#eva').html('
'+eva+'%
');
('#mark').val(mark);
*/
}
});
('#corr_save').click(function(){
if(pproblem != {}){
answer_id =
('#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 evaluate = buildEvaluateXml3();
var review = JSON.parse(evaluate);
$.ajax({
type:"POST",
url:"/saveEvaluation",
data: JSON.stringify([de_user, de_code, semester, test, student, answer_id, evaluate, review['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." });
}
},
error: function(XMLHttpRequest, textStatus, errorThrown){
Swal.fire({icon:'error',title: "Error",text: "{{no_internet_connection}}" });
}
});
}
}
});
('#clear').click(function(){
clearNet();
});
('#gennet').click(function(){
});
('#load').click(function(){
if(main_idx > -1){
.ajax({
type:"POST",
url:"/loadClipboard",
data: '1',
contentType:"application/json",
dataType: 'json',
success:function (data) {
loadResponceXml3(data);
}
});
} else {
Swal.fire({icon:'error',title: "Error",text: "No topic or test was 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, 3]),
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, 3]),
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 or test was selected."});
}
});
('#savefile').click(function(){
var xml = '
gPhysicsSolver3.0'+id_main+''+id_type+'';
var xml_problem = buildProblemXml(pproblem);
var xml_responce = buildResponceXml3();
saveFile(xml+'@#@#@'+xml_problem+'@#@#@'+xml_responce);
});
('#loadfile').click(function(){
loadFile();
});
('#networkEquation').on("click",function(){
setNetworkEquation(vgraph_network);
});
('#networkNumber').on("click",function(){
setNetworkNumber(vgraph_network);
});
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);
});
});