public function overwriteForm($return, $returnfull)
 {
     $return = parent::overwriteForm($return, $returnfull);
     $p = new QuizUlangan();
     //$p->default_read_coloms = "ID,post_title";
     $arrPage = $p->getAll();
     $arrNe = array();
     foreach ($arrPage as $pp) {
         $arrNe[$pp->ulangan_id] = $pp->ulangan_id . " - " . $pp->ulangan_name;
     }
     $ans = new QuizAnswer();
     $arrAns = $ans->getWhere('answer_qid = ' . $this->qid);
     //$ans->getAll();// $ans->getWhere('answer_qid = '.$this->qid);
     $arrNe2 = array();
     foreach ($arrAns as $pp) {
         $arrNe2[$pp->answer_id] = $pp->answer_id . " - " . $pp->answer_text;
     }
     //pr($arrAns);
     $return['q_image'] = new \Leap\View\InputFoto("foto", "q_image", $this->q_image);
     $return['q_aktif'] = new Leap\View\InputSelect($this->arrayYesNO, "q_aktif", "q_aktif", $this->q_aktif);
     $return['q_ulangan_id'] = new Leap\View\InputSelect($arrNe, "q_ulangan_id", "q_ulangan_id", $this->q_ulangan_id);
     $return['q_correct_answer_id'] = new Leap\View\InputSelect($arrNe2, "q_correct_answer_id", "q_correct_answer_id", $this->q_correct_answer_id);
     return $return;
 }
Example #2
0
    function tk($args)
    {
        list($lvl, $name) = $args;
        //$lvl = $_GET['lvl'];
        if ($lvl == "") {
            $lvl = 1;
        }
        if ($lvl == 0) {
            header("Location:" . _SPPATH . "rank/dari_untuk_indonesia");
            exit;
        }
        $l = new QuizLevel();
        $l->getByID($lvl);
        if ($l->level_name == "" || $l->level_aktif != 1) {
            Redirect::p404();
        }
        $actual_link = _BPATH . "kl/tk/" . $lvl;
        $point = QuizPoints::myPoints();
        $kurang = "";
        $lebih = "";
        $arrLevelsBig = $l->getWhere("level_limit > {$l->level_limit} AND level_aktif = 1 ORDER BY level_limit ASC LIMIT 0,1");
        $lebih = $arrLevelsBig[0];
        $arrLevelsSmall = $l->getWhere("level_limit < {$l->level_limit} AND level_aktif = 1 ORDER BY level_limit DESC LIMIT 0,1");
        $kurang = $arrLevelsSmall[0];
        //pr($arrLevels);
        $boleh = 0;
        if ($point >= $l->level_limit) {
            $boleh = 1;
        }
        $arrLevel = $l->getWhere(" level_aktif = 1 ORDER BY level_limit ASC ");
        ?>

<div class="col-md-10 col-sm-12 col-xs-12 kelas col-md-offset-1">    
    <div id="fbgroup" style="height: 20px; line-height: 20px; margin-bottom: 20px;float: none; ">
        <div style="float:left;width: 200px; text-align: left;">
            Pilih Kelas : <select id="kelassel"  onchange="document.location='<?php 
        echo _SPPATH;
        ?>
kl/tk/'+$('#kelassel').val();">
                <?php 
        foreach ($arrLevel as $level) {
            ?>
                <option <?php 
            if ($level->level_id == $lvl) {
                echo "selected";
            }
            ?>
 value="<?php 
            echo $level->level_id;
            ?>
"><?php 
            echo $level->level_name;
            ?>
</option>
                <?php 
        }
        ?>
            </select>
        </div>
     <div class="fb-like" data-href="<?php 
        echo $actual_link;
        ?>
" data-layout="button_count" data-action="like" data-show-faces="true" data-share="true"></div>
    </div>
    <div class="kelas_container">
    <h1 class="text-center judulkl">
    <?php 
        if ($kurang->level_id != "") {
            ?>
    <i onclick="document.location='<?php 
            echo _SPPATH;
            ?>
kl/tk/<?php 
            echo $kurang->level_id;
            ?>
';" class="glyphicon glyphicon-chevron-left"></i>
    <?php 
        }
        ?>
    <?php 
        echo $l->level_name;
        ?>
        <?php 
        if ($lebih->level_id != "") {
            ?>
    <i onclick="document.location='<?php 
            echo _SPPATH;
            ?>
kl/tk/<?php 
            echo $lebih->level_id;
            ?>
';" class="glyphicon glyphicon-chevron-right"></i>
<?php 
        }
        ?>
    </h1>
    <div class="kelas_isi">
    <?php 
        //echo "<h1 class='text-center'>".$l->level_name."</h1>";
        //get ulangan dlm level
        $ul = new QuizUlangan();
        $arrUl = $ul->getWhere("ulangan_level_id = '" . $l->level_id . "' AND ulangan_aktif = 1");
        //pr($arrUl);
        foreach ($arrUl as $num => $ul) {
            ?>
    <div class="col-md-4 text-center kelas_dalam">
        <div class="kelas_dalam_image">
            <a href="<?php 
            echo _SPPATH;
            ?>
ul/id/<?php 
            echo $ul->ulangan_id;
            ?>
/<?php 
            echo urlencode($ul->ulangan_name);
            ?>
">
            <img class="wow bounceIn" <?php 
            if (!$boleh) {
                ?>
style="opacity:0.5;"<?php 
            }
            ?>
 width="100%" src="<?php 
            echo _SPPATH . _PHOTOURL . "thumbnail/" . $ul->ulangan_image;
            ?>
">
            </a>
        </div>
        <div class="kelas_dalam_text">
        <a href="<?php 
            echo _SPPATH;
            ?>
ul/id/<?php 
            echo $ul->ulangan_id;
            ?>
/<?php 
            echo urlencode($ul->ulangan_name);
            ?>
"><?php 
            echo $ul->ulangan_name;
            ?>
</a>
        </div>
    </div>    
        <?php 
            if ($num % 3 == 2) {
                echo '<div class="clearfix"></div>';
            }
        }
        ?>
        <div class="clearfix"></div>
    </div>
    </div>
<div id="comment">
<div class="fb-comments" data-href="<?php 
        echo $actual_link;
        ?>
" data-width="100%" data-numposts="5" data-colorscheme="light"></div>    
</div>
</div>


<div class="clearfix"></div>
<style>
    h1.judulkl{
        font-family: verdana;
        margin-top: 0px;
    }
    .kelas_dalam_text a{
        color:#db031b;
    }
    .judulkl i{
        font-size: 20px;
        position: absolute;
        margin-top: 80px;
        margin-left: 20px;
        font-style: normal;
        cursor: pointer;
        
        //color:maroon;
    }
    .judulkl i.glyphicon-chevron-left{
        margin-left: -40px;
        //margin-right:  20px;
    }
    .kelas_container{
        padding-top: 30px;
       // background-color: #efefef;
    }
</style>
<?php 
        global $template;
        $template->title = $l->level_name . " | Seberapa Indonesiakah Anda";
        $template->metades = $l->level_descr . " #Seberapa Indonesiakah Anda | How Indonesia Are You";
        $template->metakey = 'How Indonesia Are You, Seberapa Indonesiakah Anda';
        $fb_opengraph = '<meta property="og:title" content="' . $l->level_name . '" />';
        $template->headText[] = $fb_opengraph;
        //image
        $fb_opengraph = '<meta property="og:image"  content="' . _BPATH . _PHOTOURL . $l->level_fb_image . '" /> ';
        $template->headText[] = $fb_opengraph;
        //url
        $actual_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
        $fb_opengraph = '<meta property="og:url" content="' . $actual_link . '" />';
        $template->headText[] = $fb_opengraph;
        //sitename
        $fb_opengraph = '<meta property="fb:app_id" content="' . Efiwebsetting::getData('fb_app_id') . '" />' . '<meta property="og:type" content="website" />';
        $template->headText[] = $fb_opengraph;
        //sitename
        $fb_opengraph = '<meta property="og:site_name" content="SeberapaIndonesiakahAnda"/>';
        $template->headText[] = $fb_opengraph;
        //description
        $fb_opengraph = '<meta property="og:description" content="' . $l->level_descr . '" />';
        $template->headText[] = $fb_opengraph;
    }
