Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // current time
- $mtime = microtime();
- // split seconds and microseconds
- $mtime = explode(" ",$mtime);
- // create a single value for statr time
- $mtime = $mtime[1] + $mtime[0];
- $tstart = $mtime;
- include_once "include/koneksi.php";
- $id_mp = $_REQUEST['id_mp'];
- $nama_mp = mysql_result(mysql_query("SELECT nama_mp FROM mapel WHERE id_mp='".$id_mp."'"),0);
- //ambil data ujian pada id_mp ini sebagai header
- $sql_head = "SELECT id_ujian,nama_ujian FROM ujian where id_mp='".$id_mp."'";
- $sql_head_exe = mysql_query($sql_head);
- $head_id_ujian = array();
- $nama_ujian=array();
- $sql_nilai='';
- while($head = mysql_fetch_assoc($sql_head_exe)){
- array_push($head_id_ujian,$head['id_ujian']);
- $sql_nilai.="SUM(IF(d.id_ujian=".$head['id_ujian'].",d.nilai,0)) AS nilai_".$head['id_ujian'].",";
- array_push($nama_ujian,$head['nama_ujian']);
- }
- ?>
- <div style="width:80%;margin:0 auto" class="daftar_pelajaran">
- <fieldset>
- <legend>Daftar Nilai Ujian Mata Pelajaran <?php echo ucwords($nama_mp) ?></legend>
- <div style="margin-bottom:10px"><span onclick="download_ini()" class="tombol">Download as xls</span></div>
- <table class='listing' cellpadding='0' cellspacing='0' align='center'>
- <thead>
- <tr>
- <th>No</th><th>NIS</th><th>Nama</th><th><?php echo implode("</th><th>",$nama_ujian);?></th><th>Rerata</th><th>Aksi</th>
- </tr>
- </thead>
- <tbody>
- <?php
- if(count($head_id_ujian) > 0){
- $sql="SELECT
- a.nis,
- a.nama,"
- .$sql_nilai
- ."SUM(IF(ISNULL(d.nilai),0,d.nilai))/".count($head_id_ujian)." as rerata
- FROM siswa a
- LEFT JOIN (
- SELECT b.*
- FROM nilai b
- LEFT JOIN ujian c ON b.id_ujian=c.id_ujian
- WHERE c.id_mp='".$id_mp."'
- ) d ON a.nis=d.id_user
- GROUP BY a.nis
- ORDER BY rerata DESC";
- $result = mysql_query($sql);
- $no=1;
- while($data = mysql_fetch_assoc($result)){
- echo "<tr>";
- echo "<td>".$no++."</td>";
- echo "<td class='nis'>".$data['nis']."</td>";
- echo "<td>".$data['nama']."</td>";
- for($i = 0;$i < count($head_id_ujian); $i++){
- echo "<td class='nilai' title='".$head_id_ujian[$i]."'>"
- .(empty($data['nilai_'.$head_id_ujian[$i]])?"--":number_format($data['nilai_'.$head_id_ujian[$i]],1))
- ."</td>";
- }
- echo "<td>".number_format($data['rerata'],3)."</td>";
- echo "<td><span class='tombol_mini edit' onclick='edit_nilai(this)'>Nilai</span></td>";
- echo "</tr>";
- }
- }
- else {
- echo "<tr><td colspan='5'>Belum ada ujian yang dibuat</td></tr>";
- }
- ?>
- </tbody>
- </table>
- <div style='color:#1717BF;font-size:90%;font-weight:bolder;font-style:italic'>--- berarti belum dikerjakan</div>
- <?php
- // current time
- $mtime = microtime();
- // split seconds and microseconds
- $mtime = explode(" ",$mtime);
- // create a single value for statr time
- $mtime = $mtime[1] + $mtime[0];
- $tend = $mtime;
- // hitung waktu eksekusi
- $totaltime = ($tend - $tstart);
- // Output the result
- printf ("This page was generated in %f seconds.", $totaltime);
- ?>
- <div class="kembali" onclick="kembali_lagi()">Kembali</div>
- <script >
- function kembali_lagi(){
- $("#content").html(info_loading).load("daftar_nilai_mp.php");
- }
- function download_ini(){
- var id_mp = "<?php echo $id_mp ?>";
- window.open("daftar_nilai_ujian_xls.php?id_mp="+id_mp);
- }
- function edit_nilai(elm){
- var tmb_reset = "<span style='margin-left:5px' class='hapus' onclick='reset_nilai(this)'></span>";
- $(elm).parent().parent().find("td.nilai").each(function(){
- if($(this).text() != "--"){
- $(tmb_reset).appendTo(this);
- }
- })
- }
- function reset_nilai(elm){
- var nis = $(elm).parent().parent().find("td.nis").eq(0).text();
- var id_ujian = $(elm).parent().attr("title");
- // hapus nilai siswa pada ujian tersebut
- var url = "hapus_nilai_ujian.php";
- $.post(url,{nis:nis,id_ujian:id_ujian},function(hasil){
- if(hasil == 1){
- $(elm).parent().css({"background":"#BBEEBB"}).text("---");
- }
- else {
- alert("gagal dihapus .......");
- }
- })
- }
- </script>
- <style>
- .hapus:hover{
- cursor:pointer;
- }
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement