iassign-integration-functions.js 23 KB

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