Example #3
0
    function dari_untuk_indonesia($args)
    {
        list($page, $sort) = $args;
        if ($page == "" || !isset($page) || $page < 1) {
            $page = 1;
        }
        if ($sort == "" || !isset($sort)) {
            $sort = "udate1";
        }
        $sortext = "ulangan_update_date DESC";
        if ($sort == "udate2") {
            $sortext = "ulangan_update_date ASC";
        }
        if ($sort == "cdate1") {
            $sortext = "ulangan_create_date ASC";
        }
        if ($sort == "cdate2") {
            $sortext = "ulangan_create_date DESC";
        }
        if ($sort == "view1") {
            $sortext = "ulangan_view ASC";
        }
        if ($sort == "view2") {
            $sortext = "ulangan_view DESC";
        }
        if ($sort == "fin1") {
            $sortext = "ulangan_finished ASC";
        }
        if ($sort == "fin2") {
            $sortext = "ulangan_finished DESC";
        }
        $limit = 30;
        $begin = ($page - 1) * $limit;
        ?>
    <style>
         .pagination > .active > a, .pagination > .active > span, .pagination > .active > a:hover, .pagination > .active > span:hover, .pagination > .active > a:focus, .pagination > .active > span:focus{
            
              background-color: #f0373c;
  border-color: #f0373c;
        }
        .pagination > li > a, .pagination > li > span{
            border-color: #f0373c;
        }
        .pagination > li > a, .pagination > li > span{
            color: #f0373c;
        }
        .pagination > li > a:hover, .pagination > li > span:hover{
            background-color: #efefef;
            border-color: #f0373c;
        }
    </style>
         <div class="kelas_isi col-md-8 col-md-offset-2">
             <h1 style="text-align: center;">UJIAN NASIONAL <i>TIDAK RESMI</i></h1>
             <h4 style="text-align: center; margin-bottom: 30px;">Dari, Untuk, Tentang INDONESIA</h4>
             <div style="text-align: right; padding-bottom: 10px;">
                 <select id="sortby" onchange="document.location='<?php 
        echo _SPPATH;
        ?>
rank/dari_untuk_indonesia/1/'+$('#sortby').val();">
                     <option <?php 
        if ($sort == "udate1") {
            echo "selected";
        }
        ?>
 value="udate1">Waktu Update Lama -> Baru</option>
                     <option <?php 
        if ($sort == "udate2") {
            echo "selected";
        }
        ?>
 value="udate2">Waktu Update Baru -> Lama</option>
                     <option <?php 
        if ($sort == "cdate1") {
            echo "selected";
        }
        ?>
 value="cdate1">Waktu dibuat Lama -> Baru</option>
                     <option <?php 
        if ($sort == "cdate2") {
            echo "selected";
        }
        ?>
 value="cdate2">Waktu dibuat Baru -> Lama</option>
                     <option <?php 
        if ($sort == "view1") {
            echo "selected";
        }
        ?>
 value="view1">Dilihat Sedikit -> Banyak</option>
                     <option <?php 
        if ($sort == "view2") {
            echo "selected";
        }
        ?>
 value="view2">Dilihat Banyak -> Sedikit</option>
                     <option <?php 
        if ($sort == "fin1") {
            echo "selected";
        }
        ?>
 value="fin1">Dikerjakan Sedikit -> Banyak</option>
                     <option <?php 
        if ($sort == "fin2") {
            echo "selected";
        }
        ?>
 value="fin2">Dikerjakan Banyak -> Sedikit</option>
                 </select>
             </div>
    <?php 
        //echo "<h1 class='text-center'>".$l->level_name."</h1>";
        //get ulangan dlm level
        $ul = new QuizUlangan();
        $arrUl = $ul->getWhereFromMultipleTable("ulangan_level_id = '0' AND ulangan_aktif = 1 AND ulangan_creator_id = admin_id ORDER BY {$sortext} LIMIT {$begin},{$limit}", array("Account"));
        $boleh = 1;
        $total = $ul->getJumlah("ulangan_level_id = '0' AND ulangan_aktif = 1");
        //echo $total;
        $totalpage = ceil($total / $limit);
        //pr($arrUl);
        foreach ($arrUl as $num => $ul) {
            ?>
     <div class="diui" style="background-color:#efefef; margin-bottom: 10px;">
        <div class="col-md-3 col-sm-6 ">
            <a href="<?php 
            echo _SPPATH;
            ?>
ul/id/<?php 
            echo $ul->ulangan_id;
            ?>
/<?php 
            echo urlencode($ul->ulangan_name);
            ?>
">
            <img class="wow bounceIn" <?php 
            if (!$boleh) {
                ?>
style="opacity:0.5;"<?php 
            }
            ?>
 width="100%" src="<?php 
            echo _SPPATH . _PHOTOURL . "thumbnail/" . $ul->ulangan_image;
            ?>
">
            </a>
        </div>
        <div class="col-md-9 col-sm-6 ">
            <div style="padding: 10px;">
                <a style="font-size: 16px;" href="<?php 
            echo _SPPATH;
            ?>
ul/id/<?php 
            echo $ul->ulangan_id;
            ?>
/<?php 
            echo urlencode($ul->ulangan_name);
            ?>
"><?php 
            echo $ul->ulangan_name;
            ?>
</a>
                <br>
                <small><?php 
            echo $ul->ulangan_descr;
            ?>
</small>
                <div class="oleh" style="margin-top: 5px; font-size: 12px; font-style: italic;" >
                    disunting oleh <a href="<?php 
            echo _SPPATH;
            ?>
p/user/<?php 
            echo $ul->admin_id;
            ?>
"><?php 
            echo $ul->admin_name;
            ?>
</a>
                    untuk <b>INDONESIA</b>
                    <br>dilihat : <?php 
            echo $ul->ulangan_view;
            ?>
 kali
                    <br>dikerjakan : <?php 
            echo $ul->ulangan_finished;
            ?>
 kali
                </div>
                
            </div>
        </div>
        <div class="clearfix"></div>
    </div>    
        <?php 
        }
        ?>
        <div class="clearfix"></div>
        <?php 
        if ($totalpage > 1) {
            ?>
    <div style="margin: 0 auto; text-align: center;"> 
    <nav >
  <ul class="pagination">
    <?php 
            if ($page > 1) {
                $prev = $page - 1;
                ?>
  
    <li>
      <a href="<?php 
                echo _SPPATH;
                ?>
rank/dari_untuk_indonesia/<?php 
                echo $prev;
                ?>
/<?php 
                echo $sort;
                ?>
" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
    </li>
    <?php 
            }
            ?>
    <?php 
            $mulai = max($page - $jarak, 1);
            $end = min($page + $jarak, $totalpage);
            for ($x = $mulai; $x <= $end; $x++) {
                ?>
    <li <?php 
                if ($page == $x) {
                    ?>
class="active"<?php 
                }
                ?>
><a  href="<?php 
                echo _SPPATH;
                ?>
rank/dari_untuk_indonesia/<?php 
                echo $x;
                ?>
/<?php 
                echo $sort;
                ?>
"><?php 
                echo $x;
                ?>
</a></li>
    <?php 
            }
            ?>
    <?php 
            if ($page < $totalpage) {
                $nn = $page + 1;
                ?>
    <li>
      <a href="<?php 
                echo _SPPATH;
                ?>
rank/dari_untuk_indonesia/<?php 
                echo $nn;
                ?>
/<?php 
                echo $sort;
                ?>
" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
    </li>
    <?php 
            }
            ?>
  </ul>
</nav>        
       </div>
        <?php 
        }
        ?>
        
    </div>
    
    <?php 
    }
 public static function submit_ul()
 {
     if ($_POST['judul_ulangan'] == "" || $_POST['ulangan_file'] == "" || $_POST['deskripsi_ulangan'] == "" || !Auth::isLogged()) {
         die('no id');
     }
     $ul = new QuizUlangan();
     if ($_GET['ups']) {
         if (!isset($_POST['ul_id'])) {
             die('no id');
         } else {
             $ul->getByID(addslashes($_POST['ul_id']));
             if ($ul->ulangan_creator_id != Account::getMyID()) {
                 die('not allowed');
             }
             $ul->load = 1;
         }
     }
     $json['bool'] = 0;
     $ul->ulangan_level_id = 0;
     $ul->ulangan_aktif = 0;
     $ul->ulangan_name = addslashes($_POST['judul_ulangan']);
     $ul->ulangan_image = addslashes($_POST['ulangan_file']);
     $ul->ulangan_descr = addslashes($_POST['deskripsi_ulangan']);
     $ul->ulangan_fb_image = addslashes($_POST['ulangan_file']);
     $ul->ulangan_creator_id = Account::getMyID();
     $ul->ulangan_jumlah_soal = 10;
     $scc = $ul->save();
     if ($scc) {
         $json['bool'] = 1;
         $json['ul_id'] = $scc;
     }
     echo json_encode($json);
     exit;
 }
