Просмотр исходного кода

logs: remove logs in update file

Igor 2 лет назад
Родитель
Сommit
c5ee321c96
3 измененных файлов с 15 добавлено и 9 удалено
  1. 2 2
      js/iassign-integration-functions.js
  2. 4 4
      js/util/iassignHelpers.js
  3. 9 3
      js/visualUI/functions.js

+ 2 - 2
js/iassign-integration-functions.js

@@ -291,7 +291,7 @@ function includePreviousAlgorithm () {
   }, 1);
 }
 
-function prepareActivityToStudent (ilm_cont) {
+function prepareActivityToStudent (ilm_cont, ignore_logs = false) {
 
     // File version (1.0):
     try {
@@ -313,7 +313,7 @@ function prepareActivityToStudent (ilm_cont) {
 
     // Previous file format:
     // Ver arquivo js/util/iassignHelpers.js
-    var content = ivprogCore.prepareActivityToStudentHelper(ilm_cont).getOrElse(null);
+    var content = ivprogCore.prepareActivityToStudentHelper(ilm_cont, ignore_logs).getOrElse(null);
     if(!content) {
       $('.ivprog_visual_panel').removeClass("loading");
       showInvalidData();

+ 4 - 4
js/util/iassignHelpers.js

@@ -7,12 +7,12 @@ import { SemanticAnalyser } from "../processor/semantic/semanticAnalyser";
 import { Maybe } from "./maybe";
 import { parserCodeVisual } from "./codeParser";
 
-function parseActivityData (data) {
+function parseActivityData (data, ignore_logs=false) {
   let algorithm_in_ilm = null;
   if (data.split("\n::algorithm::")[1]) {
     algorithm_in_ilm = data.split("\n::algorithm::")[1].split("\n::logs::")[0];
     const logs = data.split("\n::algorithm::")[1].split("\n::logs::")[1];
-    if (logs != null) {
+    if (logs != null && ignore_logs == false) {
       parseLogs(logs);
     }
   }
@@ -76,8 +76,8 @@ export function prepareActivityToStudentHelperJSON (ilm_cont) {
 
 }
 
-export function prepareActivityToStudentHelper (ilm_cont) {
-  const maybe_content = parseActivityData(ilm_cont);
+export function prepareActivityToStudentHelper (ilm_cont, ignore_logs=false) {
+  const maybe_content = parseActivityData(ilm_cont, ignore_logs);
   return maybe_content.map((content) => {
     const testCases = content.testcases;
     setTestCases(testCases);

+ 9 - 3
js/visualUI/functions.js

@@ -1696,14 +1696,20 @@ function uploadFile (evt) {
     oFReader.readAsText(document.getElementById("ivph_file").files[0]);
     oFReader.onload = function (oFREvent) {
       var txt = oFREvent.target.result;
+
       try {
 
-        ivprogCore.setPreviousAlgorithm(txt);
-        window.renderAlgorithm();
+        if (txt.indexOf("::algorithm::") >= 0) {
+          prepareActivityToStudent(txt, true);
+        }
+        else {
+          ivprogCore.setPreviousAlgorithm(txt);
+          window.renderAlgorithm();
+        }
 
       }
       catch (e) {
-        showInvalidFile();
+        console.log(e)
       }
     };
   }