Rangking nilai di codeigniter

saya mau membuat rangking nilai dari hasil penjumlahan seluruh nilai yang diperoleh

<?php
$uri = $this->uri->segment_array();
if(isset($uri[3])){
    if($uri[3] == 'review_rapor'){
        $border = '';
        $class = 'table table-bordered';
    } else {
        $border = 'border="1"';
        $class = 'table';
    }
}
$data['s'] = $this->siswa->get($siswa_id);
$sekolah = $this->sekolah->get($sekolah_id);
$setting = $this->settings->get(1);
$data['rombel'] = $this->rombongan_belajar->get($rombel_id);
$ajaran = $this->semester->get($ajaran_id);
$data['mapel_a'] = $this->pembelajaran->with('mata_pelajaran')->find_all("kelompok_id = 6 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_id IS NOT NULL OR kelompok_id = 6 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_pengajar_id IS NOT NULL", '*','no_urut ASC');
foreach($data['mapel_a'] as $mapela){
	$mapel_a_id[] = $mapela->mata_pelajaran_id;
}
if(isset($mapel_a_id)){
	$mapel_agama = array(100011070, 100012050, 100013010, 100014140, 100015010, 100016010);
	$data['mapel_a'] = filter_agama_mapel($ajaran_id,$mapel_agama, $mapel_a_id,$data['s']->agama_id);
}
//test($mapel_a);
$data['mapel_b'] = $this->pembelajaran->with('mata_pelajaran')->find_all("kelompok_id = 7 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_id IS NOT NULL OR kelompok_id = 7 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_pengajar_id IS NOT NULL", '*','no_urut ASC');
$data['mapel_c1'] = $this->pembelajaran->with('mata_pelajaran')->find_all("kelompok_id = 8 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_id IS NOT NULL OR kelompok_id = 8 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_pengajar_id IS NOT NULL", '*','no_urut ASC');
$data['mapel_c2'] = $this->pembelajaran->with('mata_pelajaran')->find_all("kelompok_id = 9 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_id IS NOT NULL OR kelompok_id = 9 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_pengajar_id IS NOT NULL", '*','no_urut ASC');
$data['mapel_c3'] = $this->pembelajaran->with('mata_pelajaran')->find_all("kelompok_id = 10 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_id IS NOT NULL OR kelompok_id = 10 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_pengajar_id IS NOT NULL", '*','no_urut ASC');
$data['mapel_tambahan'] = $this->pembelajaran->with('mata_pelajaran')->find_all("kelompok_id = 99 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_id IS NOT NULL OR kelompok_id = 99 AND semester_id =  $ajaran_id AND  rombongan_belajar_id = '$rombel_id' AND guru_pengajar_id IS NOT NULL", '*','no_urut ASC');
$data['nama_kelompok_a'] = $this->kelompok->get(6);
$data['nama_kelompok_b'] = $this->kelompok->get(7);
$data['nama_kelompok_c1'] = $this->kelompok->get(8);
$data['nama_kelompok_c2'] = $this->kelompok->get(9);
$data['nama_kelompok_c3'] = $this->kelompok->get(10);
$data['check_2018'] = $check_2018;
if($check_2018){
	$judul_rapor = 'A.  Nilai Akademik';
} else {
	$judul_rapor = 'C.  Pengetahuan dan Keterampilan';
}
?>
<style type="text/css">
   .tiga {
   font-size: 12px;
   }
   .ttd {
   font-size: 13px;
   }
