Browse Source

Fix bug where insufficient outputs of type string would be shown as null

Lucas de Souza 5 years ago
parent
commit
bb2b2ad5ba

+ 5 - 2
css/ivprog-assessment.css

@@ -66,7 +66,10 @@ table td { font-size: 14pt;}
 }
 .assessment-string-expected, .assessment-string-generated, .assessment-string-diff {text-align: left;}
 p.assessment-failed-execution {padding-left: 1rem;}
-.assessment-failed-case {color:#FF1212}
+.assessment-failed-case {
+  color:#FF1212;
+  padding-right: 1rem;
+}
 .assessment-input-unread {color: #d02929}
 .assessment-number-result-failed, .assessment-bool-result-failed {color: #d02929}
 .assessment-number-result, .assessment-bool-result, .assessment-string-result {color: #22a222}
@@ -115,4 +118,4 @@ p.assessment-failed-execution {padding-left: 1rem;}
 .assessment-empty-output {
   height: 1.5rem;
   width: 1.5rem;
-}
+}

+ 2 - 2
i18n/message.csv

@@ -4,9 +4,9 @@ test_case_duration,Levou $0ms,Took $0ms," "
 test_suite_grade,A sua solução alcançou $0% da nota.,Your solution scored $0% of the grade.," "
 awaiting_input_message,O seu programa está em execução e aguardando uma entrada! Digite algo e pressione ENTER...,Your program is running and awaiting for an input. Type something and press ENTER…," "
 assessment-empty-expected-tooltip,A saída gerada foi além do esperado,The generated output was beyond the amount expected," "
-assessment-empty-generated-tooltip,O programa não gerou saídas suficientes,The program did not generated enough outputs," "
+assessment-empty-generated-tooltip,O programa não gerou saídas suficientes,The program did not generate enough outputs," "
 testcase_autogen_unused_input,O caso de teste $0 possui mais entradas do que as leituras feitas no programa.,The test case $0 has more inputs than output than the number of reads present in the algorithm.," "
 testcase_autogen_empty,O caso de teste $0 não gerou qualquer saída.,The test case $0 did not generate any output.," "
 success_execution,Programa executado com sucesso!,Program executed successfully!,
 aborted_execution,A execução do programa foi interrompida!,Program execution was aborted!,
-unexpected_execution_error,Erro inesperado durante a execução do programa.,Unexpected error during program execution.,
+unexpected_execution_error,Erro inesperado durante a execução do programa.,Unexpected error during program execution.,

+ 15 - 3
js/assessment/output_matching/assessment_result.js

@@ -152,7 +152,7 @@ export class OutputAssessmentResult {
   }
 
   formatNumber (result) {
-    const result_class = result.grade == 1 ? 'assessment-number-result' : 'assessment-number-result-failed'; 
+    const result_class = result.grade == 1 ? 'assessment-number-result' : 'assessment-number-result-failed';
     let template = this.formatOutput('assessment-number-expected',
       'assessment-number-generated', result_class, result);
     return template
@@ -198,8 +198,18 @@ export class OutputAssessmentResult {
 
     const g_string = result.generated || "";
     const e_string = result.expected || "";
-    template = template.replace("$0", result.expected);
-    template = template.replace("$1", result.generated);
+    console.log("generated: ", g_string,"expected: ", e_string);
+    let g_string_tmpl = g_string;
+    let e_string_tmpl = e_string;
+    if(result.generated == null) {
+      g_string_tmpl = OutputAssessmentResult.EMPTY_OUTPUT_TEMPLATE.replace('$0',
+        LocalizedStrings.getMessage('assessment-empty-generated-tooltip'));
+    } else if (result.expected == null) {
+     e_string_tmpl = OutputAssessmentResult.EMPTY_OUTPUT_TEMPLATE.replace('$0',
+        LocalizedStrings.getMessage('assessment-empty-expected-tooltip'));
+    }
+    template = template.replace("$0", e_string_tmpl);
+    template = template.replace("$1", g_string_tmpl);
     if(result.grade == 1) {
       template = template.replace("$2", "✓");
       template = template.replace(":class-result:", 'assessment-string-result');
@@ -215,6 +225,8 @@ export class OutputAssessmentResult {
 
   getDiffStringStyle (text, action) {
     const template = "<span class='$0'>$1</span>"
+    // Fix missing whitespace when its a single element
+    text = text.replace(/\s/g,"&#x0020;");
     switch(action) {
       case StringDiff.INSERT:
         return template.replace("$0", "stringdiff-insert").replace("$1", text);

+ 1 - 0
js/assessment/output_matching/output_matching.js

@@ -57,6 +57,7 @@ export class OutputMatching {
         return this.outputMatch(g_out, this.expected_output[i]);
       }, this);
       if(this.expected_output.length > gen_output.list.length) {
+        console.log("Saída insuficientes!",this.expected_output.length,gen_output.list.length);
         for(let i = gen_output.list.length; i < this.expected_output.length; ++i) {
           const e_out = this.expected_output[i];
           result.push(new OutputResult.OutputMatchResult(e_out, null, 0, this.getPotentialOutputType(e_out)));

+ 6 - 6
js/io/domConsole.js

@@ -130,7 +130,7 @@ export class DOMConsole {
   _setupCursor () {
     this.inputCMD.addEventListener('click', this.blinkCaretAndFocus.bind(this));
     //this.inputCMD.click();
-    
+
     this.input.addEventListener('keyup', this.updateSpanText.bind(this));
     this.input.addEventListener('blur', this.stopBlinkCaret.bind(this));
   }
@@ -217,7 +217,7 @@ export class DOMConsole {
 
   getOutputText (text) {
     if(text.trim().length == 0) {
-      text = "&nbsp;";
+      text = text.replace(/\s/g, "&#x0020;");
     }
     return `<span>${text}</span>`;
   }
@@ -328,8 +328,8 @@ export class DOMConsole {
   sendOutput (text) {
     const output = ""+text;
     output.split("\n").forEach(t => {
-      t = t.replace(/\t/g,'&nbsp;&nbsp;');
-      t = t.replace(/\s/g,"&nbsp;");
+      t = t.replace(/\t/g,'&#x0020;&#x0020;');
+      t = t.replace(/\s/g,"&#x0020;");
       this.write(t)
     });
   }
@@ -367,7 +367,7 @@ export class DOMConsole {
     this.info(LocalizedStrings.getMessage('awaiting_input_message'));
     this.inputCMD.click();
   }
-  
+
   scheduleNotify () {
     this.idleInterval = window.setInterval(this.notifyIdle.bind(this), Config.idle_input_interval);
   }
@@ -384,4 +384,4 @@ export class DOMConsole {
     this.hideInput();
     this.anyKey = false;
   }
-}
+}