Browse Source

Update 'js/util/codeParser.js'

To allow try load by 3 formats (old one, new template e Portugol).
Now function parserCodeVisual(code_obj = null) return null when code_obj is null. With null ""js/util/codeParser.js!parserCodeVisual(.)" signalizes to "js/iassign-integration-functions.js" that the current format is not working, try another.
leo 2 months ago
parent
commit
e01389ce5e
1 changed files with 18 additions and 2 deletions
  1. 18 2
      js/util/codeParser.js

+ 18 - 2
js/util/codeParser.js

@@ -108,9 +108,19 @@ function printCommandText (code) {
 // @calledby Recursive, "parserCodeVisual(.)": preparedFunction.commands = parseCommands(rawFunction.commands, preparedFunction);
 // @calledby Generic parser, "parseCommands(.)": temp.push(parseCommands(command, function_obj));
 // @calledby Each parser command as "function parseIfTrue(command,function_obj)": "ifTrueBlock=parseCommands(command.ifTrue,function_obj)" and "ifFalseBlock=parseCommands(command.ifFalse,function_obj)"
+// Sequence calls: 
+//   parserCodeVisual here
+//   js/util/iassignHelpers.js!setPreviousAlgorithm(code):                                        var result = parserCodeVisual(code_obj);
+//   js/iassign-integration-functions.js!prepareActivityToStudent(ilm_cont, ignore_logs = false): var result = ivprogCore.setPreviousAlgorithm(ilm_cont);
+//   js/iassign-integration-functions.js!getiLMContent():                                         prepareActivityToStudent(data);
 export function parserCodeVisual (code_obj = null) {
-  console.log("codeParser.js!parserCodeVisual(.): code_obj has " + printCommandText(code_obj)); // JSON.stringify(code_obj));
-  //D console.trace();
+  console.log("js/util/codeParser.js!parserCodeVisual(.): code_obj has " + printCommandText(code_obj)); // JSON.stringify(code_obj));
+  if (!code_obj || code_obj===null) { // Avoid severe error! parserCodeVisual@http://localhost/ivprog/ivprogh/js/main.ecdd914f315cb1bf2925.js:11054:5...
+    console.log("js/util/codeParser.js!parserCodeVisual(.): code_obj is empty: " + code_obj); // JSON.stringify(code_obj));
+    //D console.trace();
+    return null;
+    }
+  // console.trace();
   window.conteudo = code_obj
 
   // Globals:
@@ -129,6 +139,8 @@ export function parserCodeVisual (code_obj = null) {
         }
       })
     });
+  console.log("codeParser.js!parserCodeVisual(.): finished!");
+  return true; // set to js/util/iassignHelpers.js!setPreviousAlgorithm(code) success
   }
 
 
@@ -231,6 +243,10 @@ function parseAttribution (command, function_obj) {
 function parseComment (command, function_obj) {
   // return new Models.Comment(null);
   var comment_text = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_value, command.comment_text, null, null, false);
+  console.log("js/util/codeParser.js!parseComment(.): comment_text=" + comment_text);
+  if (!comment_text || comment_text === null) {
+    return null;
+    }
   return new Models.Comment(comment_text);
   }