Browse Source

Finished textual coding editor

Igor 5 years ago
parent
commit
6a00ef526e
2 changed files with 21 additions and 14 deletions
  1. 21 8
      js/iassign-integration-functions.js
  2. 0 6
      js/visualUI/functions.js

+ 21 - 8
js/iassign-integration-functions.js

@@ -30,13 +30,18 @@ function getAnswer () {
   if (iLMparameters.iLM_PARAM_SendAnswer == 'false') {
     // 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, function(key, value) {
-      if (key == 'dom_object') {
-          return;
-      }
-      return value; 
-    });
+    contentToSend += '\n::algorithm::';
+
+    if (settingsProgrammingTypes == "textual") {
+      contentToSend +=  ivprogCore.CodeEditor.getCode();
+    } else {
+      contentToSend += JSON.stringify(window.program_obj, function(key, value) {
+        if (key == 'dom_object') {
+            return;
+        }
+        return value; 
+      });
+    }
 
     contentToSend += '\n::logs::';
     contentToSend += getTrackingLogs();
@@ -53,7 +58,7 @@ function getAnswer () {
         + ' } ';
 
     if ($("input[name='include_algo']").is(':checked')) {
-      ret += '\n::algorithm::\n';
+      ret += '\n::algorithm::';
       ret += JSON.stringify(window.program_obj, function(key, value) {
           
           if (key == 'dom_object') {
@@ -179,6 +184,10 @@ function parsePreviousAlgorithm () {
 }
 
 function includePreviousAlgorithm () {
+  if (settingsProgrammingTypes == "textual") {
+    return;
+  }
+
   parsePreviousAlgorithm();
 
   window.watchW.watch(window.program_obj.globals, function(){
@@ -284,6 +293,7 @@ function prepareEnvironment () {
 }
 
 function ivprogTextualOrVisual () {
+
   if (settingsProgrammingTypes) {
     if (settingsProgrammingTypes == "textual") {
       $('.ivprog_visual_panel').css('display', 'none'); 
@@ -293,6 +303,9 @@ function ivprogTextualOrVisual () {
       $('.visual_coding_button').removeClass('active');
       $('.textual_coding_button').addClass('active'); 
       $('.visual_coding_button').addClass('disabled');
+
+      ivprogCore.CodeEditor.setCode(algorithm_in_ilm);
+      ivprogCore.CodeEditor.disable(false);
     }
     if (settingsProgrammingTypes == "visual") {
       

+ 0 - 6
js/visualUI/functions.js

@@ -478,8 +478,6 @@ function updateProgramObjDrag () {
     }
   });
 
-  console.log(function_index);
-
   const path_target = [];
   $(evento_drag.item).parentsUntil(".all_functions").each(function () {
     if ($(this).hasClass('command_container')) {
@@ -857,10 +855,6 @@ export function initVisualUI () {
   });
 
   TextEditor.initTextEditor("ivprog-text-editor");
-  if (settingsProgrammingTypes == "textual") {
-    TextEditor.disable(false);
-  }
-  
 }
 
 export function setTestCases (testCases) {