iassign-integration-functions.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. // Função para ler parâmetros informados pelo iTarefa via URL
  2. // Apesar de não ser obrigatório, será muito útil para capturar os parâmetros
  3. function getParameterByName (name, defaultReturn = null) {
  4. var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
  5. return match ? decodeURIComponent(match[1].replace(/\+/g, ' ')) : defaultReturn;
  6. }
  7. // Criando um object com os parâmetros informados pelo iTarefa
  8. // Observe que para cada parâmetro, é realizada a chamada do método getParameterByName, implementado acima
  9. var iLMparameters = {
  10. iLM_PARAM_ServerToGetAnswerURL: getParameterByName("iLM_PARAM_ServerToGetAnswerURL"),
  11. iLM_PARAM_SendAnswer: getParameterByName("iLM_PARAM_SendAnswer"),
  12. iLM_PARAM_AssignmentURL: getParameterByName("iLM_PARAM_AssignmentURL"),
  13. iLM_PARAM_Assignment: getParameterByName("iLM_PARAM_Assignment"),
  14. iLM_PARAM_TeacherAutoEval: getParameterByName("iLM_PARAM_TeacherAutoEval"),
  15. lang: getParameterByName("lang", "pt")
  16. };
  17. // Set the lang parameter to the localStorage for easy access
  18. // and no dependency to the global scope, avoind future 'strict mode' problems
  19. //localStorage.setItem('ivprog.lang', iLMparameters.lang);
  20. // Função chamada pelo iTarefa quando o professor finaliza a criação da atividade
  21. // ou quando o aluno finaliza a resolução do exercício
  22. // O retorno é um JSON com os dados do exercício ou da resolução
  23. // Esse retorno será armazenado no banco de dados do Moodle, pelo iTarefa
  24. function getAnswer () {
  25. // Se o parâmetro "iLM_PARAM_SendAnswer" for false,
  26. // então trata-se de resolução de atividade
  27. if (iLMparameters.iLM_PARAM_SendAnswer == 'false') {
  28. // Montar o retorno com a resposta do aluno
  29. var contentToSend = previousContent.split("\n::algorithm::")[0];
  30. contentToSend += '\n::algorithm::';
  31. if (settingsProgrammingTypes == "textual") {
  32. contentToSend += ivprogCore.CodeEditor.getCode();
  33. } else {
  34. contentToSend += JSON.stringify(window.program_obj, function(key, value) {
  35. if (key == 'dom_object') {
  36. return;
  37. }
  38. return value;
  39. });
  40. }
  41. contentToSend += '\n::logs::';
  42. contentToSend += getTrackingLogs();
  43. return contentToSend;
  44. } else {
  45. // Montar o retorno com a criação da atividade do professor
  46. var ret = ' { ' + prepareTestCases()
  47. + ',\n"settings_programming_type": \n' + JSON.stringify($('form[name="settings_programming_type"]').serializeArray())
  48. + ',\n"settings_data_types": \n' + JSON.stringify($('form[name="settings_data_types"]').serializeArray())
  49. + ',\n"settings_commands": \n' + JSON.stringify($('form[name="settings_commands"]').serializeArray())
  50. + ',\n"settings_functions": \n' + JSON.stringify($('form[name="settings_functions"]').serializeArray())
  51. + ' } ';
  52. if ($("input[name='include_algo']").is(':checked')) {
  53. ret += '\n::algorithm::';
  54. ret += JSON.stringify(window.program_obj, function(key, value) {
  55. if (key == 'dom_object') {
  56. return;
  57. }
  58. return value;
  59. });
  60. }
  61. return ret;
  62. }
  63. }
  64. function prepareTestCases () {
  65. var ret = ' \n "testcases" : [ '
  66. var test_cases_array = $('form[name="test_cases"]').serializeArray();
  67. console.log(test_cases_array);
  68. for (var i = 0; i < test_cases_array.length; i = i + 2) {
  69. ret += '\n{ ';
  70. ret += '\n "input": [';
  71. var inps = test_cases_array[i].value.match(/[^\r\n]+/g);
  72. if (inps) {
  73. for (var j = 0; j < inps.length; j++) {
  74. ret += '"' + inps[j].trim() + '"';
  75. if ((j + 1) < inps.length) {
  76. ret += ', ';
  77. }
  78. }
  79. }
  80. ret += '], \n "output": [';
  81. var outs = test_cases_array[i+1].value.match(/[^\r\n]+/g);
  82. if (outs) {
  83. for (var j = 0; j < outs.length; j++) {
  84. ret += '"' + outs[j].trim() + '"';
  85. if ((j + 1) < outs.length) {
  86. ret += ', ';
  87. }
  88. }
  89. }
  90. ret += ']';
  91. ret += '\n}'
  92. if ((i + 2) < test_cases_array.length) {
  93. ret += ',';
  94. }
  95. }
  96. ret += '\n] ';
  97. return ret;
  98. }
  99. // Função chamada pelo iTarefa para receber a nota do aluno na atividade
  100. // O retorno é um valor entre 0.0 e 1.0
  101. function getEvaluation () {
  102. if (iLMparameters.iLM_PARAM_SendAnswer == 'false') {
  103. // A chamada do método abaixo é obrigatória!
  104. // Observe que a chamada parte do iLM para o iTarefa
  105. //parent.getEvaluationCallback(window.studentGrade);
  106. runCodeAssessment();
  107. }
  108. }
  109. //var testCases = null
  110. var settingsDataTypes = null;
  111. var settingsCommands = null;
  112. var settingsFunctions = null;
  113. var settingsProgrammingTypes = null;
  114. var algorithm_in_ilm = null;
  115. var previousContent = null;
  116. // Função para que o iMA leia os dados da atividade fornecidos pelo iTarefa
  117. function getiLMContent () {
  118. // O parâmetro "iLM_PARAM_Assignment" fornece o URL do endereço que deve ser
  119. // requisitado via AJAX para a captura dos dados da atividade
  120. $.get(iLMparameters.iLM_PARAM_Assignment, function (data) {
  121. //professor invocou a avaliação automática dos exercícios do bloco
  122. if (iLMparameters.iLM_PARAM_TeacherAutoEval != null) {
  123. teacherAutoEval(data);
  124. //não deve exibir nenhuma interface...
  125. return;
  126. } else if (iLMparameters.iLM_PARAM_SendAnswer == 'false') {
  127. // Aluno está trabalhando em alguma atividade:
  128. previousContent = data;
  129. prepareActivityToStudent(data);
  130. } else { // Professor está editando uma atividade:
  131. previousContent = data;
  132. prepareActivityToEdit(data);
  133. }
  134. window.block_render = false;
  135. renderAlgorithm();
  136. });
  137. }
  138. function prepareActivityToEdit (ilm_cont) {
  139. //var content = JSON.parse(ilm_cont.split('\n::algorithm::')[0]);
  140. // Ver arquivo js/util/iassignHelpers.js
  141. var content = ivprogCore.prepareActivityToStudentHelper(ilm_cont);
  142. var testCases = ivprogCore.getTestCases();
  143. settingsProgrammingTypes = content.settingsProgrammingType;
  144. settingsDataTypes = content.settingsDataTypes;
  145. settingsCommands = content.settingsCommands;
  146. settingsFunctions = content.settingsFunctions;
  147. for (var i = 0; i < testCases.length; i++) {
  148. addTestCase(testCases[i]);
  149. }
  150. if (content.algorithmInIlm != null) {
  151. algorithm_in_ilm = content.algorithmInIlm;
  152. $("input[name='include_algo']").prop('checked', true);
  153. includePreviousAlgorithm();
  154. renderAlgorithm();
  155. }
  156. ivprogTextualOrVisual();
  157. }
  158. function parsePreviousAlgorithm () {
  159. window.program_obj.functions = JSON.parse(algorithm_in_ilm).functions;
  160. window.program_obj.globals = JSON.parse(algorithm_in_ilm).globals;
  161. }
  162. function includePreviousAlgorithm () {
  163. if (settingsProgrammingTypes == "textual") {
  164. return;
  165. }
  166. parsePreviousAlgorithm();
  167. window.watchW.watch(window.program_obj.globals, function(){
  168. if (window.insertContext) {
  169. setTimeout(function(){ renderAlgorithm(); }, 300);
  170. window.insertContext = false;
  171. } else {
  172. renderAlgorithm();
  173. }
  174. }, 1);
  175. for (var i = 0; i < window.program_obj.functions.length; i ++) {
  176. window.watchW.watch(window.program_obj.functions[i].parameters_list, function(){
  177. if (window.insertContext) {
  178. setTimeout(function(){ renderAlgorithm(); }, 300);
  179. window.insertContext = false;
  180. } else {
  181. renderAlgorithm();
  182. }
  183. }, 1);
  184. window.watchW.watch(window.program_obj.functions[i].variables_list, function(){
  185. if (window.insertContext) {
  186. setTimeout(function(){ renderAlgorithm(); }, 300);
  187. window.insertContext = false;
  188. } else {
  189. renderAlgorithm();
  190. }
  191. }, 1);
  192. if (window.program_obj.functions[i].is_main) {
  193. window.program_obj.functions[i].name = LocalizedStrings.getUI("start");
  194. }
  195. }
  196. window.watchW.watch(window.program_obj.functions, function(){
  197. if (window.insertContext) {
  198. setTimeout(function(){ renderAlgorithm(); }, 300);
  199. window.insertContext = false;
  200. } else {
  201. renderAlgorithm();
  202. }
  203. }, 1);
  204. }
  205. function prepareActivityToStudent (ilm_cont) {
  206. // Ver arquivo js/util/iassignHelpers.js
  207. var content = ivprogCore.prepareActivityToStudentHelper(ilm_cont);
  208. // Casos de testes agora são delegados ao tratamento apropriado pela função acima
  209. // var testCases = content.testcases;
  210. settingsProgrammingTypes = content.settingsProgrammingType;
  211. settingsDataTypes = content.settingsDataTypes;
  212. settingsCommands = content.settingsCommands;
  213. settingsFunctions = content.settingsFunctions;
  214. if (content.algorithmInIlm != null) {
  215. algorithm_in_ilm = content.algorithmInIlm;
  216. includePreviousAlgorithm();
  217. }
  218. $('.assessment_button').removeClass('disabled');
  219. renderAlgorithm();
  220. ivprogTextualOrVisual();
  221. }
  222. // Função para organizar se para criação, visualização ou resolução de atividade
  223. function prepareEnvironment () {
  224. $('.div_to_body').click(function(e) {
  225. // trackingMatrix.push(adCoords(e, 1));
  226. ivprogCore.registerClick(e.pageX, e.pageY, e.target.classList['value']);
  227. });
  228. // Se iLM_PARAM_SendAnswer for false, então trata-se de resolução de atividade,
  229. // portanto, a "DIV" de resolução é liberada
  230. if (iLMparameters.iLM_PARAM_SendAnswer == 'false') {
  231. //$('.resolucao').css("display","block");
  232. getiLMContent();
  233. // $('.div_to_body').mousemove(function(e) {
  234. // trackingMatrix.push(adCoords(e, 0));
  235. // });
  236. // $('.div_to_body').click(function(e) {
  237. // // trackingMatrix.push(adCoords(e, 1));
  238. // ivprogCore.registerClick(e.pageX, e.pageY, e.target.classList['value']);
  239. // });
  240. } else if (iLMparameters.iLM_PARAM_Assignment) {
  241. // Caso não esteja em modo de resolução de atividade, a visualização no momento
  242. // é para a elaboração de atividade:
  243. //$('.elaboracao').css("display","block");
  244. // Se possuir o parâmetro iLMparameters.iLM_PARAM_Assignment, o professor
  245. // está editando uma atividade:
  246. getiLMContent();
  247. } else {
  248. renderAlgorithm();
  249. }
  250. if ((iLMparameters.iLM_PARAM_AssignmentURL == "true") && (iLMparameters.iLM_PARAM_SendAnswer == "true")) {
  251. prepareActivityCreation();
  252. }
  253. }
  254. function ivprogTextualOrVisual () {
  255. if (settingsProgrammingTypes) {
  256. if (settingsProgrammingTypes == "textual") {
  257. $('.ivprog_visual_panel').css('display', 'none');
  258. $('.ivprog_textual_panel').css('display', 'block');
  259. $('.ivprog_textual_panel').removeClass('loading');
  260. $('.visual_coding_button').removeClass('active');
  261. $('.textual_coding_button').addClass('active');
  262. $('.visual_coding_button').addClass('disabled');
  263. ivprogCore.CodeEditor.setCode(algorithm_in_ilm);
  264. ivprogCore.CodeEditor.disable(false);
  265. }
  266. if (settingsProgrammingTypes == "visual") {
  267. }
  268. }
  269. }
  270. function iassingIntegration () {
  271. // Disable by default...
  272. $('.assessment_button').addClass('disabled');
  273. prepareEnvironment();
  274. if (inIframe()) {
  275. orderIcons();
  276. orderWidth();
  277. }
  278. }
  279. // Função para preparar a interface para o professor criar atividade:
  280. function prepareActivityCreation () {
  281. $('.add_accordion').addClass('accordion');
  282. $('.default_visual_title').toggle();
  283. $('.default_visual_title').append('<span>'+LocalizedStrings.getUI('text_teacher_algorithm')+'</span>');
  284. $('.height_100').removeClass('height_100');
  285. $('.main_title').remove();
  286. $('.ui.accordion').addClass('styled');
  287. $('<div class="content_margin"></div>').insertBefore($('.add_accordion').find('.content').find('.div_to_body'));
  288. $('<div class="ui checkbox"><input type="checkbox" name="include_algo" class="include_algo" tabindex="0" class="hidden"><label>'+LocalizedStrings.getUI('text_teacher_algorithm_include')+'</label></div>').insertAfter('.content_margin');
  289. var cases_test_div = $('<div class="ui accordion styled"><div class="active title"><i class="dropdown icon"></i>'+LocalizedStrings.getUI('text_teacher_test_case')+'</div><div class="active content"></div></div>');
  290. cases_test_div.insertBefore('.accordion');
  291. var config_div = $('<div class="ui accordion styled"><div class="title"><i class="dropdown icon"></i>'+LocalizedStrings.getUI('text_teacher_config')+'</div><div class="content"></div></div>');
  292. config_div.insertAfter(cases_test_div);
  293. $('.ui.accordion').accordion();
  294. $('.ui.checkbox').checkbox();
  295. prepareTableSettings(config_div.find('.content'));
  296. prepareTableTestCases(cases_test_div.find('.content'));
  297. if (inIframe()) {
  298. $('.ui.styled.accordion').css('width', '96%');
  299. }
  300. }
  301. function prepareTableTestCases (div_el) {
  302. var table_el = '<form name="test_cases"><table class="ui blue table"><thead><tr><th width="30px">#</th><th>'+LocalizedStrings.getUI('text_teacher_test_case_input')+'</th><th>'+LocalizedStrings.getUI('text_teacher_test_case_output')+'</th><th width="80px">'+LocalizedStrings.getUI('text_teacher_test_case_actions')+'</th></tr></thead>'
  303. + '<tbody class="content_cases"></tbody></table></form>';
  304. div_el.append(table_el);
  305. div_el.append('<button class="ui teal labeled icon button button_add_case"><i class="plus icon"></i>'+LocalizedStrings.getUI('text_teacher_test_case_add')+'</button>');
  306. $('.button_add_case').on('click', function(e) {
  307. addTestCase();
  308. });
  309. }
  310. var hist = false;
  311. function addTestCase (test_case = null) {
  312. var new_row = null;
  313. if (test_case) {
  314. var text_row = '';
  315. text_row += '<tr><td class="counter"></td><td class="expandingArea"><textarea rows="'+test_case.input.length+'" name="input" class="text_area_input">';
  316. for (var i = 0; i < test_case.input.length; i ++) {
  317. text_row += test_case.input[i];
  318. if ((i + 1) < test_case.input.length) {
  319. text_row += '\n';
  320. }
  321. }
  322. text_row += '</textarea></td><td class="expandingArea"><textarea rows="'+test_case.output.length+'" name="output" class="text_area_output">';
  323. for (var i = 0; i < test_case.output.length; i ++) {
  324. text_row += test_case.output[i];
  325. if ((i + 1) < test_case.output.length) {
  326. text_row += '\n';
  327. }
  328. }
  329. text_row += '</textarea></td><td class="btn_actions"><div class="ui button_remove_case"><i class="red icon times large"></i></div></td></tr>';
  330. new_row = $(text_row);
  331. } else {
  332. new_row = $('<tr><td class="counter"></td><td class="expandingArea"><textarea rows="1" name="input" class="text_area_input"></textarea></td><td class="expandingArea"><textarea rows="1" name="output" class="text_area_output"></textarea></td><td class="btn_actions"><div class="ui button_remove_case"><i class="red icon times large"></i></div></td></tr>');
  333. }
  334. $('.content_cases').append(new_row);
  335. new_row.find('.button_remove_case').click(function(e) {
  336. new_row.remove();
  337. updateTestCaseCounter();
  338. });
  339. new_row.find('textarea').on('input', function(e) {
  340. var lines = $(this).val().split('\n').length;
  341. $(this).attr('rows', lines);
  342. });
  343. updateTestCaseCounter();
  344. $('.text_area_output').keydown(function(e) {
  345. var code = e.keyCode || e.which;
  346. if (code == 9 && $(this).closest("tr").is(":last-child")) {
  347. hist = true;
  348. addTestCase();
  349. }
  350. });
  351. if (test_case == null) {
  352. if (!hist) {
  353. $( ".content_cases tr:last" ).find('.text_area_input').focus();
  354. } else {
  355. hist = false;
  356. }
  357. }
  358. }
  359. function updateTestCaseCounter () {
  360. var i = 1;
  361. $( ".content_cases" ).find('tr').each(function() {
  362. $( this ).find('.counter').text(i);
  363. ++i;
  364. });
  365. }
  366. function prepareTableSettings (div_el) {
  367. div_el.append('<h4 class="ui header">'+LocalizedStrings.getUI('text_config_programming')+'</h4>');
  368. div_el.append('<form name="settings_programming_type"><div class="ui stackable five column grid">'
  369. +'<div class="column"><div class="ui radio"><input type="radio" name="programming_type" id="programming_textual" value="textual" tabindex="0" class="hidden small"><label for="programming_textual">'+LocalizedStrings.getUI('text_config_programming_textual')+'</label></div></div>'
  370. +'<div class="column"><div class="ui radio"><input type="radio" name="programming_type" id="programming_visual" value="visual" checked tabindex="0" class="hidden small"><label for="programming_visual">'+LocalizedStrings.getUI('text_config_programming_visual')+'</label></div></div>'
  371. +'</div></form>');
  372. div_el.append('<h4 class="ui header">'+LocalizedStrings.getUI('text_teacher_data_types')+'</h4>');
  373. div_el.append('<form name="settings_data_types"><div class="ui stackable five column grid">'
  374. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="integer_data_type" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('integer')+'</label></div></div>'
  375. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="real_data_type" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('real')+'</label></div></div>'
  376. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="text_data_type" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text')+'</label></div></div>'
  377. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="boolean_data_type" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('boolean')+'</label></div></div>'
  378. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="void_data_type" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('void')+'</label></div></div>'
  379. +'</div></form>');
  380. div_el.append('<h4 class="ui header">'+LocalizedStrings.getUI('text_teacher_commands')+'</h4>');
  381. div_el.append('<form name="settings_commands"><div class="ui stackable three column grid">'
  382. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="commands_read" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_read_var')+'</label></div></div>'
  383. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="commands_write" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_write_var')+'</label></div></div>'
  384. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="commands_comment" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_comment')+'</label></div></div>'
  385. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="commands_attribution" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_attribution')+'</label></div></div>'
  386. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="commands_functioncall" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_functioncall')+'</label></div></div>'
  387. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="commands_iftrue" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_iftrue')+'</label></div></div>'
  388. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="commands_repeatNtimes" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_repeatNtimes')+'</label></div></div>'
  389. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="commands_while" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_whiletrue')+'</label></div></div>'
  390. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="commands_dowhile" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_dowhiletrue')+'</label></div></div>'
  391. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="commands_switch" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_switch')+'</label></div></div>'
  392. +'</div></form>');
  393. div_el.append('<h4 class="ui header">'+LocalizedStrings.getUI('text_teacher_functions')+'</h4>');
  394. div_el.append('<form name="settings_functions"><div class="ui stackable one column grid">'
  395. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="functions_creation" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_teacher_create_functions')+'</label></div></div>'
  396. +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="functions_move" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('text_teacher_create_movement_functions')+'</label></div></div>'
  397. +'</div></form>');
  398. $('.ui.checkbox').checkbox();
  399. }
  400. function getTrackingLogs () {
  401. return ivprogCore.getLogsAsString();
  402. // var ret = "";
  403. // for (var i = 0; i < trackingMatrix.length; ++i) {
  404. // ret += "\n" + trackingMatrix[i][0] + "," + trackingMatrix[i][1] + "," + trackingMatrix[i][2];
  405. // if (trackingMatrix[i][3] === 1) {
  406. // ret += ',' + trackingMatrix[i][3] + ',"' + trackingMatrix[i][4] + '"';
  407. // }
  408. // }
  409. // return ret;
  410. }
  411. // Tracking mouse movements
  412. // var trackingMatrix = [];
  413. /* function adCoords(e, code){
  414. var x = e.pageX;
  415. var y = e.pageY;
  416. if (code === 1) {
  417. return [new Date().getTime(), x, y, code, e.target.classList['value']];
  418. } else {
  419. return [x, y, code];
  420. }
  421. } */
  422. // $( document ).ready(function() {
  423. // if (inIframe()) {
  424. // orderIcons();
  425. // orderWidth();
  426. // }
  427. // renderAlgorithm();
  428. // });
  429. function orderWidth() {
  430. $('.ui.raised.container.segment.div_to_body').css('width', '100%');
  431. $('.ui.one.column.container.segment.ivprog_visual_panel').css('width', '100%');
  432. }
  433. function orderIcons() {
  434. $('.ui.one.column.doubling.stackable.grid.container').css('display', 'none');
  435. $('.only_in_frame').css('display', 'block');
  436. }
  437. function inIframe () {
  438. try {
  439. return window.self !== window.top;
  440. } catch (e) {
  441. return true;
  442. }
  443. }
  444. function full_screen() {
  445. // check if user allows full screen of elements. This can be enabled or disabled in browser config. By default its enabled.
  446. //its also used to check if browser supports full screen api.
  447. if("fullscreenEnabled" in document || "webkitFullscreenEnabled" in document || "mozFullScreenEnabled" in document || "msFullscreenEnabled" in document) {
  448. if(document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled) {
  449. var element = document.getElementById("ui_main_div");
  450. //requestFullscreen is used to display an element in full screen mode.
  451. if("requestFullscreen" in element) {
  452. element.requestFullscreen();
  453. }
  454. else if ("webkitRequestFullscreen" in element) {
  455. element.webkitRequestFullscreen();
  456. }
  457. else if ("mozRequestFullScreen" in element) {
  458. element.mozRequestFullScreen();
  459. }
  460. else if ("msRequestFullscreen" in element) {
  461. element.msRequestFullscreen();
  462. }
  463. }
  464. } else {
  465. $('.expand_button').addClass('disabled');
  466. }
  467. }
  468. function teacherAutoEval (data) {
  469. $.get(iLMparameters.iLM_PARAM_TeacherAutoEval, function (originalData) {
  470. // Ver arquivo js/util/iassignHelpers.js
  471. var content = ivprogCore.prepareActivityToStudentHelper(data);
  472. // Casos de testes agora são delegados ao tratamento apropriado pela função acima
  473. // var testCases = content.testcases;
  474. settingsProgrammingTypes = content.settingsProgrammingType;
  475. settingsDataTypes = content.settingsDataTypes;
  476. settingsCommands = content.settingsCommands;
  477. settingsFunctions = content.settingsFunctions;
  478. if (content.algorithmInIlm != null) {
  479. algorithm_in_ilm = content.algorithmInIlm;
  480. parsePreviousAlgorithm();
  481. ivprogCore.autoEval(originalData, parent.getEvaluationCallback);
  482. }
  483. ivprogTextualOrVisual();
  484. });
  485. }