Viewing file:      clsResultRQHStd.php (5.73 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 //--Class ResultRQHStd--------------------------
 //--PK of ResultRQHStd ::
 //    1. reRHSid
 
 class ResultRQHStd extends clsDB{
 
 var $result;
 
 var $reRHSid;
 var $doHSid;
 var $sectionRQid;
 var $RQid;
 var $point;
 var $xbar;
 var $sd;
 
 function ResultRQHStd(&$c){
     $this->c=$c->c;
     $this->DB=$c->db;
 }
 
 function Save(){
 //--ข้อมูลในอ๊อบเจ๊กเป็นข้อมูลใหม่หรือข้อมูลเดิม --1:ข้อมูลใหม่  2:ข้อมูลเดิม
     if ($this->status==1){
         //uncomment a line below if your table use ID as running number
         $this->reRHSid=$this->GetNextCode();
         $sql = "insert into ResultRQHStd values(
             '$this->reRHSid',
              '$this->doHSid',
              '$this->sectionRQid',
              '$this->RQid',
              '$this->point'
             )";
     }else {
         $sql = "update ResultRQHStd set 
             doHSid='$this->doHSid', 
             sectionRQid='$this->sectionRQid', 
             RQid='$this->RQid', 
             point='$this->point' 
             where reRHSid='$this->reRHSid'";
     }
     return $this->Dml($sql);
 }
 
 function Delete(){
 //--ลบข้อมูลเดิมในอ๊อบเจ๊ก, เป็นการลบข้อมูลทีละ 1 เรคอร์ด
 //--ต้องเรียกเมธอดตามลำดับดังนี้ SearchByKey()-->GetRecord()-->Delete()
     return $this->Dml("delete from ResultRQHStd where reRHSid='$this->reRHSid'");
 }
 
 function GetNextCode(){
 //--หาค่าสูงสุดของฟิลด์ที่ใช้เป็นคีย์ของตาราง ในลักษณะ auto increment
 //--ต้องเป็นฟิลด์ชนิดตัวเลขจำนวนเต็มเท่านั้น และไม่ได้กำหนดรหัสเองทางจอภาพ
     $this->SetQuery("select max(reRHSid) as num from ResultRQHStd");
     if ($result=$this->GetResult()) {
         return $result['num']+1;
     }
 }
 
 function RSResultRQHStd(){
 //--เมธอดที่ขึ้นต้นด้วย RS (ResultSet) มีความหมายว่าจะได้รับข้อมูลกลับมาจากการ select มากกว่า 1 เรคอร์ด
 //--จะต้องเรียกเมธอด GetRecord() ด้วยเสมอ นำข้อมูลจาก ResultSet เข้าอ๊อบเจ๊ก
 //--โดยสามารถเพิ่มเมธอดได้ตามต้องการ แต่ต้องขึ้นต้นด้วย RS
     $this->SetQuery("select * from ResultRQHStd order by reRHSid");
 }
 
 function GetRecord(){
 //--นำข้อมูลจาก ResultSet มากำหนดให้กับแอตทริบิวต์ของอ๊อบเจ็ก
 //--เรียก GetRecord() หนึ่งครั้ง จะเลื่อนตัวชี้เรคอร์ดไปอีกหนึ่งเรคอร์ด
     if ($this->result = $this->GetResult()) {
         $this->reRHSid = $this->result['reRHSid'];
         $this->doHSid = $this->result['doHSid'];
         $this->sectionRQid = $this->result['sectionRQid'];
         $this->RQid = $this->result['RQid'];
         $this->point = $this->result['point'];
         $this->xbar = $this->result['xbar'];
         $this->sd = $this->result['sd'];
         return 1;
     }else {
         return 0;
     }
 }
 
 function SearchByKey($xKey){
 //--ค้นหาข้อมูลตาม PK ต้องระบุพารามิเตอร์ด้วย และต้องตามด้วยเมธอด GetRecord() เสมอ
     if ($this->SetQuery("select * from ResultRQHStd where reRHSid= '$xKey'")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 //****************** You can add new functions below **********************//
 function SumPointByRQid($xdefineid,$xRQid){
         $this->SetQuery("select  sum(point) as num  from ResultRQHStd A, DoAssessmentHStd B where  A.doHSid = B.doHSid and defineid = '$xdefineid' and RQid = '$xRQid' group by RQid");
         $result = $this->GetResult();
         return $result['num'];
 }
 
 function SearchPointByRQid($xdefineid,$xRQid){
     if ($this->SetQuery("select  point  from ResultRQHStd A, DoAssessmentHStd B where  A.doHSid = B.doHSid and defineid = $xdefineid and RQid = '$xRQid'")){ 
         return 1;
     }else {
         return 0;
     }
 
 }
 
 function SearchPointByDoHSidRQid($xdoHSid,$xRQid){
     if ($this->SetQuery("select  point  from ResultRQHStd where  doHSid = '$xdoHSid' and  RQid = '$xRQid'")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function SearchPointByDoHSidSectionRQid($xdoHSid,$xsectionRQid,$xstudentYear='%'){
     $cond = '';
     $cond.= ($xstudentYear!='%')? " AND do.stdYearAss = '$xstudentYear'" : '' ;
     $sql = "select  point  
             from ResultRQHStd rr
             inner join DoAssessmentHStd do on do.doHSid = rr.doHSid
             where rr.doHSid = '$xdoHSid' 
             and rr.sectionRQid = '$xsectionRQid' 
             $cond
             ";
 //            echo $sql.'<br>';
     if ($this->SetQuery($sql)){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function CountPointJoinByRQidDefineidPoint($xRQid,$xdefineid,$xscore,$xstudentYear='%'){
     $cond = '';
     $cond.= ($xstudentYear!='%')? " AND do.stdYearAss = '$xstudentYear'" : '' ;
     $sql = "select count(point) as num 
             from DoAssessmentHStd do  
             inner join ResultRQHStd rr on do.doHSid = rr.doHSid
             where rr.RQid = '$xRQid' 
             and do.defineid = '$xdefineid' 
             and rr.point = '$xscore'
             $cond ";
     $this->SetQuery($sql);
     $result = $this->GetResult();
     return $result['num'];
 }
 
 function SearchResultIXbarSDByDefineidSectionRQid($xdefineid,$xsectionRQid,$xstudentYear='%'){
     $cond = '';
     $cond.= ($xstudentYear!='%')? " AND do.stdYearAss = '$xstudentYear'" : '' ;
     $cond.= ($xsectionRQid!='%')? " AND rrq.sectionRQid = '$xsectionRQid'" : '' ;
     $sql = "
             SELECT avg( point ) AS xbar,  STDDEV(point) AS sd
             FROM  DoAssessmentHStd do
             INNER JOIN ResultRQHStd rrq ON rrq.doHSid = do.doHSid
             WHERE do.defineid = '$xdefineid'
             $cond";
     if ($this->SetQuery($sql)){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function SearchResultIXbarSDEachRQidByDefineidSectionRQid($xdefineid,$xsectionRQid,$xRQid,$xstudentYear){
     $cond = '';
     $cond.= ($xstudentYear!='%')? " AND do.stdYearAss = '$xstudentYear'" : '' ;
 
     $sql = "SELECT avg( point ) AS xbar,  STDDEV(point) AS sd
             FROM  DoAssessmentHStd do
             INNER JOIN ResultRQHStd rrq ON rrq.doHSid = do.doHSid
             WHERE do.defineid = '$xdefineid'
                 AND rrq.sectionRQid = '$xsectionRQid'
                 AND rrq.RQid = '$xRQid'
             $cond";
     if ($this->SetQuery($sql)){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 } //--End class ResultRQHStd--
 
 ?>
 
 
  |