Bladeren bron

Improve error unloaded page handler

Igor 4 jaren geleden
bovenliggende
commit
44cf64c7df
6 gewijzigde bestanden met toevoegingen van 31 en 3 verwijderingen
  1. 5 0
      css/ivprog-visual-1.0.css
  2. 2 0
      i18n/en/ui.json
  3. 2 0
      i18n/es/ui.json
  4. 2 0
      i18n/pt/ui.json
  5. 16 2
      js/util/iassignHelpers.js
  6. 4 1
      templates/index.html

+ 5 - 0
css/ivprog-visual-1.0.css

@@ -1006,4 +1006,9 @@ div.ui.checkbox.transition.visible {
 
 .disabled {
 	pointer-events: none;
+}
+
+.dimmer_content_message {
+	color: white;
+	display: none;
 }

+ 2 - 0
i18n/en/ui.json

@@ -50,6 +50,8 @@
   "text_logic_expression": "Logic Expression",
   "text_arithmetic_expression": "Relational Expression",
   "text_iftrue": "If true then",
+  "text_message_error_activity_file": "There was an error processing the activity. <br>Please reload the page and try again.",
+  "text_message_error_activity_reload": "Reload",
   "text_receives": "receives",
   "text_repeatNtimes": "Repeat N times",
   "text_return":"return",

+ 2 - 0
i18n/es/ui.json

@@ -50,6 +50,8 @@
   "text_logic_expression": "Logic Expression",
   "text_arithmetic_expression": "Relational Expression",
   "text_iftrue": "If true then",
+  "text_message_error_activity_file": "There was an error processing the activity. <br>Please reload the page and try again.",
+  "text_message_error_activity_reload": "Reload",
   "text_receives": "receives",
   "text_repeatNtimes": "Repeat N times",
   "text_return":"return",

+ 2 - 0
i18n/pt/ui.json

@@ -58,6 +58,8 @@
   "text_logic_expression": "Expressão Lógica",
   "text_arithmetic_expression": "Expressão Relacional",
   "text_iftrue": "Se verdadeiro então",
+  "text_message_error_activity_file": "Aconteceu um erro ao processar a atividade. <br> Recarregue a página para tentar novamente.",
+  "text_message_error_activity_reload": "Recarregar",
   "text_repeatNtimes": "Repita N vezes",
   "text_receives": "recebe",
   "text_whiletrue": "Enquanto verdadeiro",

+ 16 - 2
js/util/iassignHelpers.js

@@ -3,6 +3,7 @@ import { generate } from "../visualUI/code_generator";
 import { IVProgAssessment } from "../assessment/ivprogAssessment";
 import { TestConsole } from "./testConsole";
 import { parseLogs } from "./../services/userLog";
+import { LocalizedStrings } from './../services/localizedStringsService';
 
 function parseActivityData (data) {
   let algorithm_in_ilm = null;
@@ -13,8 +14,21 @@ function parseActivityData (data) {
       parseLogs(logs);
     }
   }
-  let content = JSON.parse(data.split('\n::algorithm::')[0]);
-  content['algorithm_in_ilm'] = algorithm_in_ilm;
+  let content;
+  try {
+    content = JSON.parse(data.split('\n::algorithm::')[0]);
+    content['algorithm_in_ilm'] = algorithm_in_ilm;
+  } catch (e) {
+    $('.ui.height_100.add_accordion').dimmer({
+      closable: false
+    });
+    $('.dimmer_content_message h3').html(LocalizedStrings.getUI('text_message_error_activity_file'));
+    $('.dimmer_content_message button').text(LocalizedStrings.getUI('text_message_error_activity_reload'));
+    $('.dimmer_content_message').css('display', 'block');
+    $('.ui.height_100.add_accordion').dimmer('add content', '.dimmer_content_message');
+    $('.ui.height_100.add_accordion').dimmer('show');
+    console.error(e);
+  }
   return content;
 }
 

+ 4 - 1
templates/index.html

@@ -104,7 +104,10 @@
           
         </div>
       </div>
-
+    </div>
+    <div class="dimmer_content_message">
+      <h3>Aconteceu um erro ao processar a atividade. <br> Recarregue a página para tentar novamente.</h3>
+      <button class="positive ui button" onclick="window.parent.location.reload()">Recarregar</button>
     </div>
     <script src="js/iassign-integration-functions.js"></script>
   </div>