|
@@ -61,77 +61,66 @@ function getAnswer () {
|
|
|
objAnswer.code = generator();
|
|
|
objAnswer.logs = ivprogCore.getLogs();
|
|
|
objAnswer.settings = {
|
|
|
- "functions": [],
|
|
|
- "datatypes": [],
|
|
|
- "commands": []
|
|
|
+ "programming": ivprogCore.Config.activity_programming_type,
|
|
|
+ "functions": ivprogCore.Config.activity_functions,
|
|
|
+ "datatypes": ivprogCore.Config.activity_datatypes,
|
|
|
+ "commands": ivprogCore.Config.activity_commands,
|
|
|
+ "filter": ivprogCore.Config.activity_filter
|
|
|
};
|
|
|
|
|
|
-
|
|
|
return JSON.stringify(objAnswer, null, 4);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- console.log('professor!!')
|
|
|
- // Montar o retorno com a criação da atividade do professor
|
|
|
- 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())
|
|
|
- + ',\n"settings_filter": \n' + JSON.stringify($('form[name="settings_filter"]').serializeArray())
|
|
|
- + ' } ';
|
|
|
+ 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()
|
|
|
+ };
|
|
|
|
|
|
if ($("input[name='include_algo']").is(':checked')) {
|
|
|
- ret += '\n::algorithm::';
|
|
|
- ret += JSON.stringify(window.program_obj, function(key, value) {
|
|
|
-
|
|
|
- if (key == 'dom_object') {
|
|
|
- return;
|
|
|
- }
|
|
|
- return value;
|
|
|
- });
|
|
|
+ objAnswer.algorithm = generator();
|
|
|
}
|
|
|
|
|
|
- return ret;
|
|
|
+ return JSON.stringify(objAnswer, null, 4);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function prepareTestCases () {
|
|
|
- var ret = ' \n "testcases" : [ '
|
|
|
+
|
|
|
var test_cases_array = $('form[name="test_cases"]').serializeArray();
|
|
|
- console.log(test_cases_array);
|
|
|
+
|
|
|
+ var cases = [];
|
|
|
+
|
|
|
for (var i = 0; i < test_cases_array.length; i = i + 2) {
|
|
|
- ret += '\n{ ';
|
|
|
- ret += '\n "input": [';
|
|
|
+
|
|
|
+ var temp = new Object();
|
|
|
+
|
|
|
+ temp.input = [];
|
|
|
+ temp.output = [];
|
|
|
+
|
|
|
var inps = test_cases_array[i].value.match(/[^\r\n]+/g);
|
|
|
if (inps) {
|
|
|
for (var j = 0; j < inps.length; j++) {
|
|
|
- ret += '"' + inps[j] + '"';
|
|
|
- if ((j + 1) < inps.length) {
|
|
|
- ret += ', ';
|
|
|
- }
|
|
|
+ temp.input.push(inps[j]);
|
|
|
}
|
|
|
}
|
|
|
- ret += '], \n "output": [';
|
|
|
+
|
|
|
var outs = test_cases_array[i+1].value.match(/[^\r\n]+/g);
|
|
|
- console.log(outs);
|
|
|
if (outs) {
|
|
|
for (var j = 0; j < outs.length; j++) {
|
|
|
- console.log("output -> ",outs[j]);
|
|
|
- ret += '"' + outs[j] + '"';
|
|
|
- if ((j + 1) < outs.length) {
|
|
|
- ret += ', ';
|
|
|
- }
|
|
|
+ temp.output.push(outs[j]);
|
|
|
}
|
|
|
}
|
|
|
- ret += ']';
|
|
|
- ret += '\n}'
|
|
|
- if ((i + 2) < test_cases_array.length) {
|
|
|
- ret += ',';
|
|
|
- }
|
|
|
+
|
|
|
+ cases.push(temp);
|
|
|
}
|
|
|
- ret += '\n] ';
|
|
|
- return ret;
|
|
|
+
|
|
|
+ return cases;
|
|
|
}
|
|
|
|
|
|
// Função chamada pelo iTarefa para receber a nota do aluno na atividade
|
|
@@ -504,6 +493,9 @@ function prepareTableTestCases (div_el) {
|
|
|
$('.button_generate_outputs').on('click', function(e) {
|
|
|
generateOutputs();
|
|
|
});
|
|
|
+
|
|
|
+ if (!iLMparameters.iLM_PARAM_Assignment)
|
|
|
+ addTestCase();
|
|
|
}
|
|
|
|
|
|
function showAlert (msg) {
|
|
@@ -519,7 +511,7 @@ function generateOutputs () {
|
|
|
// código:
|
|
|
var code_teacher = window.generator();
|
|
|
// array com as entradas já inseridas:
|
|
|
- var test_cases = JSON.parse(prepareTestCases().replace('"testcases" :', ''));
|
|
|
+ var test_cases = prepareTestCases();
|
|
|
ivprogCore.autoGenerateTestCaseOutput(code_teacher, test_cases).catch(function (error) {
|
|
|
showAlert("Houve um erro durante a execução do seu programa: "+error.message);
|
|
|
});
|