Browse Source

Merge branch 'fix-whitespace-bug' of LInE/ivprog into master

Lucas de Souza 5 years ago
parent
commit
354114c205
2 changed files with 56 additions and 53 deletions
  1. 53 50
      js/iassign-integration-functions.js
  2. 3 3
      js/util/outputTest.js

+ 53 - 50
js/iassign-integration-functions.js

@@ -39,7 +39,7 @@ function getAnswer () {
         if (key == 'dom_object') {
             return;
         }
-        return value; 
+        return value;
       });
     }
 
@@ -51,21 +51,21 @@ function getAnswer () {
   } else {
     // Montar o retorno com a criação da atividade do professor
     var ret = ' { ' + prepareTestCases()
-        + ',\n"settings_programming_type": \n' + JSON.stringify($('form[name="settings_programming_type"]').serializeArray()) 
-        + ',\n"settings_data_types": \n' + JSON.stringify($('form[name="settings_data_types"]').serializeArray()) 
-        + ',\n"settings_commands": \n' + JSON.stringify($('form[name="settings_commands"]').serializeArray()) 
-        + ',\n"settings_functions": \n' + JSON.stringify($('form[name="settings_functions"]').serializeArray()) 
-        + ',\n"settings_filter": \n' + JSON.stringify($('form[name="settings_filter"]').serializeArray()) 
+        + ',\n"settings_programming_type": \n' + JSON.stringify($('form[name="settings_programming_type"]').serializeArray())
+        + ',\n"settings_data_types": \n' + JSON.stringify($('form[name="settings_data_types"]').serializeArray())
+        + ',\n"settings_commands": \n' + JSON.stringify($('form[name="settings_commands"]').serializeArray())
+        + ',\n"settings_functions": \n' + JSON.stringify($('form[name="settings_functions"]').serializeArray())
+        + ',\n"settings_filter": \n' + JSON.stringify($('form[name="settings_filter"]').serializeArray())
         + ' } ';
 
     if ($("input[name='include_algo']").is(':checked')) {
       ret += '\n::algorithm::';
       ret += JSON.stringify(window.program_obj, function(key, value) {
-          
+
           if (key == 'dom_object') {
               return;
           }
-          return value; 
+          return value;
       });
     }
 
@@ -83,7 +83,7 @@ function prepareTestCases () {
     var inps = test_cases_array[i].value.match(/[^\r\n]+/g);
     if (inps) {
       for (var j = 0; j < inps.length; j++) {
-        ret += '"' + inps[j].trim() + '"';
+        ret += '"' + inps[j] + '"';
         if ((j + 1) < inps.length) {
           ret += ', ';
         }
@@ -91,9 +91,11 @@ function prepareTestCases () {
     }
     ret += '], \n "output": [';
     var outs = test_cases_array[i+1].value.match(/[^\r\n]+/g);
+    console.log(outs);
     if (outs) {
       for (var j = 0; j < outs.length; j++) {
-        ret += '"' + outs[j].trim() + '"';
+        console.log("output -> ",outs[j]);
+        ret += '"' + outs[j] + '"';
         if ((j + 1) < outs.length) {
           ret += ', ';
         }
@@ -321,49 +323,49 @@ function blockAllEditingOptions () {
 
   $('.add_global_button').addClass('disabled');
   $('.move_function').addClass('disabled');
-  $('.add_function_button').addClass('disabled'); 
+  $('.add_function_button').addClass('disabled');
   $('.add_var_button_function .ui.icon.button.purple').addClass('disabled');
   $('.add_var_button_function').addClass('disabled');
   $('.menu_commands').addClass('disabled');
-  
+
   $('.global_type').addClass('disabled');
   $('.editing_name_var').addClass('disabled');
   $('.span_value_variable').addClass('disabled');
 
-  $('.remove_global').addClass('disabled'); 
+  $('.remove_global').addClass('disabled');
   $('.ui.icon.ellipsis.vertical.inverted').addClass('disabled');
 
-  $('.alternate_constant').addClass('disabled'); 
-  $('.remove_variable').addClass('disabled'); 
-  
-  $('.add_global_matrix_column').addClass('disabled'); 
-  $('.remove_global_matrix_column').addClass('disabled'); 
-  
-  $('.add_global_matrix_line').addClass('disabled'); 
-  $('.remove_global_matrix_line').addClass('disabled'); 
+  $('.alternate_constant').addClass('disabled');
+  $('.remove_variable').addClass('disabled');
+
+  $('.add_global_matrix_column').addClass('disabled');
+  $('.remove_global_matrix_column').addClass('disabled');
 
-  $('.add_global_vector_column').addClass('disabled'); 
-  $('.remove_global_vector_column').addClass('disabled'); 
+  $('.add_global_matrix_line').addClass('disabled');
+  $('.remove_global_matrix_line').addClass('disabled');
 
-  $('.add_expression').addClass('disabled'); 
-  $('.add_parentheses').addClass('disabled'); 
+  $('.add_global_vector_column').addClass('disabled');
+  $('.remove_global_vector_column').addClass('disabled');
 
-  $('.remove_function_button').addClass('disabled'); 
-  $('.button_remove_command').addClass('disabled'); 
+  $('.add_expression').addClass('disabled');
+  $('.add_parentheses').addClass('disabled');
 
-  $('.command_drag').addClass('disabled'); 
-  $('.simple_add').addClass('disabled'); 
+  $('.remove_function_button').addClass('disabled');
+  $('.button_remove_command').addClass('disabled');
 
-  $('.add_parameter_button').addClass('disabled'); 
+  $('.command_drag').addClass('disabled');
+  $('.simple_add').addClass('disabled');
+
+  $('.add_parameter_button').addClass('disabled');
   $('.parameter_div_edit').addClass('disabled');
   $('.function_name_div_updated').addClass('disabled');
   $('.value_rendered').addClass('disabled');
   $('.var_name').addClass('disabled');
   $('.variable_rendered').addClass('disabled');
-  
-  $('.dropdown').addClass('disabled'); 
+
+  $('.dropdown').addClass('disabled');
   $('.remove_parameter').addClass('disabled');
-  
+
   $('.ui.dropdown.global_type.disabled').css('opacity', '1');
   $('.ui.dropdown.variable_type.disabled').css('opacity', '1');
   $('.ui.dropdown.function_return.disabled').css('opacity', '1');
@@ -377,12 +379,12 @@ function ivprogTextualOrVisual () {
 
   if (settingsProgrammingTypes) {
     if (settingsProgrammingTypes == "textual") {
-      $('.ivprog_visual_panel').css('display', 'none'); 
+      $('.ivprog_visual_panel').css('display', 'none');
       $('.ivprog_textual_panel').css('display', 'block');
       $('.ivprog_textual_panel').removeClass('loading');
 
       $('.visual_coding_button').removeClass('active');
-      $('.textual_coding_button').addClass('active'); 
+      $('.textual_coding_button').addClass('active');
       $('.visual_coding_button').addClass('disabled');
 
       let textual_code = algorithm_in_ilm;
@@ -396,7 +398,7 @@ function ivprogTextualOrVisual () {
       ivprogCore.CodeEditor.disable(false);
     }
     if (settingsProgrammingTypes == "visual") {
-      
+
     }
   }
 }
@@ -427,14 +429,14 @@ function prepareActivityCreation () {
 
   menuTab.insertBefore('.add_accordion');
   $('.tabular.menu .item').tab();
-  
+
   $('.main_title').remove();
   $('.ui.accordion').addClass('styled');
-  
+
   $('<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></div>');
 
   $('.tab_test_cases').append(cases_test_div);
@@ -498,7 +500,7 @@ function generateOutputs () {
   ivprogCore.autoGenerateTestCaseOutput(code_teacher, test_cases).catch(function (error) {
     showAlert("Houve um erro durante a execução do seu programa: "+error.message);
   });
-  
+
 }
 
 function outputGenerated (test_cases) {
@@ -515,13 +517,14 @@ function outputGenerated (test_cases) {
   }*/
   animateOutput(fields, test_cases, 0);
 
-  
+
 }
 
 function animateOutput (list, test_cases, index) {
   if (list.length == index) return;
   $(list[index]).val('');
   for (var j = 0; j < test_cases[index].output.length; j++) {
+    console.log(test_cases[index].output[j].charCodeAt(0));
     $(list[index]).val($(list[index]).val() + test_cases[index].output[j]);
     if (j < test_cases[index].output.length - 1) {
       $(list[index]).val($(list[index]).val() + '\n');
@@ -549,7 +552,7 @@ function addTestCase (test_case = null) {
         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 ++) {
@@ -576,7 +579,7 @@ function addTestCase (test_case = null) {
       var lines = $(this).val().split('\n').length;
       $(this).attr('rows', lines);
   });
-  
+
   updateTestCaseCounter();
 
   $('.text_area_output').keydown(function(e) {
@@ -674,7 +677,7 @@ function getTrackingLogs () {
 // var trackingMatrix = [];
 
 /* function adCoords(e, code){
-  var x = e.pageX; 
+  var x = e.pageX;
   var y = e.pageY;
   if (code === 1) {
     return [new Date().getTime(), x, y, code, e.target.classList['value']];
@@ -721,13 +724,13 @@ function full_screen() {
       //requestFullscreen is used to display an element in full screen mode.
       if("requestFullscreen" in element) {
         element.requestFullscreen();
-      } 
+      }
       else if ("webkitRequestFullscreen" in element) {
         element.webkitRequestFullscreen();
-      } 
+      }
       else if ("mozRequestFullScreen" in element) {
         element.mozRequestFullScreen();
-      } 
+      }
       else if ("msRequestFullscreen" in element) {
         element.msRequestFullscreen();
       }
@@ -748,7 +751,7 @@ function teacherAutoEval (data) {
     }
     // Casos de testes agora são delegados ao tratamento apropriado pela função acima
     // var testCases = content.testcases;
-    settingsProgrammingTypes = content.settingsProgrammingType; 
+    settingsProgrammingTypes = content.settingsProgrammingType;
     settingsDataTypes = content.settingsDataTypes;
     settingsCommands = content.settingsCommands;
     settingsFunctions = content.settingsFunctions;
@@ -762,7 +765,7 @@ function teacherAutoEval (data) {
 
     ivprogTextualOrVisual();
     if (settingsFilter && settingsFilter[0]) {
-      
+
       blockAllEditingOptions();
     }
   });
@@ -781,4 +784,4 @@ function showInvalidData () {
   $('.dimmer_content_message').css('display', 'block');
   $('.ui.height_100.add_accordion').dimmer('add content', '.dimmer_content_message');
   $('.ui.height_100.add_accordion').dimmer('show');
-}
+}

+ 3 - 3
js/util/outputTest.js

@@ -11,9 +11,9 @@ export class OutputTest extends Output {
     const output = ''+text;
     output.split("\n").forEach(t => {
       t = t.replace(/\t/g,'  ');
-      t = t.replace(/\s/g," ");
+      t = t.replace(/\s/g,"\u0020");
       this.list.push(t);
     },this);
-    
+
   }
-}
+}