diff --git a/app/Http/Controllers/PHP/PHPController.php b/app/Http/Controllers/PHP/PHPController.php index 68b8dc1..c53a004 100644 --- a/app/Http/Controllers/PHP/PHPController.php +++ b/app/Http/Controllers/PHP/PHPController.php @@ -279,7 +279,7 @@ function unittesting(){ $pa = "vendor\bin\phpunit -c $path_test --filter HomepageLayoutTest::$unitesting_run"; $path = base_path($pa); $output = shell_exec($path); - echo "
$pa"; + //echo "
$pa"; $sql = DB::select("SELECT * FROM php_testing_rule WHERE testing_name = '$testing_number_one'"); $row = $sql[0]; @@ -288,8 +288,6 @@ function unittesting(){ $test = str_replace(array("\r\n","\r","\n"," "),"",$html); $result_test = htmlspecialchars($test); - - $string = json_encode($output); $text = str_replace("\n", ' ', $output); @@ -299,7 +297,7 @@ function unittesting(){ $pattern = '/Codeception PHP Testing Framework v([\d.]+)/'; // Define patterns to extract relevant information - $pattern_phpunit_version = '/Codeception\s+(\d+\.\d+\.\d+)/'; + $pattern_phpunit_version = '/PHPUnit\s+([\d.]+)\s+by/'; $pattern_php_runtime = '/Runtime:\s+PHP\s+([\d.]+)/'; $pattern_configuration = '/Configuration:\s+(.+)/'; $pattern_failure_count = '/There was (\d+) failure/'; @@ -323,7 +321,7 @@ function unittesting(){ preg_match($pattern_failures, $text, $matches_failures); preg_match($pattern, $cleaned, $matches); // Extracted information - $phpunit_version = isset($matches[1]) ? $matches[1] : "Not founds"; + $phpunit_version = $matches_phpunit_version[1] ?? 'Not found'; $phpunit_stat = isset($matches_ok[0]) ? $matches_ok[0] : "Not found"; $phpunit_time = isset($matches_time[1]) ? $matches_time[1] : "Not found"; $phpunit_memory = isset($matches_memory[0]) ? $matches_memory[0] : "Not found"; diff --git a/app/Http/Controllers/PHP/Student/WelcomeController.php b/app/Http/Controllers/PHP/Student/WelcomeController.php index dc0bdbb..0cfe00f 100644 --- a/app/Http/Controllers/PHP/Student/WelcomeController.php +++ b/app/Http/Controllers/PHP/Student/WelcomeController.php @@ -51,26 +51,71 @@ function result_test(){ "); $row = $sql[0]; - $html2 = htmlspecialchars($row->output); + $html2 = htmlspecialchars($row->ket); $test = str_replace(array("\r\n","\r","\n"," "),"",$html2); $result_content2 = str_replace(array("\r\n","\r"," "),"", $test); - $studentFile = storage_path('app/public/uploads/Amal Dermawan Udjir/GuideA2.php'); - ob_start(); - include $studentFile; // Jalankan file PHP siswa - $studentOutput = ob_get_clean(); // Tangkap hasil output yang dihasilkan oleh kode siswa - $result_content = str_replace(array("\r\n","\r"," "),"", $studentOutput); + /* $actual = storage_path("app/private/{$username}/{$userfile}"); $php_output = shell_exec("PHP $actual 2>&1"); $test = str_replace(array("\r\n","\r","\n"," "),"",highlight_string($php_output)); */ return view('php.student.task.result_submssion_task',[ - 'result_up' => $result_content, + 'result_up' => $html2, ]); // echo "$value == $sess_name"; + } + function result_test_output(){ + $uname = DB::select("SELECT * FROM users + WHERE name COLLATE utf8mb4_general_ci IN (SELECT userid FROM php_user_submits) "); + + if (!empty($uname)) { + $firstUser = reset($uname); // Get the first element of the array + $sess_name = isset($firstUser->name) ? $firstUser->name : ''; // Access the 'name' property of the first user + } + + + $task = DB::table('php_submits_submission')->where('username', "$sess_name")->first(); + $username = $task->username; + + $sql = DB::select("SELECT + * + FROM + php_submits_submission a + LEFT JOIN php_testing_rule b ON a.testing_type = b.testing_name + WHERE + a.username COLLATE utf8mb4_general_ci = '$username' + ORDER BY + a.id DESC + LIMIT 1; + + "); + $row = $sql[0]; + $userfile = $row->userfile; + $ket = htmlspecialchars($row->ket); + $html2 = htmlspecialchars($row->output); + $test = str_replace(array("\r\n","\r","\n"," "),"",$html2); + $result_content2 = str_replace(array("\r\n","\r"," "),"", $test); + + $studentFile = storage_path("app/public/uploads/$username/$userfile"); + //$studentFile = storage_path("app/public/uploads/$val/GuideA1.php"); + + ob_start(); + include ($studentFile); + $studentOutput = ob_get_clean(); + + + $result_content = str_replace(array("\r\n", "\r", "\n", " "), "", $studentOutput); + + return view('php.student.task.result_submssion_task', [ + 'result_up' => $result_content, + ]); + ob_end_clean(); + // echo "$value == $sess_name"; + } function get_session(){ if (Auth::check()) { diff --git a/phpunit.xml b/phpunit.xml index f112c0c..5c8fbca 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -18,6 +18,9 @@