537 lines
32 KiB
PHP
537 lines
32 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Operator\Reports;
|
|
|
|
use App\Support\Legacy\Reports\AkademikReports;
|
|
use App\Support\Legacy\Reports\ReportContext;
|
|
use App\Support\Legacy\Reports\ReportResult;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use InvalidArgumentException;
|
|
use Tests\Concerns\FakesLegacyDatabase;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Laporan akademik (KHS, KRS, transkrip, IPK, konversi, mengulang, KKN) dari DB lama tiruan.
|
|
*
|
|
* Prodi 21 (Teknik Informatika) dan 22 (Teknik Sipil), periode 368. Mahasiswa 500 (D1041191001, angkatan 2019),
|
|
* 501 cuti, 502 (2020), 503, 504 (2021), 505 lulus, 506 keluar; 510 dan 511 prodi 22 (2020).
|
|
*/
|
|
class AkademikReportsTest extends TestCase
|
|
{
|
|
use FakesLegacyDatabase;
|
|
use RefreshDatabase;
|
|
|
|
private AkademikReports $reports;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->useLegacyDatabase();
|
|
$this->seedLegacyOverview();
|
|
$this->seedLegacyGrades();
|
|
$this->extendSchema();
|
|
$this->reports = app(AkademikReports::class);
|
|
}
|
|
|
|
private function extendSchema(): void
|
|
{
|
|
$schema = Schema::connection('untan');
|
|
|
|
foreach (['ipk' => 'double', 'skstranskrip' => 'smallInteger', 'skstranskriplulus' => 'smallInteger'] as $column => $type) {
|
|
if (! $schema->hasColumn('t_histori_mahasiswa', $column)) {
|
|
$schema->table('t_histori_mahasiswa', fn (Blueprint $table) => $table->{$type}($column)->nullable());
|
|
}
|
|
}
|
|
|
|
foreach (['nilaihuruf' => 'string', 'nilaimutu' => 'double', 'tanggal' => 'timestamp'] as $column => $type) {
|
|
if (! $schema->hasColumn('t_kst_konversi_log', $column)) {
|
|
$schema->table('t_kst_konversi_log', fn (Blueprint $table) => $table->{$type}($column)->nullable());
|
|
}
|
|
}
|
|
}
|
|
|
|
/** IPK tersimpan periode 368: idmahasiswa => [ipk, SKS transkrip]. */
|
|
private function seedIpk(): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
$db->table('t_histori_mahasiswa')->insert([
|
|
['idmahasiswa' => 504, 'idperiode' => 368, 'stat_akd_akhir' => 1, 'ips' => 0],
|
|
['idmahasiswa' => 506, 'idperiode' => 368, 'stat_akd_akhir' => 1, 'ips' => 3],
|
|
]);
|
|
|
|
foreach ([500 => [3.6, 30], 501 => [2.9, 40], 502 => [1.8, 20], 505 => [3.9, 140], 506 => [3.6, 10], 510 => [2.5, 25], 504 => [0, 0]] as $id => [$ipk, $sks]) {
|
|
$db->table('t_histori_mahasiswa')->where('idmahasiswa', $id)->where('idperiode', 368)
|
|
->update(['ipk' => $ipk, 'skstranskrip' => $sks, 'skstranskriplulus' => max(0, $sks - 2)]);
|
|
}
|
|
}
|
|
|
|
private function context(array $prodi = [21]): ReportContext
|
|
{
|
|
$names = DB::connection('untan')->table('t_bagian')->whereIn('idbagian', $prodi)->pluck('namabagian', 'idbagian')->all();
|
|
|
|
return new ReportContext(1, 'staf', $prodi, $names);
|
|
}
|
|
|
|
private function report(string $slug, array $params = [], ?ReportContext $context = null, int $limit = 100): ReportResult
|
|
{
|
|
return $this->reports->run($slug, $params, $context ?? $this->context(), $limit);
|
|
}
|
|
|
|
/** @return list<string> */
|
|
private function keys(ReportResult $result): array
|
|
{
|
|
return array_column($result->columns, 'key');
|
|
}
|
|
|
|
/** @return list<mixed> */
|
|
private function col(ReportResult $result, string $key): array
|
|
{
|
|
return array_column($result->rows, $key);
|
|
}
|
|
|
|
/** Setiap baris harus memiliki kunci persis sama dengan kolom. */
|
|
private function assertShape(ReportResult $result): void
|
|
{
|
|
foreach ($result->rows as $row) {
|
|
$this->assertSame($this->keys($result), array_keys($row));
|
|
}
|
|
}
|
|
|
|
public function test_slugs_hanya_yang_bersumber(): void
|
|
{
|
|
$this->assertSame([
|
|
'repp_khsmahasiswa', 'repp_krsmahasiswa', 'repp_khsmhskolektif', 'repp_transkrip', 'repp_transkripsmt',
|
|
'repp_nilaikonversi', 'repp_krsmhs', 'repp_rekapkrs', 'repp_distribusikrsmhs', 'repp_mkmengulang',
|
|
'repp_rekapipk', 'repp_ipk', 'repp_ipktertinggi', 'repp_nilaikkn',
|
|
], $this->reports->slugs());
|
|
$this->assertNotContains('repp_transkripobemhs', $this->reports->slugs());
|
|
}
|
|
|
|
public function test_definisi_valid(): void
|
|
{
|
|
foreach ($this->reports->slugs() as $slug) {
|
|
$params = $this->reports->definition($slug, $this->context([21, 22]))['params'];
|
|
$names = array_column($params, 'name');
|
|
|
|
$this->assertSame($names, array_values(array_unique($names)), $slug);
|
|
$this->assertNotContains('tampil', $names, $slug);
|
|
$this->assertNotContains('kop', $names, $slug);
|
|
|
|
foreach ($params as $param) {
|
|
$this->assertContains($param['type'], ['select', 'text', 'number', 'date', 'check'], $slug.'.'.$param['name']);
|
|
$this->assertNotSame('', $param['label']);
|
|
|
|
if ($param['type'] === 'select') {
|
|
$this->assertIsArray($param['options'], $slug.'.'.$param['name']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function test_opsi_berasal_dari_db(): void
|
|
{
|
|
$params = collect($this->reports->definition('repp_rekapipk', $this->context([21, 22]))['params'])->keyBy('name');
|
|
|
|
$this->assertSame([368 => '2020/2021 Ganjil', 366 => '2019/2020 Genap (pendek)', 365 => '2019/2020 Genap', 362 => '2019/2020 Ganjil'], $params['periode']['options']);
|
|
$this->assertSame(368, $params['periode']['default']);
|
|
$this->assertSame([21 => 'Teknik Informatika', 22 => 'Teknik Sipil'], $params['prodi']['options']);
|
|
$this->assertSame([2021 => '2021', 2020 => '2020', 2019 => '2019'], $params['angkatan']['options']);
|
|
$this->assertSame([3 => 'MANDIRI', 1 => 'SNMPTN'], $params['jalur']['options']);
|
|
|
|
$kosong = $this->reports->definition('repp_rekapipk', $this->context([]))['params'];
|
|
$this->assertSame([], collect($kosong)->firstWhere('name', 'periode')['options']);
|
|
}
|
|
|
|
public function test_slug_tak_dikenal_ditolak(): void
|
|
{
|
|
$this->expectException(InvalidArgumentException::class);
|
|
|
|
$this->reports->definition('repp_transkripobemhs', $this->context());
|
|
}
|
|
|
|
public function test_khs_mahasiswa_per_periode(): void
|
|
{
|
|
DB::connection('untan')->table('t_histori_mahasiswa')->where('idmahasiswa', 500)->where('idperiode', 365)->update(['ips' => 1.95]);
|
|
|
|
$result = $this->report('repp_khsmahasiswa', ['periode' => 365]);
|
|
|
|
$this->assertSame(['nim', 'nama', 'kode', 'mk', 'sks', 'kelas', 'nilai', 'huruf', 'bobot', 'ips', 'ipk'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
// Skripsi (tipe 2 tanpa nilai) dan Statistika (batal) tidak ikut; Kalkulus belum terbit.
|
|
$this->assertSame(['IF201', 'IF202', 'IF999'], $this->col($result, 'kode'));
|
|
$this->assertSame(3, $result->total);
|
|
$this->assertSame(['Periode: 2019/2020 Genap', 'Jumlah: 2 mahasiswa, 3 mata kuliah'], $result->summary);
|
|
|
|
$jaringan = $result->rows[0];
|
|
$this->assertSame(['D1041191001', 'Rina Lestari', 3, 78.0, 'B+', 3.25, 1.95], [$jaringan['nim'], $jaringan['nama'], $jaringan['sks'], $jaringan['nilai'], $jaringan['huruf'], $jaringan['bobot'], $jaringan['ips']]);
|
|
|
|
$kalkulus = $result->rows[1];
|
|
$this->assertNull($kalkulus['nilai']);
|
|
$this->assertNull($kalkulus['huruf']);
|
|
$this->assertNull($kalkulus['bobot']);
|
|
}
|
|
|
|
public function test_khs_filter_dan_cakupan_prodi(): void
|
|
{
|
|
$this->assertSame(['D1041191001'], array_unique($this->col($this->report('repp_khsmahasiswa', ['periode' => 365, 'mahasiswa' => 'rina']), 'nim')));
|
|
$this->assertSame(['X501'], array_unique($this->col($this->report('repp_khsmahasiswa', ['periode' => 365, 'angkatan' => 2019, 'mahasiswa' => 'X5']), 'nim')));
|
|
|
|
// Periode 368: prodi 21 hanya 500 dan 502; prodi 22 hanya 510.
|
|
$this->assertSame(['D1041191001', 'X502'], $this->col($this->report('repp_khsmahasiswa', ['periode' => 368]), 'nim'));
|
|
$this->assertSame(['X510'], $this->col($this->report('repp_khsmahasiswa', ['periode' => 368], $this->context([22])), 'nim'));
|
|
|
|
$semua = $this->report('repp_khsmahasiswa', ['periode' => 368], $this->context([21, 22]));
|
|
$this->assertContains('prodi', $this->keys($semua));
|
|
$this->assertSame(['Teknik Informatika', 'Teknik Informatika', 'Teknik Sipil'], $this->col($semua, 'prodi'));
|
|
|
|
// Prodi dipilih menyempit; prodi di luar akun diabaikan (tetap cakupan akun).
|
|
$this->assertSame(['X510'], $this->col($this->report('repp_khsmahasiswa', ['periode' => 368, 'prodi' => 22], $this->context([21, 22])), 'nim'));
|
|
$this->assertSame(['D1041191001', 'X502'], $this->col($this->report('repp_khsmahasiswa', ['periode' => 368, 'prodi' => 99]), 'nim'));
|
|
|
|
$kosong = $this->report('repp_khsmahasiswa', ['periode' => 368], $this->context([]));
|
|
$this->assertSame([], $kosong->rows);
|
|
$this->assertSame(0, $kosong->total);
|
|
}
|
|
|
|
public function test_krs_mahasiswa_dan_status(): void
|
|
{
|
|
$result = $this->report('repp_krsmahasiswa', ['periode' => 368]);
|
|
|
|
$this->assertSame(['nim', 'nama', 'kode', 'mk', 'sks', 'kelas', 'status'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
// 501 membatalkan KRS: tidak muncul. 510 prodi lain.
|
|
$this->assertSame(['D1041191001', 'X502', 'X502'], $this->col($result, 'nim'));
|
|
$this->assertSame(['Menunggu persetujuan', 'Disetujui', 'Disetujui'], $this->col($result, 'status'));
|
|
$this->assertSame(['MK601', 'MK601', 'MK604'], $this->col($result, 'kode'));
|
|
$this->assertSame('Jumlah: 2 mahasiswa, 3 mata kuliah, 6 SKS', $result->summary[1]);
|
|
|
|
$this->assertSame(['X502', 'X502'], $this->col($this->report('repp_krsmahasiswa', ['periode' => 368, 'angkatan' => 2020]), 'nim'));
|
|
$this->assertSame(['X510'], $this->col($this->report('repp_krsmahasiswa', ['periode' => 368], $this->context([22])), 'nim'));
|
|
$this->assertSame([], $this->report('repp_krsmahasiswa', ['periode' => 368], $this->context([]))->rows);
|
|
}
|
|
|
|
public function test_khs_kolektif_ringkasan_per_semester(): void
|
|
{
|
|
$this->seedIpk();
|
|
|
|
$result = $this->report('repp_khsmhskolektif', ['angkatan' => 2019, 'periode' => 368, 'status' => 1]);
|
|
|
|
$this->assertSame(['nim', 'nama', 'periode', 'smt', 'status', 'ips', 'sks_kum', 'sks_lulus', 'ipk'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
$this->assertSame(['D1041191001', 'X506'], $this->col($result, 'nim'));
|
|
$this->assertSame(['2020/2021 Ganjil', 3, 'Aktif', 3.5, 30, 28, 3.6], [
|
|
$result->rows[0]['periode'], $result->rows[0]['smt'], $result->rows[0]['status'], $result->rows[0]['ips'],
|
|
$result->rows[0]['sks_kum'], $result->rows[0]['sks_lulus'], $result->rows[0]['ipk'],
|
|
]);
|
|
|
|
// Tanpa periode: semua semester sampai periode aktif prodi.
|
|
$semua = $this->report('repp_khsmhskolektif', ['angkatan' => 2019]);
|
|
$this->assertSame(['D1041191001', 'D1041191001', 'X501', 'X505', 'X505', 'X506'], $this->col($semua, 'nim'));
|
|
$this->assertSame(6, $semua->total);
|
|
|
|
$this->assertSame([], $this->report('repp_khsmhskolektif', ['angkatan' => 2019], $this->context([22]))->rows);
|
|
$this->assertSame([], $this->report('repp_khsmhskolektif', ['angkatan' => 2019], $this->context([]))->rows);
|
|
$this->assertSame([], $this->report('repp_khsmhskolektif', [])->rows);
|
|
}
|
|
|
|
public function test_transkrip_lulusan(): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
$db->table('t_mahasiswa')->where('idmahasiswa', 500)->update(['stataktif' => 2, 'idperiodewisuda' => 111]);
|
|
$db->table('t_mahasiswa')->where('idmahasiswa', 505)->update(['idperiodewisuda' => 112]);
|
|
$db->table('t_mahasiswa')->insert(['idmahasiswa' => 507, 'nim' => 'X507', 'nama' => 'Mahasiswa 507', 'idprogdi' => 22, 'idangkatan' => 160, 'stataktif' => 2, 'idperiodewisuda' => 111]);
|
|
$db->table('t_periodewisuda')->insert([
|
|
['idperiode' => 111, 'namaperiode' => '2020/2021 Periode I', 'kdperiode' => '20201'],
|
|
['idperiode' => 112, 'namaperiode' => '2020/2021 Periode II', 'kdperiode' => '20202'],
|
|
]);
|
|
|
|
$definition = collect($this->reports->definition('repp_transkrip', $this->context([21, 22]))['params'])->keyBy('name');
|
|
$this->assertSame([112 => '20202 (2020/2021 Periode II)', 111 => '20201 (2020/2021 Periode I)'], $definition['yudisium']['options']);
|
|
|
|
$result = $this->report('repp_transkrip', ['yudisium' => 111]);
|
|
|
|
$this->assertSame(['nim', 'nama', 'smt', 'kode', 'mk', 'sks', 'huruf', 'bobot', 'mutu', 'ket'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
// Nilai terbaik per mata kuliah; Kalkulus belum terbit dan Skripsi/Statistika tidak ikut.
|
|
$this->assertSame(['Algoritma', 'Basis Data', 'Jaringan Komputer', 'Etika Profesi', 'Jumlah'], $this->col($result, 'mk'));
|
|
$this->assertSame(['A', 'B', 'B+', 'C', null], $this->col($result, 'huruf'));
|
|
$this->assertSame(['Lulus', 'Lulus', 'Lulus', 'Tidak lulus', 'IPK 3,07; SKS lulus 8'], $this->col($result, 'ket'));
|
|
$jumlah = $result->rows[count($result->rows) - 1];
|
|
$this->assertSame([11, 33.75], [$jumlah['sks'], $jumlah['mutu']]);
|
|
|
|
// Tanpa filter yudisium: 505 (tanpa nilai) ikut, 507 (prodi 22) tidak.
|
|
$semua = $this->report('repp_transkrip');
|
|
$this->assertSame(['D1041191001', 'X505'], array_values(array_unique($this->col($semua, 'nim'))));
|
|
$this->assertSame('Belum ada nilai yang diterbitkan', $semua->rows[count($semua->rows) - 1]['mk']);
|
|
$this->assertSame(['X507'], array_values(array_unique($this->col($this->report('repp_transkrip', [], $this->context([22])), 'nim'))));
|
|
$this->assertSame([], $this->report('repp_transkrip', [], $this->context([]))->rows);
|
|
$this->assertSame([], $this->report('repp_transkrip', ['mahasiswa' => 'tidak ada'])->rows);
|
|
}
|
|
|
|
public function test_transkrip_sementara_dan_cadangan_t_transkrip(): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
// 503 mahasiswa lama: nilai hanya di t_transkrip (Algoritma B).
|
|
$db->table('t_transkrip')->insert(['idmahasiswa' => 503, 'idmatakuliah' => 1, 'nilaimutu' => 3, 'nilaihuruf' => 'B']);
|
|
|
|
$result = $this->report('repp_transkripsmt', ['angkatan' => 2019, 'status' => 'aktif', 'tidak_lulus' => false]);
|
|
|
|
$this->assertShape($result);
|
|
$this->assertSame(['D1041191001', 'D1041191001', 'D1041191001', 'D1041191001', 'X501', 'X501', 'X503', 'X503'], $this->col($result, 'nim'));
|
|
// MK tidak lulus (Etika Profesi) disembunyikan, tetapi jumlah dan IPK tetap menghitung seluruh mata kuliah.
|
|
$this->assertSame(['Algoritma', 'Basis Data', 'Jaringan Komputer', 'Jumlah'], array_slice($this->col($result, 'mk'), 0, 4));
|
|
$this->assertSame('IPK 3,07; SKS lulus 8', $result->rows[3]['ket']);
|
|
$this->assertSame(['Nilai Mahasiswa Lain', 'Jumlah', 'Algoritma', 'Jumlah'], array_slice($this->col($result, 'mk'), 4));
|
|
$this->assertSame('IPK 3,00; SKS lulus 3', $result->rows[7]['ket']);
|
|
|
|
$lengkap = $this->report('repp_transkripsmt', ['mahasiswa' => 'D1041191001']);
|
|
$this->assertContains('Etika Profesi', $this->col($lengkap, 'mk'));
|
|
|
|
// 505 lulus: tidak termasuk status aktif.
|
|
$this->assertNotContains('X505', $this->col($result, 'nim'));
|
|
$this->assertSame(['X505'], array_values(array_unique($this->col($this->report('repp_transkripsmt', ['status' => 'lulus']), 'nim'))));
|
|
}
|
|
|
|
public function test_nilai_konversi(): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
$db->table('t_kst_konversi_log')->insert([
|
|
['idmahasiswa' => 504, 'idperiode' => 368, 'idmatakuliahlama' => 602, 'idmatakuliahbaru' => 601, 'nilaihuruf' => 'A', 'nilaimutu' => 4, 'tanggal' => '2021-02-14 10:00:00'],
|
|
['idmahasiswa' => 504, 'idperiode' => 368, 'idmatakuliahlama' => 603, 'idmatakuliahbaru' => null, 'nilaihuruf' => 'B', 'nilaimutu' => 3, 'tanggal' => null],
|
|
['idmahasiswa' => 510, 'idperiode' => 368, 'idmatakuliahlama' => 601, 'idmatakuliahbaru' => 602, 'nilaihuruf' => 'C', 'nilaimutu' => 2, 'tanggal' => null],
|
|
]);
|
|
|
|
$result = $this->report('repp_nilaikonversi', ['angkatan' => 2021]);
|
|
|
|
$this->assertSame(['nim', 'nama', 'periode', 'kode_lama', 'mk_lama', 'sks_lama', 'kode', 'mk', 'sks', 'huruf', 'bobot', 'tanggal'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
$this->assertSame(2, $result->total);
|
|
$this->assertSame(['X504', 'Mahasiswa 504', '2020/2021 Ganjil', 'MK602', 'Kelas 602', 2, 'MK601', 'Kelas 601', 2, 'A', 4.0, '14-02-2021'], array_values($result->rows[0]));
|
|
// Mata kuliah konversi tidak tercatat: tampil kosong, bukan karangan.
|
|
$this->assertSame([null, null, null, 'B', 3.0, null], [$result->rows[1]['kode'], $result->rows[1]['mk'], $result->rows[1]['sks'], $result->rows[1]['huruf'], $result->rows[1]['bobot'], $result->rows[1]['tanggal']]);
|
|
$this->assertSame(['Angkatan: 2021', 'Jumlah: 1 mahasiswa, 2 mata kuliah'], $result->summary);
|
|
|
|
// Cakupan prodi: 510 hanya terlihat oleh prodi 22; angkatan lain kosong.
|
|
$this->assertSame([], $this->report('repp_nilaikonversi', ['angkatan' => 2020])->rows);
|
|
$this->assertSame(['X510'], $this->col($this->report('repp_nilaikonversi', ['angkatan' => 2020], $this->context([22])), 'nim'));
|
|
$this->assertSame([], $this->report('repp_nilaikonversi', ['angkatan' => 2021], $this->context([22]))->rows);
|
|
$this->assertSame([], $this->report('repp_nilaikonversi', ['angkatan' => 2021], $this->context([]))->rows);
|
|
$this->assertSame(['X504'], array_unique($this->col($this->report('repp_nilaikonversi', ['angkatan' => 2021, 'mahasiswa' => '504']), 'nim')));
|
|
$this->assertSame([], $this->report('repp_nilaikonversi', ['angkatan' => 2021, 'mahasiswa' => 'rina'])->rows);
|
|
}
|
|
|
|
public function test_status_krs_mahasiswa_aktif(): void
|
|
{
|
|
DB::connection('untan')->table('t_histori_mahasiswa')->insert(['idmahasiswa' => 504, 'idperiode' => 368, 'stat_akd_akhir' => 1]);
|
|
|
|
$result = $this->report('repp_krsmhs', ['periode' => 368]);
|
|
|
|
$this->assertSame(['nim', 'nama', 'angkatan', 'sistem', 'mk', 'sks', 'status'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
// 501 cuti, 505 lulus, 511 tanpa status, 510 prodi lain: hanya yang berstatus aktif di prodi 21.
|
|
$this->assertSame(['D1041191001', 'X502', 'X504'], $this->col($result, 'nim'));
|
|
$this->assertSame(['KRS Diajukan', 'KRS Disetujui', 'Belum Mengisi KRS'], $this->col($result, 'status'));
|
|
$this->assertSame([2019, 2020, 2021], $this->col($result, 'angkatan'));
|
|
$this->assertSame([2, 4, 0], $this->col($result, 'sks'));
|
|
$this->assertSame('Reguler A', $result->rows[0]['sistem']);
|
|
$this->assertSame(3, $result->total);
|
|
|
|
$this->assertSame(['D1041191001'], $this->col($this->report('repp_krsmhs', ['periode' => 368, 'status_krs' => 'diajukan']), 'nim'));
|
|
$this->assertSame(['X502'], $this->col($this->report('repp_krsmhs', ['periode' => 368, 'status_krs' => 'disetujui']), 'nim'));
|
|
$this->assertSame(['X504'], $this->col($this->report('repp_krsmhs', ['periode' => 368, 'status_krs' => 'belum']), 'nim'));
|
|
$this->assertSame(['X502'], $this->col($this->report('repp_krsmhs', ['periode' => 368, 'angkatan' => 2020]), 'nim'));
|
|
$this->assertSame(['X510'], $this->col($this->report('repp_krsmhs', ['periode' => 368], $this->context([22])), 'nim'));
|
|
$this->assertSame([], $this->report('repp_krsmhs', ['periode' => 368], $this->context([]))->rows);
|
|
|
|
// Limit memotong baris, total tetap jumlah sebenarnya.
|
|
$dibatasi = $this->report('repp_krsmhs', ['periode' => 368], null, 2);
|
|
$this->assertCount(2, $dibatasi->rows);
|
|
$this->assertSame(3, $dibatasi->total);
|
|
$this->assertTrue($dibatasi->truncated());
|
|
}
|
|
|
|
public function test_rekap_krs_per_prodi_dan_angkatan(): void
|
|
{
|
|
DB::connection('untan')->table('t_histori_mahasiswa')->insert(['idmahasiswa' => 504, 'idperiode' => 368, 'stat_akd_akhir' => 1]);
|
|
|
|
$result = $this->report('repp_rekapkrs', ['periode' => 368], $this->context([21, 22]));
|
|
|
|
$this->assertSame(['prodi', 'angkatan', 'aktif', 'belum', 'diajukan', 'disetujui', 'sks', 'rata'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
$this->assertSame([
|
|
['Teknik Informatika', 2021, 1, 1, 0, 0, 0, null],
|
|
['Teknik Informatika', 2020, 1, 0, 0, 1, 4, 4.0],
|
|
['Teknik Informatika', 2019, 1, 0, 1, 0, 2, 2.0],
|
|
['Teknik Sipil', 2020, 1, 0, 0, 1, 2, 2.0],
|
|
], array_map('array_values', $result->rows));
|
|
$this->assertSame(4, $result->total);
|
|
$this->assertSame('Jumlah: 4 mahasiswa aktif, 1 belum mengisi KRS', $result->summary[1]);
|
|
|
|
$this->assertSame(['Teknik Sipil'], array_unique($this->col($this->report('repp_rekapkrs', ['periode' => 368, 'prodi' => 22], $this->context([21, 22])), 'prodi')));
|
|
$this->assertSame(['Teknik Informatika'], array_unique($this->col($this->report('repp_rekapkrs', ['periode' => 368]), 'prodi')));
|
|
$this->assertSame([], $this->report('repp_rekapkrs', ['periode' => 368], $this->context([]))->rows);
|
|
}
|
|
|
|
public function test_distribusi_sks_krs(): void
|
|
{
|
|
DB::connection('untan')->table('t_histori_mahasiswa')->insert(['idmahasiswa' => 504, 'idperiode' => 368, 'stat_akd_akhir' => 1]);
|
|
|
|
$result = $this->report('repp_distribusikrsmhs', ['periode' => 368]);
|
|
|
|
$this->assertSame(['sks', 'jumlah', 'persen'], $this->keys($result));
|
|
$this->assertSame([[0, 1, 33.3], [2, 1, 33.3], [4, 1, 33.3]], array_map('array_values', $result->rows));
|
|
$this->assertSame('Jumlah: 3 mahasiswa aktif, rata-rata 2,00 SKS', $result->summary[1]);
|
|
|
|
$this->assertSame([[4, 1, 100.0]], array_map('array_values', $this->report('repp_distribusikrsmhs', ['periode' => 368, 'angkatan' => 2020])->rows));
|
|
$this->assertSame([[2, 1, 100.0]], array_map('array_values', $this->report('repp_distribusikrsmhs', ['periode' => 368], $this->context([22]))->rows));
|
|
$this->assertSame([], $this->report('repp_distribusikrsmhs', ['periode' => 368], $this->context([]))->rows);
|
|
}
|
|
|
|
public function test_mata_kuliah_mengulang(): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
$db->table('t_kst')->insert([
|
|
// 500 mengulang Algoritma (sebelumnya A pada 362) dan Skripsi (tugas akhir: tidak dihitung).
|
|
['idmahasiswa' => 500, 'idjadwal' => 1, 'idmatakuliah' => 1, 'idperiode' => 368, 'nilaihuruf' => null, 'stat' => 1],
|
|
['idmahasiswa' => 500, 'idjadwal' => 5, 'idmatakuliah' => 5, 'idperiode' => 368, 'nilaihuruf' => null, 'stat' => 1],
|
|
// 510 (prodi 22) mengulang MK 602 di periode 371.
|
|
['idmahasiswa' => 510, 'idjadwal' => 602, 'idmatakuliah' => 602, 'idperiode' => 371, 'nilaihuruf' => null, 'stat' => 1],
|
|
]);
|
|
$db->table('t_kst')->where('idmahasiswa', 510)->where('idperiode', 368)->update(['nilaihuruf' => 'D']);
|
|
|
|
$result = $this->report('repp_mkmengulang', ['periode' => 368]);
|
|
|
|
$this->assertSame(['nim', 'nama', 'angkatan', 'kode', 'mk', 'sks', 'kelas', 'ke', 'lalu'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
$this->assertSame([['D1041191001', 'IF101', 'Algoritma', 2, 'A']], array_map(fn (array $r): array => [$r['nim'], $r['kode'], $r['mk'], $r['ke'], $r['lalu']], $result->rows));
|
|
$this->assertSame(1, $result->total);
|
|
|
|
$this->assertSame([], $this->report('repp_mkmengulang', ['periode' => 371])->rows);
|
|
$sipil = $this->report('repp_mkmengulang', ['periode' => 371], $this->context([22]));
|
|
$this->assertSame([['X510', 'MK602', 2, 'D']], array_map(fn (array $r): array => [$r['nim'], $r['kode'], $r['ke'], $r['lalu']], $sipil->rows));
|
|
$this->assertSame([], $this->report('repp_mkmengulang', ['periode' => 368], $this->context([]))->rows);
|
|
}
|
|
|
|
public function test_rekap_ipk(): void
|
|
{
|
|
$this->seedIpk();
|
|
|
|
$result = $this->report('repp_rekapipk', ['periode' => 368], $this->context([21, 22]));
|
|
|
|
$this->assertSame(['prodi', 'angkatan', 'jumlah', 'rata', 'min', 'maks', 'k1', 'k2', 'k3', 'k4'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
// 504 (SKS 0) dan 511 (tanpa IPK) tidak dihitung.
|
|
$this->assertSame([
|
|
['Teknik Informatika', 2020, 1, 1.8, 1.8, 1.8, 1, 0, 0, 0],
|
|
['Teknik Informatika', 2019, 4, 3.5, 2.9, 3.9, 0, 0, 1, 3],
|
|
['Teknik Sipil', 2020, 1, 2.5, 2.5, 2.5, 0, 1, 0, 0],
|
|
], array_map('array_values', $result->rows));
|
|
$this->assertSame('Jumlah: 6 mahasiswa, rata-rata IPK 3,05', $result->summary[1]);
|
|
|
|
$aktif = $this->report('repp_rekapipk', ['periode' => 368, 'status' => 1], $this->context([21, 22]));
|
|
$this->assertSame([1, 2, 1], $this->col($aktif, 'jumlah'));
|
|
|
|
DB::connection('untan')->table('t_progdi')->insert([['idbagian' => 21, 'idjenjang' => 2], ['idbagian' => 22, 'idjenjang' => 1]]);
|
|
$this->assertSame([1 => 'D3', 2 => 'S1'], collect($this->reports->definition('repp_rekapipk', $this->context([21, 22]))['params'])->firstWhere('name', 'jenjang')['options']);
|
|
$this->assertSame(['Teknik Sipil'], $this->col($this->report('repp_rekapipk', ['periode' => 368, 'jenjang' => 1], $this->context([21, 22])), 'prodi'));
|
|
$this->assertSame([2020], $this->col($this->report('repp_rekapipk', ['periode' => 368, 'angkatan' => 2020, 'prodi' => 21], $this->context([21, 22])), 'angkatan'));
|
|
$this->assertSame([2020], $this->col($this->report('repp_rekapipk', ['periode' => 368, 'jalur' => 3]), 'angkatan'));
|
|
|
|
DB::connection('untan')->table('t_kurikulum')->insert(['idkurikulum' => 900, 'idprogdi' => 21, 'idprogram' => 1, 'namakurikulum' => 'Kurikulum 2020']);
|
|
DB::connection('untan')->table('t_mahasiswa')->where('idmahasiswa', 500)->update(['idkurikulum' => 900]);
|
|
$this->assertSame([900 => 'Kurikulum 2020'], collect($this->reports->definition('repp_rekapipk', $this->context())['params'])->firstWhere('name', 'kurikulum')['options']);
|
|
$this->assertSame([1], $this->col($this->report('repp_rekapipk', ['periode' => 368, 'kurikulum' => 900]), 'jumlah'));
|
|
|
|
$this->assertSame([], $this->report('repp_rekapipk', ['periode' => 368], $this->context([]))->rows);
|
|
}
|
|
|
|
public function test_daftar_ipk_dan_cakupan(): void
|
|
{
|
|
$this->seedIpk();
|
|
|
|
$result = $this->report('repp_ipk', ['periode' => 368, 'prodi' => 21]);
|
|
|
|
$this->assertSame(['nim', 'nama', 'angkatan', 'sistem', 'jalur', 'sks', 'ips', 'ipk'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
$this->assertSame(['D1041191001', 'X501', 'X502', 'X505', 'X506'], $this->col($result, 'nim'));
|
|
$this->assertSame(['Reguler A', 'SNMPTN'], [$result->rows[0]['sistem'], $result->rows[0]['jalur']]);
|
|
$this->assertSame([3.5, 30, 3.6], [$result->rows[0]['ips'], $result->rows[0]['sks'], $result->rows[0]['ipk']]);
|
|
|
|
$this->assertSame(['X502'], $this->col($this->report('repp_ipk', ['periode' => 368, 'ipk_maks' => '2,0']), 'nim'));
|
|
$this->assertSame(['D1041191001', 'X505', 'X506'], $this->col($this->report('repp_ipk', ['periode' => 368, 'ipk_min' => 3.5]), 'nim'));
|
|
$this->assertSame(['X501'], $this->col($this->report('repp_ipk', ['periode' => 368, 'ipk_min' => 2, 'ipk_maks' => 3]), 'nim'));
|
|
$this->assertSame(['X505'], $this->col($this->report('repp_ipk', ['periode' => 368, 'status' => 3]), 'nim'));
|
|
$this->assertSame(['X502'], $this->col($this->report('repp_ipk', ['periode' => 368, 'angkatan' => 2020]), 'nim'));
|
|
$this->assertSame(['X502'], $this->col($this->report('repp_ipk', ['periode' => 368, 'jalur' => 3]), 'nim'));
|
|
|
|
// Prodi dipilih dari akun dengan dua prodi; prodi lain tidak terlihat.
|
|
$this->assertSame(['X510'], $this->col($this->report('repp_ipk', ['periode' => 368, 'prodi' => 22], $this->context([21, 22])), 'nim'));
|
|
$this->assertNotContains('X510', $this->col($this->report('repp_ipk', ['periode' => 368, 'prodi' => 22]), 'nim'));
|
|
$this->assertSame([], $this->report('repp_ipk', ['periode' => 368], $this->context([]))->rows);
|
|
|
|
// Limit dan total.
|
|
$dibatasi = $this->report('repp_ipk', ['periode' => 368], null, 2);
|
|
$this->assertSame(['D1041191001', 'X501'], $this->col($dibatasi, 'nim'));
|
|
$this->assertSame(5, $dibatasi->total);
|
|
$this->assertTrue($dibatasi->truncated());
|
|
}
|
|
|
|
public function test_peringkat_ipk(): void
|
|
{
|
|
$this->seedIpk();
|
|
|
|
$result = $this->report('repp_ipktertinggi', ['periode' => 368]);
|
|
|
|
$this->assertSame(['rank', 'nim', 'nama', 'angkatan', 'sistem', 'sks', 'ips', 'ipk'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
// IPK sama (500 dan 506) berbagi peringkat; urutan berikutnya melompat.
|
|
$this->assertSame(['X505', 'D1041191001', 'X506', 'X501', 'X502'], $this->col($result, 'nim'));
|
|
$this->assertSame([1, 2, 2, 4, 5], $this->col($result, 'rank'));
|
|
$this->assertSame([3.9, 3.6, 3.6, 2.9, 1.8], $this->col($result, 'ipk'));
|
|
|
|
$this->assertSame(['X505'], $this->col($this->report('repp_ipktertinggi', ['periode' => 368, 'status' => 3]), 'nim'));
|
|
$this->assertSame(['X510'], $this->col($this->report('repp_ipktertinggi', ['periode' => 368], $this->context([22])), 'nim'));
|
|
$this->assertSame([], $this->report('repp_ipktertinggi', ['periode' => 368], $this->context([]))->rows);
|
|
|
|
$teratas = $this->report('repp_ipktertinggi', ['periode' => 368], null, 1);
|
|
$this->assertSame(['X505'], $this->col($teratas, 'nim'));
|
|
$this->assertSame(5, $teratas->total);
|
|
}
|
|
|
|
public function test_nilai_kkn(): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
$db->table('t_matakuliah')->insert([
|
|
['idmatakuliah' => 800, 'kodemk' => 'UN800', 'namamk' => 'Kuliah Kerja Nyata (KKN)', 'sks' => 3, 'tipe' => 0],
|
|
['idmatakuliah' => 801, 'kodemk' => 'UN801', 'namamk' => 'Kuliah Kerja Mahasiswa', 'sks' => 2, 'tipe' => 0],
|
|
]);
|
|
$db->table('t_jadwal')->insert([
|
|
['idjadwal' => 800, 'idmatakuliah' => 800, 'idperiode' => 368, 'flag_cetak' => true],
|
|
['idjadwal' => 801, 'idmatakuliah' => 801, 'idperiode' => 365, 'flag_cetak' => false],
|
|
]);
|
|
$db->table('t_kst')->insert([
|
|
['idmahasiswa' => 500, 'idjadwal' => 800, 'idmatakuliah' => 800, 'idperiode' => 368, 'nilaitotal' => 85, 'nilaimutu' => 4, 'nilaihuruf' => 'A', 'stat' => 1],
|
|
['idmahasiswa' => 502, 'idjadwal' => 801, 'idmatakuliah' => 801, 'idperiode' => 365, 'nilaitotal' => 70, 'nilaimutu' => 3, 'nilaihuruf' => 'B', 'stat' => 1],
|
|
['idmahasiswa' => 510, 'idjadwal' => 800, 'idmatakuliah' => 800, 'idperiode' => 368, 'nilaitotal' => 60, 'nilaimutu' => 2, 'nilaihuruf' => 'C', 'stat' => 1],
|
|
]);
|
|
|
|
$result = $this->report('repp_nilaikkn');
|
|
|
|
$this->assertSame(['nim', 'nama', 'angkatan', 'periode', 'kode', 'mk', 'sks', 'nilai', 'huruf', 'bobot'], $this->keys($result));
|
|
$this->assertShape($result);
|
|
$this->assertSame(['D1041191001', 'X502'], $this->col($result, 'nim'));
|
|
$this->assertSame(['2020/2021 Ganjil', 85.0, 'A', 4.0], [$result->rows[0]['periode'], $result->rows[0]['nilai'], $result->rows[0]['huruf'], $result->rows[0]['bobot']]);
|
|
// Nilai belum terbit tidak ditampilkan.
|
|
$this->assertSame([null, null, null], [$result->rows[1]['nilai'], $result->rows[1]['huruf'], $result->rows[1]['bobot']]);
|
|
$this->assertSame(2, $result->total);
|
|
|
|
$this->assertSame(['D1041191001'], $this->col($this->report('repp_nilaikkn', ['periode' => 368]), 'nim'));
|
|
$this->assertSame(['X510'], $this->col($this->report('repp_nilaikkn', [], $this->context([22])), 'nim'));
|
|
$this->assertSame([], $this->report('repp_nilaikkn', [], $this->context([]))->rows);
|
|
}
|
|
}
|