Example #5
0
 function hapus_ul($args)
 {
     list($id) = $args;
     if (!isset($id) || $id < 1) {
         die('no proper id');
     }
     $ul = new QuizUlangan();
     $ul->getByID($id);
     if ($ul->ulangan_creator_id == Account::getMyID() && !$ul->ulangan_aktif) {
         $ul->delete($id);
         //$ul->ulangan_aktif = 0;
         //$ul->save();
         $q = new QuizQuestion();
         $arr = $q->getWhere("q_ulangan_id = '{$id}'");
         foreach ($arr as $qq) {
             $q->delete($qq->qid);
             $a = new QuizAnswer();
             $arr2 = $a->getWhere("answer_qid = '{$qq->qid}'");
             foreach ($arr2 as $aa) {
                 $a->delete($aa->answer_id);
             }
         }
     }
 }
    function Ulangan_Full()
    {
        $id = addslashes($_GET['id']);
        if ($id == "") {
            die('no id');
        }
        $ul = new QuizUlangan();
        $ul->getByID($id);
        //pr($ul);
        $lv = new QuizLevel();
        $lv->getByID($ul->ulangan_level_id);
        ?>
<style>
    .quest{
        padding: 20px;
        border-bottom: 1px solid #dedede;
    }    
    .answer{
        padding: 20px;
        padding-left: 30px;
    }
    .choice{
        padding: 10px;
    }
</style>
<h1><?php 
        echo $ul->ulangan_name;
        ?>
</h1>    
<p><?php 
        echo $lv->level_name;
        ?>
</p>
<hr>
        <?php 
        $q = new QuizQuestion();
        $arrQ = $q->getWhere("q_ulangan_id = '{$ul->ulangan_id}'");
        $cnt = 1;
        foreach ($arrQ as $q) {
            ?>
<div id="newform_<?php 
            echo $cnt;
            ?>
">
<div class="quest">
    <form class="form-inline" id="form_q_<?php 
            echo $cnt;
            ?>
" >
        <div class="form-group">
            <label for="question_<?php 
            echo $q->qid;
            ?>
_title"><?php 
            echo $cnt;
            $cnt++;
            ?>
.</label>
            <input style="min-width: 500px;" id="question_<?php 
            echo $cnt;
            ?>
_title" class="form-control" type="text" value="<?php 
            echo $q->q_title;
            ?>
">
   
        </div>
        <div class="form-group">
            
             Active : <input id="question_<?php 
            echo $cnt;
            ?>
_aktif" class="form-control" type="text" value="<?php 
            echo $q->q_aktif;
            ?>
">
   
        </div>
        <div class="form-group">
            <?php 
            $if = new Leap\View\InputFoto("question_" . $cnt . "_file", "question_" . $cnt . "_file", $q->q_image);
            $if->p();
            ?>
            <?php 
            /*<input id="question_<?=$q->qid;?>_file" class="form-control" type="file" value="<?=$q->q_image;?>">*/
            ?>
        </div>
    
    <div class="answer">
        <?php 
            $ans = new QuizAnswer();
            $arrAns = $ans->getWhere("answer_qid = '{$q->qid}'");
            $arrAns = array_reverse($arrAns);
            for ($x = 0; $x < 4; $x++) {
                $ans = array_pop($arrAns);
                if (!isset($ans)) {
                    $ans = new QuizAnswer();
                }
                $checked = "";
                if ($ans->answer_id == $q->q_correct_answer_id) {
                    $checked = "checked";
                }
                ?>
        <div class="choice">
            
        
           <div class="form-group">
               <input <?php 
                echo $checked;
                ?>
 type="radio" name="radio_<?php 
                echo $cnt;
                ?>
" value="<?php 
                echo $x;
                ?>
"> 
           </div>
           <div class="form-group">
               <input id="answer_title_<?php 
                echo $cnt;
                ?>
_<?php 
                echo $x;
                ?>
" type="text" style="min-width: 300px;" value="<?php 
                echo $ans->answer_text;
                ?>
" class="form-control"> 
           </div>
           <div class="form-group">
                <?php 
                $if = new Leap\View\InputFoto("answer_file_{$cnt}_{$x}", "answer_file_{$cnt}_{$x}", $ans->answer_image);
                $if->p();
                ?>

           </div>
       
            
        </div>
                <?php 
            }
            ?>
    </div>
        <button class="btn btn-default" id="formbutton_q_<?php 
            echo $cnt;
            ?>
" onclick="doSave('<?php 
            echo $cnt;
            ?>
','<?php 
            echo $q->qid;
            ?>
',event);">Save Q and A</button>
    </form>
    
</div>
</div>
            <?php 
        }
        ?>
<script>
        function doSave(cnt,qid,event){
            
            event.preventDefault();
            var answer_0 = $('#answer_title_'+cnt+'_0').val();
            var answer_0_img = $('#answer_file_'+cnt+'_0').val();
            //alert(answer_1+' '+answer_1_img);
            
            var answer_1 = $('#answer_title_'+cnt+'_1').val();
            var answer_1_img = $('#answer_file_'+cnt+'_1').val();
            //alert(answer_2+' '+answer_2_img);
            
            var answer_2 = $('#answer_title_'+cnt+'_2').val();
            var answer_2_img = $('#answer_file_'+cnt+'_2').val();
            //alert(answer_3+' '+answer_3_img);
            
            var answer_3 = $('#answer_title_'+cnt+'_3').val();
            var answer_3_img = $('#answer_file_'+cnt+'_3').val();
            //alert(answer_4+' '+answer_4_img);
            
            //var qid = <?php 
        echo $q->qid;
        ?>
;
            
            var q_title = $('#question_'+cnt+'_title').val();
            var q_img = $('#question_'+cnt+'_file').val();
            
            var radio = $('input[name=radio_'+cnt+']:checked').val();
            
            var q_aktif = $('#question_'+cnt+'_aktif').val();
            //alert(radio+' '+qid+' '+q_title+' '+q_img+' '+answer_0+' '+answer_0_img+' '+answer_1+' '+answer_1_img+' '+answer_2+' '+answer_2_img+' '+answer_3+' '+answer_3_img);
            
            $.post('<?php 
        echo _SPPATH;
        ?>
UlWeb/saveQ',
            {
                radio:radio,
                qid : qid,
                q_title : q_title,
                q_img : q_img,
                q_aktif: q_aktif,
                answer_0 : answer_0,
                answer_0_img : answer_0_img,
                answer_1 : answer_1,
                answer_1_img : answer_1_img,
                answer_2 : answer_2,
                answer_2_img : answer_2_img,
                answer_3 : answer_3,
                answer_3_img : answer_3_img,
                ul_id : '<?php 
        echo $id;
        ?>
',
            }
            ,function(data){
                alert(data);
                location.reload();
            });
        }
 </script>
<div id="tambahanform"></div>
<div style="padding: 30px; text-align: center;">
    <button class="btn btn-primary btn-lg" onclick="addform();">Add more Questions</button>   
</div>
<script>
    var jumlahform = <?php 
        echo $cnt;
        ?>
;
function addform(){
    $('#tambahanform').append('<div id="newform_'+jumlahform+'"></div>');
    
    $('#newform_'+jumlahform).load('<?php 
        echo _SPPATH;
        ?>
UlWeb/newform?jml='+jumlahform);
    jumlahform++;
    
}    
</script>
         <?php 
    }
Example #7
0
 public function hitung($args)
 {
     //pr($_POST);
     $jwb = $_POST['jwb'];
     $qid = $_POST['qid'];
     if (!isset($qid)) {
         die("No ID");
     }
     $ul = new QuizUlangan();
     $ul->getByID($qid);
     //update number
     $ul->ulangan_finished = $ul->ulangan_finished + 1;
     $ul->ulangan_update_date = leap_mysqldate();
     $ul->save();
     // user gen
     $acc = new Account();
     $ucreate = 0;
     if ($ul->ulangan_creator_id != 0) {
         $ucreate = 1;
         $acc->getByID($ul->ulangan_creator_id);
     }
     $ucreate_text = "Seberapa Indonesiakah Anda";
     //campur badge
     if ($ucreate) {
         $ul->ulangan_badge_1 = $ul->ulangan_image;
         $ul->ulangan_badge_2 = $ul->ulangan_image;
         $ul->ulangan_badge_3 = $ul->ulangan_image;
         $ul->ulangan_badge_4 = $ul->ulangan_image;
         $ul->ulangan_badge_5 = $ul->ulangan_image;
         $ucreate_text_title = $ul->ulangan_name;
         $ucreate_text = $acc->admin_name . " membuat ujian '" . $ul->ulangan_name . "' untuk INDONESIA. Berani terima tantangan dia?!?";
         $ul->ulangan_desc_1 = $ucreate_text;
         $ul->ulangan_desc_2 = $ucreate_text;
         $ul->ulangan_desc_3 = $ucreate_text;
         $ul->ulangan_desc_4 = $ucreate_text;
         $ul->ulangan_desc_5 = $ucreate_text;
         $ul->ulangan_descr = $ucreate_text;
     }
     $q = new QuizQuestion();
     $arrQ = $q->getWhere("q_ulangan_id = '{$ul->ulangan_id}' AND q_aktif = 1");
     //pr($arrQ);
     $jumlah_question = $ul->ulangan_jumlah_soal;
     foreach ($arrQ as $q) {
         $qs[$q->qid] = $q;
     }
     $point = 0;
     foreach ($jwb as $o) {
         $active = $qs[$o['qid']];
         if ($active->q_correct_answer_id == $o['aid']) {
             $point++;
         }
         //echo $o['qid']." jwb ".$o['aid']."<br>";
     }
     //pilah poin ke badge
     if ($point == 0) {
         $json['badge'] = _BPATH . _PHOTOURL . "thumbnail/" . $ul->ulangan_badge_1;
     }
     if ($point > 0 && $point < 6) {
         $json['badge'] = _BPATH . _PHOTOURL . "thumbnail/" . $ul->ulangan_badge_2;
     }
     if ($point > 5 && $point < 8) {
         $json['badge'] = _BPATH . _PHOTOURL . "thumbnail/" . $ul->ulangan_badge_3;
     }
     if ($point > 7 && $point < 10) {
         $json['badge'] = _BPATH . _PHOTOURL . "thumbnail/" . $ul->ulangan_badge_4;
     }
     if ($point == 10) {
         $json['badge'] = _BPATH . _PHOTOURL . "thumbnail/" . $ul->ulangan_badge_5;
     }
     $json['points'] = $point;
     $json['saved'] = 0;
     $json['naik_level'] = 0;
     $json['total_point'] = -1;
     $qp = new QuizPoints();
     if (Auth::isLogged()) {
         $pid = $qid . "_" . Account::getMyID();
         $qp->getByID($pid);
         if ($qp->points_id == "") {
             $qp->load = 0;
         }
         $qp->points_id = $pid;
         $qp->points_acc_id = Account::getMyID();
         $qp->points_ul_id = $qid;
         $qp->points_update = leap_mysqldate();
         if ($qp->points_nilai < $point) {
             $qp->points_nilai = $point;
         }
         $json['saved'] = $qp->save();
         $pointLama = QuizPoints::myPoints();
         $lvl_lama = floor($pointLama / 36);
         //update sessions points
         $qp->getPoints();
         $pointBaru = QuizPoints::myPoints();
         $lvl_baru = floor($pointBaru / 36);
         if ($lvl_baru > $lvl_lama && $pointLama > 0) {
             $json['naik_level'] = 1;
         }
         $json['total_point'] = $pointBaru;
     } else {
         if (!isset($_SESSION['game']['unsaved'])) {
             $_SESSION['game']['unsaved'] = array();
         }
         $_SESSION['game']['unsaved'][] = array($qid, $point);
     }
     echo json_encode($json);
     exit;
 }
    function user($args)
    {
        list($uid, $lvl, $res, $res_id) = $args;
        if ($lvl < 0 || $lvl == "") {
            die("No lvl");
        }
        if ($uid < 1 || $uid == "") {
            die("No id");
        }
        $fb_page = "https://www.facebook.com/pages/Stage-City/1076705655676385";
        $ql = new QuizLevel();
        $ql->getByID($lvl);
        $sm = new SiteMember();
        $sm->getByID($uid);
        $q = new QuizUlangan();
        $arrQ = $q->getWhere("ulangan_level_id = '{$ql->level_id}' AND ulangan_aktif = 1 ORDER BY ulangan_name ASC");
        $tn = 0;
        $nn = array();
        foreach ($arrQ as $q) {
            $nn[] = "points_ul_id = '{$q->ulangan_id}'";
            $tn++;
        }
        $imp = implode(" OR ", $nn);
        $p = new QuizPoints();
        //echo "$imp AND (points_acc_id = '$uid')";
        $arrP = $p->getWhere("({$imp}) AND (points_acc_id = '{$uid}')");
        $pid = array();
        $tp = 0;
        foreach ($arrP as $p) {
            $pid[$p->points_ul_id] = $p;
            //echo $p->points_ul_id."  ".$p->points_nilai." ".$p->points_acc_id."<br>";
            $tp += $p->points_nilai;
            //$tn++;
        }
        $rata2 = $tp / $tn;
        //echo $tp;
        //echo "<br>";
        //echo $tn;
        $point = ceil($rata2);
        $pp = ceil($rata2);
        //pilah poin ke badge
        if ($point == 0) {
            $badge = _BPATH . _PHOTOURL . $ql->level_rapor_1;
            $badge_thumb = _BPATH . _PHOTOURL . "thumbnail/" . $ql->level_rapor_1;
        }
        if ($point > 0 && $point < 6) {
            $badge = _BPATH . _PHOTOURL . $ql->level_rapor_2;
            $badge_thumb = _BPATH . _PHOTOURL . "thumbnail/" . $ql->level_rapor_2;
        }
        if ($point > 5 && $point < 8) {
            $badge = _BPATH . _PHOTOURL . $ql->level_rapor_3;
            $badge_thumb = _BPATH . _PHOTOURL . "thumbnail/" . $ql->level_rapor_3;
        }
        if ($point > 7 && $point < 10) {
            $badge = _BPATH . _PHOTOURL . $ql->level_rapor_4;
            $badge_thumb = _BPATH . _PHOTOURL . "thumbnail/" . $ql->level_rapor_4;
        }
        if ($point == 10) {
            $badge = _BPATH . _PHOTOURL . $ql->level_rapor_5;
            $badge_thumb = _BPATH . _PHOTOURL . "thumbnail/" . $ql->level_rapor_5;
        }
        $actual_link = _BPATH . "rapor/user/" . $uid . "/" . $lvl;
        ?>
<style>
    body{
        background-color: #efefef;
    }
    .table th{
        text-align: center;
        text-transform: uppercase;
    }
    .table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th, .table > thead > tr > td, .table > tbody > tr > td, .table > tfoot > tr > td{
        line-height: 35px;
        
    }
    .table a{
        color:#000;
        text-decoration: underline;
    }
</style>
<div class="col-md-8 col-md-offset-2" >
    <div style="background-color: white; padding: 30px; margin-top: 30px; margin-bottom: 30px;">
        
        <div style="text-align: center;">
            <?php 
        if ($point == 10) {
            ?>
            <div style="position: absolute;">
                <img src="<?php 
            echo _SPPATH;
            ?>
images/10.png" width="100px">
            </div>
            <?php 
        }
        ?>
            <?php 
        if ($point == 0) {
            ?>
            <div style="position: absolute;">
                <img src="<?php 
            echo _SPPATH;
            ?>
images/0.png" width="100px">
            </div>
            <?php 
        }
        ?>
        <img src="<?php 
        echo _SPPATH;
        ?>
images/logo-si2.png" width="20%">
<h3 style="text-align: center; padding-bottom: 10px;">LAPORAN HASIL BELAJAR</h3>
        </div>
<hr>
<div class="detail" style="padding-bottom: 20px; margin-top: 30px;">
<div class="col-md-6 col-sm-6 col-xs-6">
    Murid : <img class="wow bounceInLeft" src="//graph.facebook.com/<?php 
        echo $sm->admin_fb_id;
        ?>
/picture" height="35px">  <b class="wow bounceInLeft"><?php 
        echo $sm->admin_name;
        ?>
</b>
</div>
    <div class="col-md-6 col-sm-6 col-xs-6" style="text-align: right;">
    Kelas : <b class="wow bounceInRight"><?php 
        echo $ql->level_name;
        ?>
</b>
</div>
    <div class="clearfix"></div>
</div>

        
       
        <div class="table-responsive">
            <table class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th>No</th>
                        <th>Mata Pelajaran</th>
                        
                        <!--<th>Deskripsi kemajuan</th>-->
                        <th>Nilai</th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
        $cnt = 1;
        foreach ($arrQ as $q) {
            ?>
                    <tr>
                        <td style="text-align: center;"><?php 
            echo $cnt;
            ?>
</td>
                        <td><a href="<?php 
            echo _SPPATH;
            ?>
ul/id/<?php 
            echo $q->ulangan_id;
            ?>
/<?php 
            echo urlencode($q->ulangan_name);
            ?>
"><?php 
            echo $q->ulangan_name;
            ?>
</a></td>
                        
                        <?php 
            $nilai = $pid[$q->ulangan_id]->points_nilai;
            ?>
                            
                            
                        
                        <!--<td style="text-align: center;">
                            <?php 
            $jml = 0;
            $point = $nilai;
            if ($point > 5 && $point < 8) {
                $jml = 3;
            }
            if ($point > 7 && $point < 10) {
                $jml = 4;
            }
            if ($point == 10) {
                $jml = 5;
            }
            for ($x = 1; $x <= $jml; $x++) {
                ?>
                            <img  src="<?php 
                echo _SPPATH;
                ?>
images/bebekmini.png" height="35px">
                            <?php 
            }
            ?>
                        </td>-->
                        <td style="text-align: center;">
                            <?php 
            if (!isset($nilai)) {
                if (Account::getMyID() == $uid) {
                    ?>
                            <a href="<?php 
                    echo _SPPATH;
                    ?>
ul/id/<?php 
                    echo $q->ulangan_id;
                    ?>
/<?php 
                    echo urlencode($q->ulangan_name);
                    ?>
">ambil ujian</a>
                                <?php 
                } else {
                    ?>
                            Tidak Tersedia
                                <?php 
                }
            } else {
                ?>
<b <?php 
                if ($nilai < 6) {
                    ?>
style="color:red;"<?php 
                }
                ?>
 ><?php 
                echo $nilai;
                ?>
</b><?php 
            }
            ?>
                        </td>
                    </tr>
                    <?php 
            $cnt++;
        }
        ?>
                </tbody>
            </table>
        </div>


<div class="el" style="padding-top: 20px; font-size: 18px; text-align: center;">
                 Nilai rata-rata : <b><?php 
        echo $pp;
        ?>
</b> (<?php 
        echo round($rata2, 2);
        ?>
)
            </div>
            <div style="padding: 30px; text-align: center;">
            <div class="aftersales"><button class="btn btn-primary btn-lg btn-fb" onclick="return fbs_click('<?php 
        echo $badge;
        ?>
');">Bagi di Facebook</button></div>
            </div>

</div>
</div>

<script>
    $(document).ready(function(){
            var obj = {'lid': '<?php 
        echo $pp;
        ?>
', 'url': '<?php 
        echo $actual_link;
        ?>
'};
            var title = '<?php 
        echo $id;
        ?>
';
            var url = '<?php 
        echo _SPPATH . "rapor/user/" . $uid . "/" . $lvl;
        ?>
/result/<?php 
        echo $pp;
        ?>
';
            history.pushState(obj, title, url);  
            
            setTimeout(function() {
                $('#afterSalesModal').modal('show');
            }, 3000);
    });
    
function fbs_click(badge){
    u=location.href;    
    //t=document.title;
    var win = window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&p[images][0]='+badge,'sharer','toolbar=0,status=0,width=626,height=436');
    //win.location.reload();
    setTimeout(win.location.reload, 1400);
    return false;
}
</script>


<!-- Modal -->
<div class="modal fade" id="afterSalesModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <div class="modal-title" id="myModalLabel">Bagi ke teman</div>
      </div>
        <div class="modal-body" id="modalbody">
            <div id="modalbody2" style="text-align: center;">
                <img class="wow tada" src="<?php 
        echo $badge_thumb;
        ?>
" width="100%">
                    <div class="el" style="padding-top: 20px; font-size: 18px; text-align: center;">
                 Nilai rata-rata : <b><?php 
        echo $pp;
        ?>
</b> (<?php 
        echo round($rata2, 2);
        ?>
)
            </div>
            <div style="padding: 30px; text-align: center;">
            <div class="aftersales"><button class="btn btn-primary btn-lg btn-fb" onclick="return fbs_click('<?php 
        echo $badge;
        ?>
');">Bagi di Facebook</button></div>
            </div>
                   
            </div>
            <div class="likeus" style="text-align: center; padding: 20px;">
                Kalau kamu menyukai situs kami. Tolong like kami. Makaci! 
                <div class="likebut" style="padding:20px;">
                    <div class="fb-like fb-like2" data-href="<?php 
        echo $fb_page;
        ?>
" data-layout="button_count" data-action="like" data-show-faces="true" data-share="false"></div>
                </div>
            </div>  
      </div>
      <!--<div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>-->
    </div>
  </div>
</div>
        <?php 
        global $template;
        $template->title = "Rapor {$sm->admin_name} {$ql->level_name} | Seberapa Indonesiakah Anda";
        $fb_opengraph = '<meta property="og:title" content="Rapor ' . $ql->level_name . ' ' . $sm->admin_name . '" />';
        $template->headText[] = $fb_opengraph;
        if ($res_id != "") {
            $point = (int) $res_id;
            //pilah poin ke badge
            if ($point == 0) {
                $badge = _BPATH . _PHOTOURL . $ql->level_rapor_1;
            }
            if ($point > 0 && $point < 6) {
                $badge = _BPATH . _PHOTOURL . $ql->level_rapor_2;
            }
            if ($point > 5 && $point < 8) {
                $badge = _BPATH . _PHOTOURL . $ql->level_rapor_3;
            }
            if ($point > 7 && $point < 10) {
                $badge = _BPATH . _PHOTOURL . $ql->level_rapor_4;
            }
            if ($point == 10) {
                $badge = _BPATH . _PHOTOURL . $ql->level_rapor_5;
            }
            //image
            $fb_opengraph = '<meta property="og:image"  content="' . $badge . '" /> ';
            $template->headText[] = $fb_opengraph;
            //description
            $fb_opengraph = '<meta property="og:description" content="' . $sm->admin_name . ' mendapatkan nilai rata-rata ' . $res_id . '. Buktikan Seberapa Indonesiakah Anda?!?" />';
            $template->headText[] = $fb_opengraph;
        } else {
            //image
            $fb_opengraph = '<meta property="og:image"  content="' . $badge . '" /> ';
            $template->headText[] = $fb_opengraph;
            //description
            $fb_opengraph = '<meta property="og:description" content="' . $sm->admin_name . ' mendapatkan nilai rata-rata ' . $pp . '. Buktikan Seberapa Indonesiakah Anda?!?" />';
            $template->headText[] = $fb_opengraph;
        }
        $template->metades = " Buktikan Seberapa Indonesiakah Anda ?!?! #Seberapa Indonesiakah Anda | How Indonesia Are You";
        $template->metakey = 'How Indonesia Are You, Seberapa Indonesiakah Anda';
        //url
        $actual_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
        $fb_opengraph = '<meta property="og:url" content="' . $actual_link . '" />';
        $template->headText[] = $fb_opengraph;
        //sitename
        $fb_opengraph = '<meta property="fb:app_id" content="' . Efiwebsetting::getData('fb_app_id') . '" />' . '<meta property="og:type" content="website" />';
        $template->headText[] = $fb_opengraph;
        //sitename
        $fb_opengraph = '<meta property="og:site_name" content="SeberapaIndonesiakahAnda"/>';
        $template->headText[] = $fb_opengraph;
    }