</style>
<div class="strong"><?php echo $judul_rapor; ?></div>
<table <?php echo $border; ?> class="<?php echo $class; ?>">
    <thead>
	<?php if($check_2018){?>
		<tr>
			<th class="tiga" style="vertical-align:middle;width: 2px;" align="center">No</th>
			<th class="tiga" style="vertical-align:middle;width: 200px;" align="center" class="text-center">Mata Pelajaran</th>
			<th align="center" class="text-center tiga">Pengetahuan</th>
			<th align="center" class="text-center tiga">Keterampilan</th>
			<th align="center" class="text-center tiga">Nilai Akhir</th>
			<th align="center" class="text-center tiga">Predikat</th>
		</tr>
	<?php } else { ?>
		<tr>
			<th class="tiga" style="vertical-align:middle;width: 2px;" align="center" rowspan="2">No</th>
			<th class="tiga" style="vertical-align:middle;width: 200px;" rowspan="2" align="center" class="text-center">Mata Pelajaran</th>
			<th colspan="4" align="center" class="text-center tiga">Pengetahuan</th>
			<th colspan="4" align="center" class="text-center tiga">Keterampilan</th>
		</tr>
		<tr>
			<th align="center" style="width:10px;" class="text-center tiga">KKM</th>
			<th align="center" style="width:10px;" class="text-center tiga">Angka</th>
			<th align="center" style="width:10px;" class="text-center tiga">Predikat</th>
			<th align="center" style="width:150px;" class="text-center tiga">Deskripsi</th>
			<th align="center" style="width:10px;" class="text-center tiga">KKM</th>
			<th align="center" style="width:10px;" class="text-center tiga">Angka</th>
			<th align="center" style="width:10px;" class="text-center tiga">Predikat</th>
			<th align="center" style="width:150px;" class="text-center tiga">Deskripsi</th>
		</tr>
  	<?php } ?>
    </thead>
    <tbody>
		<?php
		$count_a = count($data['mapel_a']);
		$count_b = count($data['mapel_b']);
		$count_c1 = 0;
		$count_c2 = 0;
		$count_c3 = 0;
		$this->load->view('backend/cetak/2017/a',$data);
		$data['i'] = $count_a + 1;
		$this->load->view('backend/cetak/2017/b',$data);
		//if($data['rombel']->tingkat != 12){
		$count_c1 = count($data['mapel_c1']);
		$count_c2 = count($data['mapel_c2']);
		$data['i'] = $count_a + $count_b + 1;
		$this->load->view('backend/cetak/2017/c1',$data);
		$data['i'] = $count_a + $count_b + $count_c1 + 1;
		$this->load->view('backend/cetak/2017/c2',$data);
		//}
		//if($data['rombel']->tingkat != 10){
		$count_c3 = count($data['mapel_c3']);
		$data['i'] = $count_a + $count_b + $count_c1 + $count_c2 + 1;
		$this->load->view('backend/cetak/2017/c3',$data);
		//}
		$data['i'] = $count_a + $count_b + $count_c1 + $count_c2 + $count_c3 + 1;
		$this->load->view('backend/cetak/2017/m',$data);
		?>
		<tr>
		<?php
		$total_nilai = 0;
		$jumlah_mapel = 0;
			foreach($data_mapel as $key=>$mapel){
					$nilai_value1	= get_nilai_akhir2_siswa($ajaran_id, $kompetensi_id=1, $rombel_id, $mapel->mata_pelajaran_id, $siswa_id);
					$nilai_value2	= get_nilai_akhir2_siswa($ajaran_id, $kompetensi_id=2, $rombel_id, $mapel->mata_pelajaran_id, $siswa_id);
					$total_nilai += $nilai_value1 + $nilai_value2;
					if($nilai_value1){
						$jumlah_mapel++;
					}
					if($nilai_value2){
						$jumlah_mapel++;
					}
				}
		$rata_nilai_rapor = $total_nilai / $jumlah_mapel;
		$jumlah_siswa_rombel = get_jumlah_siswa($rombel_id);
		$value = array($total_nilai);
		$ranking = array();
		foreach ($value as $k => $v){
    		array_push($ranking, $v);
		}

		?>
			<td height="30px;" colspan="5" align="center" class="strong tiga">Total Nilai (Pengetahuan + Keterampilan)</td>
			<td colspan="5" align="center" class="strong tiga" ><?php echo number_format($total_nilai,0,',','.'); ?></td>
		</tr>
		<tr>
			<td height="30px;" colspan="5" align="center" class="strong tiga" >Nilai Rata-rata</td>
			<td colspan="5" align="center" class="strong tiga" ><?php echo number_format($rata_nilai_rapor,0,',','.'); ?></td>
		</tr>
		<tr>
			<td height="40px;" colspan="5" align="center" class="strong tiga" >Peringkat</td>
////////////////saya mau memberikan rangking disini
<td colspan="5" align="center" class="strong tiga" ><?php echo $ranking[0], "  dari  ",$jumlah_siswa_rombel; ?></td>
		</tr>
	</tbody>
</table>

avatar Genay
@Genay

1 Kontribusi 0 Poin

Dipost 4 tahun yang lalu

Tanggapan

pertanyaan kamu kurang jelas, kamu hanya menaruh kode yang banyak yang orang lain tidak mengerti konteksnya, jadi sulit untuk dibantu. baca aturan main cara bertanya yang mudah dimengerti

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban