|
@@ -43,6 +43,26 @@ function removeCollapseValue (command) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function configAuxiliar (form_element) {
|
|
|
+ var _array = form_element.serializeArray();
|
|
|
+ var temp = _array.reduce(function(map, obj) {
|
|
|
+ map[obj.name] = obj.value == "on";
|
|
|
+ return map;
|
|
|
+ }, {});
|
|
|
+
|
|
|
+ return temp;
|
|
|
+}
|
|
|
+
|
|
|
+function configAuxiliarProgrammingType (form_element) {
|
|
|
+ var _array = form_element.serializeArray();
|
|
|
+ var temp = _array.reduce(function(map, obj) {
|
|
|
+ map[obj.name] = obj.value;
|
|
|
+ return map;
|
|
|
+ }, {});
|
|
|
+
|
|
|
+ return temp;
|
|
|
+}
|
|
|
+
|
|
|
// Função chamada pelo iTarefa quando o professor finaliza a criação da atividade
|
|
|
// ou quando o aluno finaliza a resolução do exercício
|
|
|
// O retorno é um JSON com os dados do exercício ou da resolução
|
|
@@ -57,8 +77,8 @@ function getAnswer () {
|
|
|
if (iLMparameters.iLM_PARAM_SendAnswer == 'false') {
|
|
|
// Montar o retorno com a resposta do aluno
|
|
|
|
|
|
- objAnswer.test_cases = ivprogCore.getTestCases();
|
|
|
objAnswer.code = generator();
|
|
|
+ objAnswer.test_cases = ivprogCore.getTestCases();
|
|
|
objAnswer.logs = ivprogCore.getLogs();
|
|
|
objAnswer.settings = {
|
|
|
"programming": ivprogCore.Config.activity_programming_type,
|
|
@@ -75,11 +95,11 @@ function getAnswer () {
|
|
|
objAnswer.test_cases = prepareTestCases();
|
|
|
|
|
|
objAnswer.settings = {
|
|
|
- "programming": $('form[name="settings_programming_type"]').serializeArray(),
|
|
|
- "functions": $('form[name="settings_functions"]').serializeArray(),
|
|
|
- "datatypes": $('form[name="settings_data_types"]').serializeArray(),
|
|
|
- "commands": $('form[name="settings_commands"]').serializeArray(),
|
|
|
- "filter": $('form[name="settings_filter"]').serializeArray()
|
|
|
+ "programming": configAuxiliarProgrammingType($('form[name="settings_programming_type"]')),
|
|
|
+ "functions": configAuxiliar($('form[name="settings_functions"]')),
|
|
|
+ "datatypes": configAuxiliar($('form[name="settings_data_types"]')),
|
|
|
+ "commands": configAuxiliar($('form[name="settings_commands"]')),
|
|
|
+ "filter": configAuxiliar($('form[name="settings_filter"]'))
|
|
|
};
|
|
|
|
|
|
if ($("input[name='include_algo']").is(':checked')) {
|
|
@@ -261,12 +281,31 @@ function includePreviousAlgorithm () {
|
|
|
}
|
|
|
|
|
|
function prepareActivityToStudent (ilm_cont) {
|
|
|
+
|
|
|
+ // File version (1.0):
|
|
|
+ try {
|
|
|
+ var jsonObj = JSON.parse(ilm_cont);
|
|
|
+ ivprogCore.prepareActivityToStudentHelperJSON(jsonObj);
|
|
|
+
|
|
|
+ if (ivprogCore.getTestCases())
|
|
|
+ $('.assessment_button').removeClass('disabled');
|
|
|
+
|
|
|
+ renderAlgorithm();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ console.log('Previous file format!');
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Previous file format:
|
|
|
// Ver arquivo js/util/iassignHelpers.js
|
|
|
var content = ivprogCore.prepareActivityToStudentHelper(ilm_cont).getOrElse(null);
|
|
|
if(!content) {
|
|
|
showInvalidData();
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
// Casos de testes agora são delegados ao tratamento apropriado pela função acima
|
|
|
// var testCases = content.testcases;
|
|
|
settingsProgrammingTypes = content.settingsProgrammingType;
|