Selaa lähdekoodia

Partial improves of textual coding

Igor 5 vuotta sitten
vanhempi
commit
a1bdfb94da

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

@@ -996,4 +996,8 @@ div.ui.checkbox.transition.visible {
 	font-style: italic;
 	margin-left: 1px;
 	margin-right: 1px;
+}
+
+.disabled {
+	pointer-events: none;
 }

+ 4 - 0
i18n/en/ui.json

@@ -43,6 +43,10 @@
   "text_command_do":"do",
   "text_code_switch": "switch",
   "text_code_case": "case",
+  "text_config_programming":"Programming",
+  "text_config_programming_both":"Visual and textual",
+  "text_config_programming_textual":"Textual",
+  "text_config_programming_visual":"Visual",
   "text_logic_expression": "Logic Expression",
   "text_arithmetic_expression": "Relational Expression",
   "text_iftrue": "If true then",

+ 4 - 0
i18n/es/ui.json

@@ -43,6 +43,10 @@
   "text_command_do":"do",
   "text_code_switch": "switch",
   "text_code_case": "case",
+  "text_config_programming":"Programming",
+  "text_config_programming_both":"Visual and textual",
+  "text_config_programming_textual":"Textual",
+  "text_config_programming_visual":"Visual",
   "text_logic_expression": "Logic Expression",
   "text_arithmetic_expression": "Relational Expression",
   "text_iftrue": "If true then",

+ 4 - 0
i18n/pt/ui.json

@@ -51,6 +51,10 @@
   "text_command_do":"faça",
   "text_code_switch": "escolha",
   "text_code_case": "caso",
+  "text_config_programming":"Programação",
+  "text_config_programming_both":"Visual e textual",
+  "text_config_programming_textual":"Textual",
+  "text_config_programming_visual":"Visual",
   "text_logic_expression": "Expressão Lógica",
   "text_arithmetic_expression": "Expressão Relacional",
   "text_iftrue": "Se verdadeiro então",

+ 38 - 3
js/iassign-integration-functions.js

@@ -45,7 +45,8 @@ function getAnswer () {
 
   } else {
     // Montar o retorno com a criação da atividade do professor
-    var ret = ' { ' + prepareTestCases() 
+    var ret = ' { ' + prepareTestCases()
+        + ',\n"settings_programming_type": \n' + JSON.stringify($('form[name="settings_programming_type"]').serializeArray()) 
         + ',\n"settings_data_types": \n' + JSON.stringify($('form[name="settings_data_types"]').serializeArray()) 
         + ',\n"settings_commands": \n' + JSON.stringify($('form[name="settings_commands"]').serializeArray()) 
         + ',\n"settings_functions": \n' + JSON.stringify($('form[name="settings_functions"]').serializeArray()) 
@@ -114,11 +115,11 @@ function getEvaluation () {
   }
 }
 
-
-//var testCases = null;
+//var testCases = null
 var settingsDataTypes = null;
 var settingsCommands = null;
 var settingsFunctions = null;
+var settingsProgrammingTypes = null;
 var algorithm_in_ilm = null;
 var previousContent = null;
 
@@ -152,6 +153,8 @@ function prepareActivityToEdit (ilm_cont) {
   // Ver arquivo js/util/iassignHelpers.js
   var content = ivprogCore.prepareActivityToStudentHelper(ilm_cont);
   var testCases = ivprogCore.getTestCases();
+
+  settingsProgrammingTypes = content.settingsProgrammingType;
   settingsDataTypes = content.settingsDataTypes;
   settingsCommands = content.settingsCommands;
   settingsFunctions = content.settingsFunctions;
@@ -166,6 +169,8 @@ function prepareActivityToEdit (ilm_cont) {
     includePreviousAlgorithm();
     renderAlgorithm();
   }
+
+  ivprogTextualOrVisual();
 }
 
 function parsePreviousAlgorithm () {
@@ -224,6 +229,7 @@ function prepareActivityToStudent (ilm_cont) {
     var content = ivprogCore.prepareActivityToStudentHelper(ilm_cont);
     // Casos de testes agora são delegados ao tratamento apropriado pela função acima
     // var testCases = content.testcases;
+    settingsProgrammingTypes = content.settingsProgrammingType;
     settingsDataTypes = content.settingsDataTypes;
     settingsCommands = content.settingsCommands;
     settingsFunctions = content.settingsFunctions;
@@ -234,6 +240,8 @@ function prepareActivityToStudent (ilm_cont) {
     }
     $('.assessment_button').removeClass('disabled');
     renderAlgorithm();
+
+    ivprogTextualOrVisual();
 }
 
 // Função para organizar se para criação, visualização ou resolução de atividade
@@ -275,6 +283,23 @@ function prepareEnvironment () {
   }
 }
 
