Viewing file: 2552-12-09-1.0.05-clsDoAssessment.php (16.67 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 $status;
var $doid;
var $defineid;
var $studentId;
var $officerId;
var $classId;
var $courseId;
var $section;
var $dateAss;
var $ttId;
var $mepId;
var $sepId;
var $xbar;
var $sd;
var $txbar;
var $tsd;
var $officerName;
var $officerSurname;
var $num1;
var $num2;
var $per;
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',
'$this->mepId',
'$this->sepId'
)";
}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',
mepId='$this->mepId',
sepId='$this->sepId'
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->mepId = $this->result['mepId'];
$this->sepId = $this->result['sepId'];
$this->xbar = $this->result['xbar'];
$this->sd = $this->result['sd'];
$this->txbar = $this->result['txbar'];
$this->tsd = $this->result['tsd'];
$this->officerName = $this->result['officerName'];
$this->officerSurname = $this->result['officerSurname'];
$this->num1 = $this->result['num1'];
$this->num2 = $this->result['num2'];
$this->per = $this->result['per'];
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 LIKE '$xofficerId' and classId LIKE '$xclassId' order by classId,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' and ttId = 0");
$result = $this->GetResult();
return $result['num'];
}
function CountCheckAssessmentHP($xdefineid,$xstudentId,$xclassId,$xsection,$xmepId,$xsepId){
$this->SetQuery("select count(*) as num from DoAssessment where defineid = '$xdefineid' and studentId = '$xstudentId' and classId = '$xclassId' and section = '$xsection' and ttId = 0 and mepId = '$xmepId' and sepId = '$xsepId' ");
$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 SearchByClassIdOfficeridttId($xclassId,$xofficerId,$xttId){
if ($this->SetQuery("select * from DoAssessment where classId = '$xclassId' and officerId = '$xofficerId' and ttId ='$xttId' ")){
return 1;
}else {
return 0;
}
}
function SearchByClassIdOfficerid($xclassId,$xofficerId){
if ($this->SetQuery("select * from DoAssessment where classId = '$xclassId' and officerId = '$xofficerId' ")){
return 1;
}else {
return 0;
}
}
// sumRe
function RSXbarSDSumReByCourseIdDefineidOfficerId($xCourseId,$xdefineid,$xOfficerId){
if ($this->SetQuery("
select A.sec1 as section,xbar,sd,txbar,tsd
from (
select section as sec1, xbar as txbar, sqrt(sumpow2-(xbar*xbar)) as tsd
from (
SELECT ca.section,avg(point) as xbar,sum(point*point)/count(point) as sumpow2
FROM DoAssessment da
inner JOIN ClassAssess ca ON ca.classId = da.classId
inner JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE da.defineid = '$xdefineid'
AND da.officerId = '$xOfficerId'
AND ca.courseId = '$xCourseId'
group by ca.section
)inn1
)A,(
select section as sec2,sectionRQid , xbar , sqrt(sumpow2-(xbar*xbar)) as sd
from (
SELECT ca.section as section,rrq.sectionRQid,avg(point) as xbar,sum(point*point)/count(point) as sumpow2
FROM DoAssessment da
inner JOIN ClassAssess ca ON ca.classId = da.classId
inner JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE da.defineid = '$xdefineid'
AND da.officerId = '$xOfficerId'
AND ca.courseId = '$xCourseId'
group by ca.section,rrq.sectionRQid
)inn2
order by section,sectionRQid
)B
where A.sec1 = B.sec2
order by A.sec1
")){
return 1;
}else {
return 0;
}
}
function getOverviewCourseByCourseIdDefineidOfficerId($xCourseId,$xdefineid,$xOfficerId){
if ($this->SetQuery("
SELECT avg(point) AS xbar, stddev(point) as sd
FROM DoAssessment da
inner JOIN ClassAssess ca ON ca.classId = da.classId
inner JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE da.defineid = '$xdefineid'
AND da.officerId = '$xOfficerId'
AND ca.courseId = '$xCourseId'
")){
return 1;
}else {
return 0;
}
}
function RSOverviewCourseSectionRQidByCourseIdDefineidOfficerId($xCourseId,$xdefineid,$xOfficerId){
if ($this->SetQuery("
SELECT rrq.sectionRQid, avg(point) AS xbar, stddev(point) as sd
FROM DoAssessment da
inner JOIN ClassAssess ca ON ca.classId = da.classId
inner JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE da.defineid = '$xdefineid'
AND da.officerId = '$xOfficerId'
AND ca.courseId = '$xCourseId'
GROUP BY rrq.sectionRQid
")){
return 1;
}else {
return 0;
}
}
function CountDoStdOrderSectionByDefineIdCourseIdOfficerid($defineid,$courseId,$officerId){
if($this->SetQuery(" SELECT r1.section, r1.num AS num1, r2.num AS num2, (r1.num/r2.num)*100 AS per
FROM (
SELECT section, count( * ) AS num
FROM DoAssessment
WHERE defineid = '$defineid'
AND courseId = '$courseId'
AND officerId = '$officerId'
GROUP BY section
)r1, (
SELECT section, count( reg.studentId ) AS num
FROM DefineAssessment df
JOIN Registration reg ON df.acadYear = reg.acadYear
AND df.semester = reg.semester
JOIN ClassAssess cl ON cl.classId = reg.classId
WHERE df.defineid = '$defineid'
AND reg.courseId = '$courseId'
GROUP BY cl.section
)r2
WHERE r1.section = r2.section"))
{
return 1;
}else{
return 0;
}
}
// RSXbarSD --/04/2552
function RSXbarSDOverviewCollage($xassid, $xacadYear, $xsemester, $xdefineid, $xOfSitId)
{
if($this->SetQuery("
SELECT C.officerName as officerName,C.officerSurname as officerSurname,of2,xbar,sd,txbar,tsd
from (
SELECT officerId as of1, xbar as txbar, sqrt(sumpow2-(xbar*xbar)) as tsd
from (
SELECT da.officerId,sum(point)/count(point) as xbar,sum(point*point)/count(point) as sumpow2
FROM DoAssessment da
inner JOIN DefineAssessment df ON df.defineid = da.defineid
inner JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear LIKE '$xacadYear'
AND df.semester LIKE '$xsemester'
AND df.defineid LIKE '$xdefineid'
AND df.assid LIKE '$xassid'
group by da.officerId
)inn1
)A,(
SELECT officerId AS of2,sectionRQid , xbar , sqrt(sumpow2-(xbar*xbar)) AS sd
from (
SELECT da.officerId,rrq.sectionRQid,sum(point)/count(point) AS xbar,sum(point*point)/count(point) AS sumpow2
FROM DoAssessment da
INNER JOIN DefineAssessment df ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear LIKE '$xacadYear'
AND df.semester LIKE '$xsemester'
AND df.defineid LIKE '$xdefineid'
AND df.assid LIKE '$xassid'
GROUP BY da.officerId,rrq.sectionRQid
)inn2
)B,(
SELECT * FROM OfficerAssess WHERE ofSitId LIKE '$xOfSitId'
)C
WHERE of1=of2 AND of2=C.officerId
order by txbar desc ,tsd desc ,B.sectionRQid
")){
return 1;
}else {
return 0;
}
}
// SumXbarSD --/04/2552
function SumOverviewCollage($xassid, $xacadYear, $xsemester, $xdefineid, $xOfSitId)
{
if ($this->SetQuery("
SELECT sectionRQid, xbar,sd
FROM (
SELECT rrq.sectionRQid, sum(point)/count(point) AS xbar, sqrt(sum(point*point)/count(point) - (sum(point)/count(point)*sum(point)/count(point))) AS sd
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
INNER JOIN OfficerAssess oa ON oa.officerId = da.officerId
WHERE df.assid LIKE '$xassid'
AND df.acadYear LIKE '$xacadYear'
AND df.semester LIKE '$xsemester'
AND df.defineid LIKE '$xdefineid'
AND oa.ofSitId LIKE '$xOfSitId'
GROUP BY rrq.sectionRQid
)inn2
")){
return 1;
}else {
return 0;
}
}
function CountDoidByDefineIdCourseIdClassIdOfficerid($xdefineid,$xcourseId,$xclassId,$xofficerId){
$this->SetQuery("select count(distinct studentId) as num from DoAssessment where defineid= '$xdefineid' and courseId = '$xcourseId' and classId LIKE '$xclassId' and officerId LIKE '$xofficerId'");
$result = $this->GetResult();
return $result['num'];
}
function RSDoidByDefineidOfficeridClassIdCourseId($xdefineid,$xofficerId,$xclassId,$xcourseId){
if ($this->SetQuery("select doid from DoAssessment where defineid= '$xdefineid' and officerId LIKE '$xofficerId' and classId LIKE '$xclassId' and courseId LIKE '$xcourseId' order by classId,doid")){
return 1;
}else {
return 0;
}
}
} //--End class DoAssessment--
?>
|