Viewing file:      2551-11-14-1.0.02-clsDoAssessment.php (10.03 KB)      -rw-r--r-- Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 //--Class DoAssessment--------------------------
 //--PK of DoAssessment ::
 //    1. doid
 
 class DoAssessment extends clsDB{
 
 var $result;
 
 var $doid;
 var $defineid;
 var $studentId;
 var $officerId;
 var $classId;
 var $courseId;
 var $section;
 var $dateAss;
 var $ttId;
 
 var $xbar;
 var $sd;
 
 function DoAssessment(&$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->doid=$this->GetNextCode();
         $sql = "insert into DoAssessment values(
             '$this->doid',
              '$this->defineid',
              '$this->studentId',
              '$this->officerId',
             '$this->classId',
              '$this->courseId',
              '$this->section',
              '$this->dateAss',
             '$this->ttId'
             )";
     }else {
         $sql = "update DoAssessment set 
             defineid='$this->defineid', 
             studentId='$this->studentId', 
             officerId='$this->officerId',
             classId='$this->classId',  
             courseId='$this->courseId', 
             section='$this->section', 
             dateAss='$this->dateAss' 
             ttId='$this->ttId'
             where doid='$this->doid'";
     }
     return $this->Dml($sql);
 }
 
 function Delete(){
 //--ลบข้อมูลเดิมในอ๊อบเจ๊ก, เป็นการลบข้อมูลทีละ 1 เรคอร์ด
 //--ต้องเรียกเมธอดตามลำดับดังนี้ SearchByKey()-->GetRecord()-->Delete()
     return $this->Dml("delete from DoAssessment where doid='$this->doid'");
 }
 
 function GetNextCode(){
 //--หาค่าสูงสุดของฟิลด์ที่ใช้เป็นคีย์ของตาราง ในลักษณะ auto increment
 //--ต้องเป็นฟิลด์ชนิดตัวเลขจำนวนเต็มเท่านั้น และไม่ได้กำหนดรหัสเองทางจอภาพ
     $this->SetQuery("select max(doid) as num from DoAssessment");
     if ($result=$this->GetResult()) {
         return $result['num']+1;
     }
 }
 
 function RSDoAssessment(){
 //--เมธอดที่ขึ้นต้นด้วย RS (ResultSet) มีความหมายว่าจะได้รับข้อมูลกลับมาจากการ select มากกว่า 1 เรคอร์ด
 //--จะต้องเรียกเมธอด GetRecord() ด้วยเสมอ นำข้อมูลจาก ResultSet เข้าอ๊อบเจ๊ก
 //--โดยสามารถเพิ่มเมธอดได้ตามต้องการ แต่ต้องขึ้นต้นด้วย RS
     $this->SetQuery("select * from DoAssessment order by doid");
 }
 
 function GetRecord(){
 //--นำข้อมูลจาก ResultSet มากำหนดให้กับแอตทริบิวต์ของอ๊อบเจ็ก
 //--เรียก GetRecord() หนึ่งครั้ง จะเลื่อนตัวชี้เรคอร์ดไปอีกหนึ่งเรคอร์ด
     if ($this->result = $this->GetResult()) {
         $this->doid = $this->result['doid'];
         $this->defineid = $this->result['defineid'];
         $this->studentId = $this->result['studentId'];
         $this->officerId = $this->result['officerId'];
         $this->classId = $this->result['classId'];
         $this->courseId = $this->result['courseId'];
         $this->section = $this->result['section'];
         $this->dateAss = $this->result['dateAss'];
         $this->ttId = $this->result['ttId'];
         $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 DoAssessment where doid= '$xKey'")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 
 //****************** You can add new functions below **********************//
 function getMaxDoid(){
     $this->SetQuery("select max(doid) as num from DoAssessment");
     if ($result=$this->GetResult()) {
         return $result['num'];
     }
 }
 
 function CountCheckAssessment($xdefineid,$xstudentId,$xofficerId,$xclassId,$xsection){
         $this->SetQuery("select count(*) as num  from DoAssessment where defineid = '$xdefineid' and studentId = '$xstudentId' and officerId = '$xofficerId' and classId = '$xclassId' and section = '$xsection'");
         $result = $this->GetResult();
         return $result['num'];
 }
 
 function CountDoidByDefineid($xdefineid){
         $this->SetQuery("select count(doid) as num  from DoAssessment where defineid = '$xdefineid'");
         $result = $this->GetResult();
         return $result['num'];
 }
 
 //16/11/2006
 function CountDoidByAcadSemDefineIdOfficerIdJoinClass($xacadYear,$xsemester,$xdefineid,$xofficerId){
         $this->SetQuery("select count(*) as num  from ClassAssess A, DoAssessment B where acadYear = '$xacadYear' and semester = '$xsemester' and defineid = '$xdefineid' and officerId = '$xofficerId' and A.classId = B.classId");
         $result = $this->GetResult();
         return $result['num'];
 }
 
 function CountDoidByDefineIdClassIdOfficeridSection($xdefineid,$xclassId,$xofficerId,$xsection){
     $this->SetQuery("select count(*) as num  from DoAssessment where defineid= '$xdefineid' and classId= '$xclassId' and officerId = '$xofficerId' and section = '$xsection'");
         $result = $this->GetResult();
         return $result['num'];
 }
 
 function CheckAssessment($xdefineid,$xstudentId,$xofficerId,$xclassId,$xsection){
     if ($this->SetQuery("select  *  from DoAssessment where defineid = '$xdefineid' and studentId = '$xstudentId' and officerId = '$xofficerId' and classId = '$xclassId' and section = '$xsection'")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function CheckAssessment2($xdefineid,$xstudentId,$xofficerId,$xttId,$xsection){
     if ($this->SetQuery("select  *  from DoAssessment where defineid = '$xdefineid' and studentId = '$xstudentId' and officerId = '$xofficerId' and ttId = '$xttId' and section = '$xsection'")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function SearchDoidByDefineid($xdefineid){
     if ($this->SetQuery("select doid from DoAssessment where defineid= '$xdefineid'")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function SearchDoidByDefineidOfficeridClassId($xdefineid,$xofficerId,$xclassId){
     if ($this->SetQuery("select doid from DoAssessment where defineid= '$xdefineid' and officerId = '$xofficerId' and classId = '$xclassId' order by doid")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function SearchByDefineidOfficeridClassId($xdefineid,$xofficerId,$xclassId){
     if ($this->SetQuery("select * from DoAssessment where defineid= '$xdefineid' and officerId = '$xofficerId' and classId = '$xclassId'")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function SearchClassIdByDefineidOfficerid($xdefineid,$xofficerId){
     if ($this->SetQuery("select classId from DoAssessment where defineid= '$xdefineid' and officerId = '$xofficerId' group by classId")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function SearchByDefineIdClassIdOfficeridSection($xdefineid,$xclassId,$xofficerId,$xsection){
     if ($this->SetQuery("select * from DoAssessment where defineid= '$xdefineid' and classId= '$xclassId' and officerId = '$xofficerId' and section = '$xsection'")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function SearchByDefineIdClassId($xdefineid,$xclassId){
     if ($this->SetQuery("select * from DoAssessment where defineid= '$xdefineid' and classId= '$xclassId'")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function CountCheckAssessment2($xdefineid,$xstudentId,$xofficerId,$xttId,$xsection){
         $this->SetQuery("select count(*) as num  from DoAssessment where defineid = '$xdefineid' and studentId = '$xstudentId' and officerId = '$xofficerId' and ttId = '$xttId' and section = '$xsection'");
         $result = $this->GetResult();
         return $result['num'];
 }
 function CountCheckAssessment3($xdefineid,$xstudentId,$xclassId,$xsection){
         $this->SetQuery("select count(*) as num  from DoAssessment where defineid = '$xdefineid' and studentId = '$xstudentId' and classId = '$xclassId' and section = '$xsection'");
         $result = $this->GetResult();
         return $result['num'];
 }
 
 function SearchByDefineIdClassIdOfficeridSectionttId($xdefineid,$xclassId,$xofficerId,$xsection,$xttId){
     if ($this->SetQuery("select * from DoAssessment where defineid= '$xdefineid' and classId= '$xclassId' and officerId = '$xofficerId' and section = '$xsection' and ttId='$xttId' ")){ 
         return 1;
     }else {
         return 0;
     }
 }
 function SearchStdIdByDefineIdClassIdOfficeridSection($xdefineid,$xclassId,$xofficerId,$xsection){
     if ($this->SetQuery("select distinct studentId from DoAssessment where defineid= '$xdefineid' and classId= '$xclassId' and officerId = '$xofficerId' and section = '$xsection'")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function SearchDoidByDefineidOfficeridClassIdttId($xdefineid,$xofficerId,$xclassId,$xttId){
     if ($this->SetQuery("select doid from DoAssessment where defineid= '$xdefineid' and officerId = '$xofficerId' and classId = '$xclassId' and ttId ='$xttId' order by doid")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 function CountDistinctStdByDefineidOfficeridClassId($xdefineid,$xofficerId,$xclassId){
         $this->SetQuery("select count(distinct(studentId)) as num  from DoAssessment where defineid = '$xdefineid' and officerId = '$xofficerId' and classId = '$xclassId' ");
         $result = $this->GetResult();
         return $result['num'];
 }
 
 function CountDistinctStdByDefineidOfficeridClassIdttId($xdefineid,$xofficerId,$xclassId,$xttId){
         $this->SetQuery("select count(distinct(studentId)) as num  from DoAssessment where defineid = '$xdefineid' and officerId = '$xofficerId' and classId = '$xclassId' and ttId = '$xttId' ");
         $result = $this->GetResult();
         return $result['num'];
 }
 
 function RSDistinctOfficeridByDefineid($xdefineid){
         if($this->SetQuery("select distinct officerId  from DoAssessment where defineid = '$xdefineid' order by officerId")){
             return 1;
         }else{
             return 0;
         }
 }
 
 function RSXbarSDCollageByAcadSemAssidDefineidOfficerId($xacadYear,$xsemester,$xdefineid,$xofficerId){
     if ($this->SetQuery("
         select  A.xbar, sqrt(A.val - pow(A.xbar,2)) as sd
         from  
         (
             SELECT sectionRQid,total / ( dd * num ) as xbar, (sumpow2 / (dd * num)) as val
             FROM 
             (
                 SELECT sa.sectionRQid, count( DISTINCT RQid ) AS num,count( DISTINCT da.doid ) AS dd,sum( point ) AS total, sum(point *point) AS sumpow2
                 FROM DefineAssessment df
                 INNER JOIN DoAssessment da ON df.defineid = da.defineid
                 INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
                 INNER JOIN SectionAll sa ON sa.assid = df.assid
                 WHERE df.acadYear = '$xacadYear'
                     AND df.semester = '$xsemester'
                     AND df.defineid = '$xdefineid'
                     AND da.officerId = '$xofficerId'
                     AND sa.sectionRQid = rrq.sectionRQid
                 group by sa.sectionRQid
             ) inn
         ) A
         where 1
         ")){ 
         return 1;
     }else {
         return 0;
     }
 }
 
 } //--End class DoAssessment--
 
 ?>
 
  |