|
@@ -30,7 +30,12 @@ function getAnswer () {
|
|
|
// Montar o retorno com a resposta do aluno
|
|
|
var contentToSend = previousContent.split("\n::algorithm::")[0];
|
|
|
contentToSend += '\n::algorithm::\n';
|
|
|
- contentToSend += JSON.stringify(window.program_obj);
|
|
|
+ contentToSend += JSON.stringify(window.program_obj, function(key, value) {
|
|
|
+ if (key == 'dom_object') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ });
|
|
|
|
|
|
contentToSend += '\n::logs::';
|
|
|
contentToSend += getTrackingLogs();
|
|
@@ -47,10 +52,17 @@ function getAnswer () {
|
|
|
|
|
|
if ($("input[name='include_algo']").is(':checked')) {
|
|
|
ret += '\n::algorithm::\n';
|
|
|
- ret += JSON.stringify(window.program_obj);
|
|
|
+ ret += JSON.stringify(window.program_obj, function(key, value) {
|
|
|
+
|
|
|
+ if (key == 'dom_object') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
return ret;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -115,27 +127,54 @@ function getiLMContent () {
|
|
|
// O parâmetro "iLM_PARAM_Assignment" fornece o URL do endereço que deve ser
|
|
|
// requisitado via AJAX para a captura dos dados da atividade
|
|
|
$.get(iLMparameters.iLM_PARAM_Assignment, function (data) {
|
|
|
+ // Aluno está trabalhando em alguma atividade:
|
|
|
if (iLMparameters.iLM_PARAM_SendAnswer == 'false') {
|
|
|
previousContent = data;
|
|
|
prepareActivityToStudent(data);
|
|
|
- } else {
|
|
|
-
|
|
|
+ } else { // Professor está editando uma atividade:
|
|
|
+ previousContent = data;
|
|
|
+ prepareActivityToEdit(data);
|
|
|
}
|
|
|
+
|
|
|
+ window.block_render = false;
|
|
|
+ renderAlgorithm();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function prepareActivityToStudent (ilm_cont) {
|
|
|
+function prepareActivityToEdit (ilm_cont) {
|
|
|
var content = JSON.parse(ilm_cont.split('\n::algorithm::')[0]);
|
|
|
testCases = content.testcases;
|
|
|
settingsDataTypes = content.settings_data_types;
|
|
|
settingsCommands = content.settings_commands;
|
|
|
settingsFunctions = content.settings_functions;
|
|
|
+
|
|
|
+ for (var i = 0; i < testCases.length; i++) {
|
|
|
+ addTestCase(testCases[i]);
|
|
|
+ }
|
|
|
+
|
|
|
if (ilm_cont.split('\n::algorithm::')[1]) {
|
|
|
algorithm_in_ilm = ilm_cont.split('\n::algorithm::')[1].split('\n::logs::')[0];
|
|
|
- window.program_obj.functions = JSON.parse(algorithm_in_ilm).functions;
|
|
|
- window.program_obj.globals = JSON.parse(algorithm_in_ilm).globals;
|
|
|
+ $("input[name='include_algo']").prop('checked', true);
|
|
|
+ includePreviousAlgorithm();
|
|
|
+ renderAlgorithm();
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- window.watchW.watch(window.program_obj.globals, function(){
|
|
|
+function includePreviousAlgorithm () {
|
|
|
+ window.program_obj.functions = JSON.parse(algorithm_in_ilm).functions;
|
|
|
+ window.program_obj.globals = JSON.parse(algorithm_in_ilm).globals;
|
|
|
+
|
|
|
+ window.watchW.watch(window.program_obj.globals, function(){
|
|
|
+ if (window.insertContext) {
|
|
|
+ setTimeout(function(){ renderAlgorithm(); }, 300);
|
|
|
+ window.insertContext = false;
|
|
|
+ } else {
|
|
|
+ renderAlgorithm();
|
|
|
+ }
|
|
|
+ }, 1);
|
|
|
+
|
|
|
+ for (var i = 0; i < window.program_obj.functions.length; i ++) {
|
|
|
+ window.watchW.watch(window.program_obj.functions[i].parameters_list, function(){
|
|
|
if (window.insertContext) {
|
|
|
setTimeout(function(){ renderAlgorithm(); }, 300);
|
|
|
window.insertContext = false;
|
|
@@ -144,26 +183,7 @@ function prepareActivityToStudent (ilm_cont) {
|
|
|
}
|
|
|
}, 1);
|
|
|
|
|
|
- for (var i = 0; i < window.program_obj.functions.length; i ++) {
|
|
|
- window.watchW.watch(window.program_obj.functions[i].parameters_list, function(){
|
|
|
- if (window.insertContext) {
|
|
|
- setTimeout(function(){ renderAlgorithm(); }, 300);
|
|
|
- window.insertContext = false;
|
|
|
- } else {
|
|
|
- renderAlgorithm();
|
|
|
- }
|
|
|
- }, 1);
|
|
|
-
|
|
|
- window.watchW.watch(window.program_obj.functions[i].variables_list, function(){
|
|
|
- if (window.insertContext) {
|
|
|
- setTimeout(function(){ renderAlgorithm(); }, 300);
|
|
|
- window.insertContext = false;
|
|
|
- } else {
|
|
|
- renderAlgorithm();
|
|
|
- }
|
|
|
- }, 1);
|
|
|
- }
|
|
|
- window.watchW.watch(window.program_obj.functions, function(){
|
|
|
+ window.watchW.watch(window.program_obj.functions[i].variables_list, function(){
|
|
|
if (window.insertContext) {
|
|
|
setTimeout(function(){ renderAlgorithm(); }, 300);
|
|
|
window.insertContext = false;
|
|
@@ -171,6 +191,31 @@ function prepareActivityToStudent (ilm_cont) {
|
|
|
renderAlgorithm();
|
|
|
}
|
|
|
}, 1);
|
|
|
+
|
|
|
+ if (window.program_obj.functions[i].is_main) {
|
|
|
+ window.program_obj.functions[i].name = LocalizedStrings.getUI("start");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ window.watchW.watch(window.program_obj.functions, function(){
|
|
|
+ if (window.insertContext) {
|
|
|
+ setTimeout(function(){ renderAlgorithm(); }, 300);
|
|
|
+ window.insertContext = false;
|
|
|
+ } else {
|
|
|
+ renderAlgorithm();
|
|
|
+ }
|
|
|
+ }, 1);
|
|
|
+}
|
|
|
+
|
|
|
+function prepareActivityToStudent (ilm_cont) {
|
|
|
+ var content = JSON.parse(ilm_cont.split('\n::algorithm::')[0]);
|
|
|
+ testCases = content.testcases;
|
|
|
+ settingsDataTypes = content.settings_data_types;
|
|
|
+ settingsCommands = content.settings_commands;
|
|
|
+ settingsFunctions = content.settings_functions;
|
|
|
+
|
|
|
+ if (ilm_cont.split('\n::algorithm::')[1]) {
|
|
|
+ algorithm_in_ilm = ilm_cont.split('\n::algorithm::')[1].split('\n::logs::')[0];
|
|
|
+ includePreviousAlgorithm();
|
|
|
}
|
|
|
$('.assessment_button').removeClass('disabled');
|
|
|
renderAlgorithm();
|
|
@@ -207,6 +252,12 @@ $(document).ready(function() {
|
|
|
// Caso não esteja em modo de resolução de atividade, a visualização no momento
|
|
|
// é para a elaboração de atividade:
|
|
|
//$('.elaboracao').css("display","block");
|
|
|
+
|
|
|
+ // Se possuir o parâmetro iLMparameters.iLM_PARAM_Assignment, o professor
|
|
|
+ // está editando uma atividade:
|
|
|
+ if (iLMparameters.iLM_PARAM_Assignment) {
|
|
|
+ getiLMContent();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!testCases) {
|
|
@@ -226,7 +277,9 @@ function prepareActivityCreation () {
|
|
|
$('.main_title').remove();
|
|
|
$('.ui.accordion').addClass('styled');
|
|
|
|
|
|
- $('<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>').insertBefore('.content_margin');
|
|
|
+ $('<div class="content_margin"></div>').insertBefore($('.add_accordion').find('.content').find('.div_to_body'));
|
|
|
+
|
|
|
+ $('<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');
|
|
|
|
|
|
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>');
|
|
|
|
|
@@ -243,6 +296,10 @@ function prepareActivityCreation () {
|
|
|
prepareTableSettings(config_div.find('.content'));
|
|
|
|
|
|
prepareTableTestCases(cases_test_div.find('.content'));
|
|
|
+
|
|
|
+ if (inIframe()) {
|
|
|
+ $('.ui.styled.accordion').css('width', '96%');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function prepareTableTestCases (div_el) {
|
|
@@ -257,13 +314,39 @@ function prepareTableTestCases (div_el) {
|
|
|
$('.button_add_case').on('click', function(e) {
|
|
|
addTestCase();
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
|
|
|
var hist = false;
|
|
|
|
|
|
-function addTestCase () {
|
|
|
- var 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>');
|
|
|
+function addTestCase (test_case = null) {
|
|
|
+ var new_row = null;
|
|
|
+ if (test_case) {
|
|
|
+ var text_row = '';
|
|
|
+
|
|
|
+ text_row += '<tr><td class="counter"></td><td class="expandingArea"><textarea rows="'+test_case.input.length+'" name="input" class="text_area_input">';
|
|
|
+
|
|
|
+ for (var i = 0; i < test_case.input.length; i ++) {
|
|
|
+ text_row += test_case.input[i];
|
|
|
+ if ((i + 1) < test_case.input.length) {
|
|
|
+ text_row += '\n';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ text_row += '</textarea></td><td class="expandingArea"><textarea rows="'+test_case.output.length+'" name="output" class="text_area_output">';
|
|
|
+
|
|
|
+ for (var i = 0; i < test_case.output.length; i ++) {
|
|
|
+ text_row += test_case.output[i];
|
|
|
+ if ((i + 1) < test_case.output.length) {
|
|
|
+ text_row += '\n';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ text_row += '</textarea></td><td class="btn_actions"><div class="ui button_remove_case"><i class="red icon times large"></i></div></td></tr>';
|
|
|
+
|
|
|
+ new_row = $(text_row);
|
|
|
+ } else {
|
|
|
+ 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>');
|
|
|
+ }
|
|
|
$('.content_cases').append(new_row);
|
|
|
|
|
|
new_row.find('.button_remove_case').click(function(e) {
|
|
@@ -271,7 +354,7 @@ function addTestCase () {
|
|
|
updateTestCaseCounter();
|
|
|
});
|
|
|
|
|
|
- $('textarea').on('input', function(e) {
|
|
|
+ new_row.find('textarea').on('input', function(e) {
|
|
|
var lines = $(this).val().split('\n').length;
|
|
|
$(this).attr('rows', lines);
|
|
|
});
|
|
@@ -285,10 +368,12 @@ function addTestCase () {
|
|
|
addTestCase();
|
|
|
}
|
|
|
});
|
|
|
- if (!hist) {
|
|
|
- $( ".content_cases tr:last" ).find('.text_area_input').focus();
|
|
|
- } else {
|
|
|
- hist = false;
|
|
|
+ if (test_case == null) {
|
|
|
+ if (!hist) {
|
|
|
+ $( ".content_cases tr:last" ).find('.text_area_input').focus();
|
|
|
+ } else {
|
|
|
+ hist = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -340,8 +425,8 @@ function getTrackingLogs () {
|
|
|
var ret = "";
|
|
|
for (var i = 0; i < trackingMatrix.length; i++) {
|
|
|
ret += "\n" + trackingMatrix[i][0] + "," + trackingMatrix[i][1] + "," + trackingMatrix[i][2];
|
|
|
- if (trackingMatrix[i][2] === 1) {
|
|
|
- ret += ',"' + trackingMatrix[i][3] + '"';
|
|
|
+ if (trackingMatrix[i][3] === 1) {
|
|
|
+ ret += ',' + trackingMatrix[i][3] + ',"' + trackingMatrix[i][4] + '"';
|
|
|
}
|
|
|
}
|
|
|
return ret;
|
|
@@ -354,7 +439,7 @@ function adCoords(e, code){
|
|
|
var x = e.pageX;
|
|
|
var y = e.pageY;
|
|
|
if (code === 1) {
|
|
|
- return [x, y, code, e.target.classList['value']];
|
|
|
+ return [new Date().getTime(), x, y, code, e.target.classList['value']];
|
|
|
} else {
|
|
|
return [x, y, code];
|
|
|
}
|
|
@@ -364,14 +449,19 @@ $( document ).ready(function() {
|
|
|
|
|
|
if (inIframe()) {
|
|
|
orderIcons();
|
|
|
+ orderWidth();
|
|
|
}
|
|
|
-
|
|
|
+ renderAlgorithm();
|
|
|
});
|
|
|
|
|
|
+function orderWidth() {
|
|
|
+ $('.ui.raised.container.segment.div_to_body').css('width', '100%');
|
|
|
+ $('.ui.one.column.container.segment.ivprog_visual_panel').css('width', '100%');
|
|
|
+}
|
|
|
+
|
|
|
function orderIcons() {
|
|
|
$('.ui.one.column.doubling.stackable.grid.container').css('display', 'none');
|
|
|
$('.only_in_frame').css('display', 'block');
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -385,7 +475,7 @@ function inIframe () {
|
|
|
|
|
|
|
|
|
function full_screen() {
|
|
|
- // check if user allows full screen of elements. This can be enabled or disabled in browser config. By default its enabled.
|
|
|
+ // check if user allows full screen of elements. This can be enabled or disabled in browser config. By default its enabled.
|
|
|
//its also used to check if browser supports full screen api.
|
|
|
if("fullscreenEnabled" in document || "webkitFullscreenEnabled" in document || "mozFullScreenEnabled" in document || "msFullscreenEnabled" in document) {
|
|
|
if(document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled) {
|