+function ivprogTextualOrVisual () {
+  if (settingsProgrammingTypes) {
+    if (settingsProgrammingTypes == "textual") {
+      $('.ivprog_visual_panel').css('display', 'none'); 
+      $('.ivprog_textual_panel').css('display', 'block');
+      $('.ivprog_textual_panel').removeClass('loading');
+
+      $('.visual_coding_button').removeClass('active');
+      $('.textual_coding_button').addClass('active'); 
+      $('.visual_coding_button').addClass('disabled');
+    }
+    if (settingsProgrammingTypes == "visual") {
+      
+    }
+  }
+}
+
 function iassingIntegration () {
 
   // Disable by default...
@@ -406,8 +431,15 @@ function updateTestCaseCounter () {
     });
 }
 
+
 function prepareTableSettings (div_el) {
 
+  div_el.append('<h4 class="ui header">'+LocalizedStrings.getUI('text_config_programming')+'</h4>');
+  div_el.append('<form name="settings_programming_type"><div class="ui stackable five column grid">'
+    +'<div class="column"><div class="ui radio"><input type="radio" name="programming_type" id="programming_textual" value="textual" tabindex="0" class="hidden small"><label for="programming_textual">'+LocalizedStrings.getUI('text_config_programming_textual')+'</label></div></div>'
+    +'<div class="column"><div class="ui radio"><input type="radio" name="programming_type" id="programming_visual" value="visual" checked tabindex="0" class="hidden small"><label for="programming_visual">'+LocalizedStrings.getUI('text_config_programming_visual')+'</label></div></div>'
+    +'</div></form>');
+
   div_el.append('<h4 class="ui header">'+LocalizedStrings.getUI('text_teacher_data_types')+'</h4>');
   div_el.append('<form name="settings_data_types"><div class="ui stackable five column grid">'
     +'<div class="column"><div class="ui checkbox"><input type="checkbox" name="integer_data_type" checked tabindex="0" class="hidden small"><label>'+LocalizedStrings.getUI('integer')+'</label></div></div>'
@@ -526,6 +558,7 @@ function teacherAutoEval (data) {
     var content = ivprogCore.prepareActivityToStudentHelper(data);
     // Casos de testes agora são delegados ao tratamento apropriado pela função acima
     // var testCases = content.testcases;
+    settingsProgrammingTypes = content.settingsProgrammingType; 
     settingsDataTypes = content.settingsDataTypes;
     settingsCommands = content.settingsCommands;
     settingsFunctions = content.settingsFunctions;
@@ -535,5 +568,7 @@ function teacherAutoEval (data) {
       parsePreviousAlgorithm();
       ivprogCore.autoEval(originalData, parent.getEvaluationCallback);
     }
+
+    ivprogTextualOrVisual();
   });
 }

+ 8 - 0
js/util/iassignHelpers.js

@@ -23,7 +23,15 @@ export function prepareActivityToStudentHelper (ilm_cont) {
   const testCases = content.testcases;
   setTestCases(testCases);
 
+  let prog_type = null;
+  if (content.settings_programming_type) {
+    prog_type = content.settings_programming_type[0].value;
+  } else {
+    prog_type = "visual";
+  }
+
   return {
+    settingsProgrammingType: prog_type,
     settingsDataTypes: content.settings_data_types,
     settingsCommands: content.settings_commands,
     settingsFunctions: content.settings_functions,

+ 17 - 2
js/visualUI/functions.js

@@ -890,8 +890,16 @@ function runCodeAssessment () {
     return;
   }
   
+  let strCode = null;
+
   window.studentGrade = null;
-  const strCode = CodeManagement.generate();
+
+  if (settingsProgrammingTypes == "textual") {
+    strCode = $('.ivprog_textual_code').val();
+  } else {
+    strCode = CodeManagement.generate();
+  }
+
   if (strCode == null) {
     return;
   }
@@ -921,7 +929,14 @@ function runCode () {
   if (isRunning) {
     return;
   }
-  const strCode = CodeManagement.generate();
+  let strCode = null;
+
+  if (settingsProgrammingTypes == "textual") {
+    strCode = $('.ivprog_textual_code').val();
+  } else {
+    strCode = CodeManagement.generate();
+  }
+
   if (strCode == null) {
     return;
   }

+ 1 - 1
templates/index.html

@@ -97,7 +97,7 @@
 
 
         <div class="ui one column container segment ivprog_textual_panel loading" style="display: none;">
-          <textarea class="ivprog_textual_code" readonly></textarea>
+          <textarea class="ivprog_textual_code"></textarea>
         </div>
         <div id='ivprog-term-div' class="six column wide">