|
@@ -36,6 +36,17 @@ function qualVersaoDoIVProg ($arquivo) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// delete all files and sub-folders from a folder
|
|
|
+function deleteFolderAndFiles($dir) {
|
|
|
+ foreach(glob($dir . '/*') as $file) {
|
|
|
+ if(is_dir($file))
|
|
|
+ deleteFolderAndFiles($file);
|
|
|
+ else
|
|
|
+ unlink($file);
|
|
|
+ }
|
|
|
+ rmdir($dir);
|
|
|
+}
|
|
|
+
|
|
|
function pegarLogsDoAluno ($curso, $aluno, $exercicio) {
|
|
|
|
|
|
$zip = new ZipArchive;
|
|
@@ -94,70 +105,51 @@ function pegarLogsDoAluno ($curso, $aluno, $exercicio) {
|
|
|
return $arquivo;
|
|
|
}
|
|
|
|
|
|
-function pegarLogsDoAlunoComoString ($arquivo) {
|
|
|
-
|
|
|
- $handle = fopen("temp/" . $arquivo, "r");
|
|
|
- $inicio = false;
|
|
|
- $string_final = "";
|
|
|
- if ($handle) {
|
|
|
-
|
|
|
- while (($line = fgets($handle)) !== false) {
|
|
|
-
|
|
|
- if ( strpos($line, "::logs::") !== false) {
|
|
|
- $inicio = true;
|
|
|
- print $line;
|
|
|
- break;
|
|
|
- }
|
|
|
- if ($inicio) {
|
|
|
- $ex = explode(",", $line);
|
|
|
- if (count($ex) > 3) {
|
|
|
- $string_final .= $ex[1] . "," . $ex[2] . ",1,0\\n";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- fclose($handle);
|
|
|
- } else {
|
|
|
- echo "ERRO AO LER O ARQUIVO";
|
|
|
- }
|
|
|
- print 'a'. $string_final;
|
|
|
-
|
|
|
- exit;
|
|
|
+function pegarLogsDoAlunoComoString ($curso, $aluno, $exercicio) {
|
|
|
|
|
|
- return $string_final;
|
|
|
-}
|
|
|
+ $registros = abrirArquivoCSV($_GET['curso'], false);
|
|
|
|
|
|
-function listarAlunos ($curso) {
|
|
|
+ $aluno_raw = str_replace(" ", "_", $aluno);
|
|
|
+ $exercicio_raw = str_replace("_", " ", $curso);
|
|
|
|
|
|
- $dir = 'cursos/' . $curso;
|
|
|
- $files1 = scandir($dir);
|
|
|
- $nomes = array();
|
|
|
-
|
|
|
- if (count($files1) < 3) {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ foreach ($registros as $registro) {
|
|
|
|
|
|
- for ($i = 0; $i < count($files1); $i++) {
|
|
|
- if ($files1[$i] == "." || $files1[$i] == "..") continue;
|
|
|
- $ex = explode("_iassign_", $files1[$i])[1];
|
|
|
- $ex = explode("-", $ex)[0];
|
|
|
-
|
|
|
- $ja_existe = false;
|
|
|
- for ($j = 0; $j < count($nomes); $j ++) {
|
|
|
- if ($nomes[$j] == $ex) {
|
|
|
- $ja_existe = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ //if (str_contains($registro))
|
|
|
|
|
|
- if (!$ja_existe) {
|
|
|
- array_push($nomes, $ex);
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- return $nomes;
|
|
|
+ // $handle = fopen("temp/" . $arquivo, "r");
|
|
|
+ // $inicio = false;
|
|
|
+ // $string_final = "";
|
|
|
+ // if ($handle) {
|
|
|
+
|
|
|
+ // while (($line = fgets($handle)) !== false) {
|
|
|
+
|
|
|
+ // if ( strpos($line, "::logs::") !== false) {
|
|
|
+ // $inicio = true;
|
|
|
+ // print $line;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // if ($inicio) {
|
|
|
+ // $ex = explode(",", $line);
|
|
|
+ // if (count($ex) > 3) {
|
|
|
+ // $string_final .= $ex[1] . "," . $ex[2] . ",1,0\\n";
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // fclose($handle);
|
|
|
+ // } else {
|
|
|
+ // echo "ERRO AO LER O ARQUIVO";
|
|
|
+ // }
|
|
|
+ // print 'a'. $string_final;
|
|
|
+
|
|
|
+ // exit;
|
|
|
+
|
|
|
+ // return $string_final;
|
|
|
}
|
|
|
|
|
|
-function listarExercicios ($curso) {
|
|
|
+
|
|
|
+function abrirArquivoCSV ($curso, $delete_temp = true) {
|
|
|
$zip = new ZipArchive;
|
|
|
|
|
|
$dir = 'cursos/' . $curso;
|
|
@@ -168,49 +160,68 @@ function listarExercicios ($curso) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ $temp_folder = 'temp/' . $curso;
|
|
|
+
|
|
|
for ($i = 0; $i < count($files1); $i++) {
|
|
|
if ($files1[$i] == "." || $files1[$i] == "..") continue;
|
|
|
$res = $zip->open($dir . '/' . $files1[$i]);
|
|
|
if ($res === TRUE) {
|
|
|
- $zip->extractTo('temp/');
|
|
|
+ $zip->extractTo($temp_folder);
|
|
|
$zip->close();
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- $dir = 'temp';
|
|
|
- $files1 = scandir($dir);
|
|
|
-
|
|
|
- if (count($files1) < 3) {
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
- for ($i = 0; $i < count($files1); $i++) {
|
|
|
- if ($files1[$i] == "." || $files1[$i] == "..") continue;
|
|
|
+ if (!file_exists($temp_folder . '/index.csv')) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ $final_array = array();
|
|
|
+ $file = fopen($temp_folder . '/index.csv', 'r');
|
|
|
+ while (($line = fgetcsv($file)) !== FALSE) {
|
|
|
+ array_push($final_array, $line);
|
|
|
+ }
|
|
|
+ fclose($file);
|
|
|
|
|
|
- $exp = explode("-", $files1[$i]);
|
|
|
- $fi = "";
|
|
|
- for ($j = 0; $j < count($exp) - 1; $j++) {
|
|
|
- $fi .= $exp[$j];
|
|
|
- if ($j < (count($exp) - 3)) {
|
|
|
- $fi .= "-";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $ja_existe = false;
|
|
|
- for ($j = 0; $j < count($exercicios); $j++) {
|
|
|
- if ($exercicios[$j] == $fi) {
|
|
|
- $ja_existe = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (!$ja_existe) {
|
|
|
- array_push($exercicios, $fi);
|
|
|
- }
|
|
|
-
|
|
|
- unlink($dir . '/' . $files1[$i]);
|
|
|
- }
|
|
|
- return $exercicios;
|
|
|
+ if ($delete_temp)
|
|
|
+ deleteFolderAndFiles($temp_folder);
|
|
|
+
|
|
|
+ return $final_array;
|
|
|
+}
|
|
|
+
|
|
|
+function listarAlunos ($curso) {
|
|
|
+
|
|
|
+ $registros = abrirArquivoCSV($curso);
|
|
|
+
|
|
|
+ $nomes = array();
|
|
|
+ foreach ($registros as $registro) {
|
|
|
+ if ($registro[0] == 'submissionid') continue;
|
|
|
+
|
|
|
+ $nome = str_replace("_", " ", explode("/", $registro[1])[1]);
|
|
|
+
|
|
|
+ array_push($nomes, $nome);
|
|
|
+ }
|
|
|
+
|
|
|
+ $nomes = array_unique($nomes);
|
|
|
+ asort($nomes);
|
|
|
+
|
|
|
+ return $nomes;
|
|
|
+}
|
|
|
+
|
|
|
+function listarExercicios ($curso) {
|
|
|
+
|
|
|
+ $registros = abrirArquivoCSV($curso);
|
|
|
+
|
|
|
+ $exercicios = array();
|
|
|
+ foreach ($registros as $registro) {
|
|
|
+ if ($registro[0] == 'submissionid') continue;
|
|
|
+
|
|
|
+ $nome = str_replace("_", " ", explode("/", $registro[1])[0]);
|
|
|
+
|
|
|
+ array_push($exercicios, $nome);
|
|
|
+ }
|
|
|
+
|
|
|
+ return array_unique($exercicios);
|
|
|
}
|
|
|
|
|
|
function instrucoes () {
|