|
|
@@ -1513,35 +1513,41 @@ function uploadFile (evt) {
|
|
|
|
|
|
oFReader.onload = function (oFREvent) {
|
|
|
var txt = oFREvent.target.result;
|
|
|
+ var msg_err = ""; // help debug
|
|
|
try {
|
|
|
- if (txt.indexOf("::algorithm::") >= 0 || txt.indexOf("\"test_cases\"") >= 0) {
|
|
|
- //leo/lucas Version with "test-cases": { "version": "x.y",\n "code": ... \n "test_cases":...
|
|
|
+ if (txt.indexOf("::algorithm::") >= 0 || txt.indexOf('"test_cases"') >= 0) {
|
|
|
+ //leo/lucas Version with "test-cases": { "version": "x.y",\n "code": ... \n "test_cases":... }
|
|
|
+ msg_err += "(1) Inside if ::algorithm:: or test_cases\n";
|
|
|
prepareActivityToStudent(txt, true); // in ./src/ivprog/js/iassign-integration-functions.js
|
|
|
+ msg_err += "(2) After prepareActivityToStudent(.)\n";
|
|
|
console.debug("js/visualUI/functions.js!uploadFile(.): code=" + txt.code);
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
//N ivprogCore.setPreviousAlgorithm(txt);
|
|
|
//N window.renderAlgorithm();
|
|
|
-
|
|
|
//N Gleyce: start
|
|
|
+ msg_err += "(3) Inside else\n";
|
|
|
+
|
|
|
// First try the old iVProg syntax to program (translate texto to data object)
|
|
|
console.log("js/visualUI/functions.js!uploadFile(.): read IVPH (allow comment)");
|
|
|
const code_obj = textParser(txt);
|
|
|
if (code_obj) {
|
|
|
// If succeed, translate data objects to visual block
|
|
|
modelParser(code_obj);
|
|
|
+ msg_err += "(4) Inside code_obj after modelParser(.)\n";
|
|
|
// Render algorithm into the visual interface
|
|
|
window.renderAlgorithm();
|
|
|
+ msg_err += "(5) Inside code_obj after window.renderAlgorithm()\n";
|
|
|
} else {
|
|
|
// If first try failed, present a warning
|
|
|
console.error("js/visualUI/functions.js: failed in the translation from texto to iVProg code");
|
|
|
alert("Something was wrong! Please, check if the syntax code of your file is valid to iVProg");
|
|
|
}
|
|
|
//N Gleyce: end
|
|
|
-
|
|
|
}
|
|
|
} catch (e) {
|
|
|
- console.log(e)
|
|
|
+ // console.log(e); - to avoid error in printing: TypeError: cyclic object
|
|
|
+ // try with JSON.stringify(e)?
|
|
|
+ console.log("js/visualUI/functions.js!uploadFile(.): erro!\n" + msg_err);
|
|
|
}
|
|
|
- };
|
|
|
- }
|
|
|
+ }; // oFReader.onload = function(oFREvent)
|
|
|
+ } // function uploadFile(evt)
|