Viewing file: 2551-11-14-1.0.02-clsResultRQ.php (14.24 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//--Class ResultRQ--------------------------
//--PK of ResultRQ ::
// 1. resultRQid
class ResultRQ extends clsDB{
var $result;
var $resultRQid;
var $doid;
var $sectionRQid;
var $RQid;
var $point;
var $xbar;
var $sd;
function ResultRQ(&$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->resultRQid=$this->GetNextCode();
$sql = "insert into ResultRQ values(
'$this->resultRQid',
'$this->doid',
'$this->sectionRQid',
'$this->RQid',
'$this->point'
)";
}else {
$sql = "update ResultRQ set
doid='$this->doid',
sectionRQid='$this->sectionRQid',
RQid='$this->RQid',
point='$this->point'
where resultRQid='$this->resultRQid'";
}
return $this->Dml($sql);
}
function Delete(){
//--ลบข้อมูลเดิมในอ๊อบเจ๊ก, เป็นการลบข้อมูลทีละ 1 เรคอร์ด
//--ต้องเรียกเมธอดตามลำดับดังนี้ SearchByKey()-->GetRecord()-->Delete()
return $this->Dml("delete from ResultRQ where resultRQid='$this->resultRQid'");
}
function GetNextCode(){
//--หาค่าสูงสุดของฟิลด์ที่ใช้เป็นคีย์ของตาราง ในลักษณะ auto increment
//--ต้องเป็นฟิลด์ชนิดตัวเลขจำนวนเต็มเท่านั้น และไม่ได้กำหนดรหัสเองทางจอภาพ
$this->SetQuery("select max(resultRQid) as num from ResultRQ");
if ($result=$this->GetResult()) {
return $result['num']+1;
}
}
function RSResultRQ(){
//--เมธอดที่ขึ้นต้นด้วย RS (ResultSet) มีความหมายว่าจะได้รับข้อมูลกลับมาจากการ select มากกว่า 1 เรคอร์ด
//--จะต้องเรียกเมธอด GetRecord() ด้วยเสมอ นำข้อมูลจาก ResultSet เข้าอ๊อบเจ๊ก
//--โดยสามารถเพิ่มเมธอดได้ตามต้องการ แต่ต้องขึ้นต้นด้วย RS
$this->SetQuery("select * from ResultRQ order by resultRQid");
}
function GetRecord(){
//--นำข้อมูลจาก ResultSet มากำหนดให้กับแอตทริบิวต์ของอ๊อบเจ็ก
//--เรียก GetRecord() หนึ่งครั้ง จะเลื่อนตัวชี้เรคอร์ดไปอีกหนึ่งเรคอร์ด
if ($this->result = $this->GetResult()) {
$this->resultRQid = $this->result['resultRQid'];
$this->doid = $this->result['doid'];
$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 ResultRQ where resultRQid= '$xKey'")){
return 1;
}else {
return 0;
}
}
//****************** You can add new functions below **********************//
function SumPointByClassIdOfficerIdRQid($xdefineid,$xclassId,$xofficerId,$xRQid){
$this->SetQuery("select sum(point) as num from ResultRQ A, DoAssessment B where A.doid = B.doid and B.classId = '$xclassId' and B.officerId = '$xofficerId' and defineid = '$xdefineid' and RQid = '$xRQid' group by RQid");
//echo "<br> RQid = ".$xRQid;
$result = $this->GetResult();
return $result['num'];
}
//16/11/2006
function SumPointByAcadSemDefineIdOfficerIdRQidJoinClass($xacadYear,$xsemester,$xdefineid,$xofficerId,$xRQid){
$this->SetQuery("select sum(point) as num from ClassAssess A, DoAssessment B, ResultRQ C where acadYear = '$xacadYear' and semester = '$xsemester' and defineid = '$xdefineid' and B.officerId = '$xofficerId' and RQid = '$xRQid' and A.classId = B.classId and B.doid = C.doid");
//echo "<br> RQid = ".$xRQid;
$result = $this->GetResult();
return $result['num'];
}
/*function SumPointByAcadSemDefineIdOfficerIdRQidJoinClass2($xacadYear,$xsemester,$xdefineid,$xofficerId,$xRQid){
if ($this->SetQuery("select * from ClassAssess A, DoAssessment B, ResultRQ C where acadYear = '$xacadYear' and semester = '$xsemester' and defineid = '$xdefineid' and B.officerId = '$xofficerId' and RQid = '$xRQid' and A.classId = B.classId and B.doid = C.doid group by RQid")){
return 1;
}else {
return 0;
}
}*/
function SearchPointByClassIdOfficerIdRQid($xdefineid,$xclassId,$xofficerId,$xRQid){
if ($this->SetQuery("select point from ResultRQ A, DoAssessment B where B.classId = '$xclassId' and B.officerId = '$xofficerId' and defineid = '$xdefineid' and RQid = '$xRQid' and A.doid = B.doid")){
return 1;
}else {
return 0;
}
}
//16/11/2006
function SearchPointByDefineIdOfficerIdRQidJoinDoid($xdefineid,$xofficerId,$xRQid){
if ($this->SetQuery("select point from ResultRQ A, DoAssessment B where defineid = '$xdefineid' and officerId = '$xofficerId' and RQid = '$xRQid' and A.doid = B.doid")){
return 1;
}else {
return 0;
}
}
//21/11/2006
function PowSumPointByDefineIdOfficerIdRQidJoinDoid($xdefineid,$xofficerId,$xRQid){
$this->SetQuery("select sum(point*point) as num from ResultRQ A, DoAssessment B where defineid = '$xdefineid' and officerId = '$xofficerId' and RQid = '$xRQid' and A.doid = B.doid");
$result = $this->GetResult();
return $result['num'];
}
//21/11/2006
function NumPointByDefineIdOfficerIdRQidJoinDoid($xdefineid,$xofficerId,$xRQid){
$this->SetQuery("select count(point) as num from ResultRQ A, DoAssessment B where defineid = '$xdefineid' and officerId = '$xofficerId' and RQid = '$xRQid' and A.doid = B.doid");
$result = $this->GetResult();
return $result['num'];
}
function SearchPointByDoidRQid($xdoid,$xRQid){
if ($this->SetQuery("select point from ResultRQ where doid = '$xdoid' and RQid = '$xRQid'")){
return 1;
}else {
return 0;
}
}
function SearchPointByDoidSectionRQid($xdoid,$xsectionRQid){
if ($this->SetQuery("select point from ResultRQ where doid = '$xdoid' and sectionRQid = '$xsectionRQid' order by RQid")){
return 1;
}else {
return 0;
}
}
function CountPointJoinByRQidDefineidOfficerIdClassIdPoint($xRQid,$xdefineid,$xofficerId,$xclassId,$xscore){
$this->SetQuery("select count(point) as num from DoAssessment A ,ResultRQ B WHERE A.doid = B.doid and RQid = '$xRQid' and defineid = '$xdefineid' and officerId = '$xofficerId' and classId = '$xclassId'and point = '$xscore'");
$result = $this->GetResult();
return $result['num'];
}
//15/11/2006
function CountPointJoinByRQidDefineidOfficerIdClassIdPointBetweenValue($xRQid,$xdefineid,$xofficerId,$xclassId,$xscore1,$xscore2){
$this->SetQuery("select count(point) as num from DoAssessment A ,ResultRQ B WHERE A.doid = B.doid and
RQid = '$xRQid' and defineid = '$xdefineid' and officerId = '$xofficerId' and classId = '$xclassId'and point between '$xscore1' and '$xscore2'");
$result = $this->GetResult();
return $result['num'];
}
function CountPointJoinByRQidDefineidOfficerIdClassIdPointTtId($xRQid,$xdefineid,$xofficerId,$xclassId,$xscore,$xttId){
$this->SetQuery("select count(point) as num from DoAssessment A ,ResultRQ B WHERE A.doid = B.doid and RQid = '$xRQid' and defineid = '$xdefineid' and officerId = '$xofficerId' and classId = '$xclassId'and point = '$xscore' and A.ttId='$xttId' ");
$result = $this->GetResult();
return $result['num'];
}
//26/11/2006
function SearchResultIXbarSDByAcadSemDefineidOfficerIdClassIdSectionRQid($xacadYear,$xsemester,$xdefineid,$xofficerId,$xclassId,$xsectionRQid){
if ($this->SetQuery("
SELECT total / (doAss * numRQ) AS xbar, SQRT((sumpow / (doAss * numRQ))-pow(total/(doAss * numRQ),2)) AS sd
FROM
(
SELECT sum( point ) AS total, sum(point *point) AS sumpow
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
AND rrq.sectionRQid = '$xsectionRQid'
)r1, (
SELECT count(*) AS doAss
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da. defineid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
)r2, (
SELECT count( DISTINCT RQid ) AS numRQ
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
AND rrq.sectionRQid = '$xsectionRQid'
)r3
")){
return 1;
}else {
return 0;
}
}
function SearchResultIXbarSDEachRQidByAcadSemDefineidOfficerIdClassIdSectionRQid($xacadYear,$xsemester,$xdefineid,$xofficerId,$xclassId,$xsectionRQid,$xRQid){
if ($this->SetQuery("
SELECT total / (doAss) AS xbar, SQRT((sumpow / (doAss))-pow(total/(doAss),2)) AS sd
FROM
(
SELECT sum( point ) AS total, sum(point *point) AS sumpow
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
AND rrq.sectionRQid = '$xsectionRQid'
AND rrq.RQid = '$xRQid'
)r1, (
SELECT count(*) AS doAss
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da. defineid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
)r2
")){
return 1;
}else {
return 0;
}
}
//26/11/2006
function CountQuestionByAcadSemDefineidOfficerIdClassIdSectionRQid($xacadYear,$xsemester,$xdefineid,$xofficerId,$xclassId,$xsectionRQid){
$this->SetQuery("
SELECT count( DISTINCT RQid ) AS numRQ
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
AND rrq.sectionRQid = '$xsectionRQid'
");
$result = $this->GetResult();
return $result['numRQ'];
}
//26/11/2006
function CountPoint2ValueByAcadSemDefineidOfficerIdClassIdSectionRQid($xacadYear,$xsemester,$xdefineid,$xofficerId,$xclassId,$xsectionRQid,$xpoint1,$xpoint2){
$this->SetQuery("
SELECT count(point) AS numPoint
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
AND rrq.sectionRQid = '$xsectionRQid'
AND rrq.point between '$xpoint1' AND '$xpoint2'
");
$result = $this->GetResult();
return $result['numPoint'];
}
/*function SearchPointByDefineidClassIdOfficerIdSectionRQidJoinDoRRQ($xdefineid,$xclassId,$xofficerId,$xsectionRQid){ echo "<br> SELECT rrq.point
FROM DoAssessment da
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE da.defineid = '$xdefineid'
AND da.classId = '$xclassId'
AND da.officerId = '$xofficerId'
AND rrq.sectionRQid = '$xsectionRQid'
ORDER BY da.doid";
$this->SetQuery("
SELECT rrq.point
FROM DoAssessment da
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE da.defineid = '$xdefineid'
AND da.classId = '$xclassId'
AND da.officerId = '$xofficerId'
AND rrq.sectionRQid = '$xsectionRQid'
ORDER BY da.doid
");
$result = $this->GetResult();
return $result['numPoint'];
}*/
// 2008 include TimeTableAssess
function SearchResultIXbarSDEachRQidByAcadSemDefineidOfficerIdClassIdSectionRQidttId($xacadYear,$xsemester,$xdefineid,$xofficerId,$xclassId,$xsectionRQid,$xRQid,$xttId){
if ($this->SetQuery("
SELECT total / (doAss) AS xbar, SQRT((sumpow / (doAss))-pow(total/(doAss),2)) AS sd
FROM
(
SELECT sum( point ) AS total, sum(point *point) AS sumpow
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
AND da.ttId = '$xttId'
AND rrq.sectionRQid = '$xsectionRQid'
AND rrq.RQid = '$xRQid'
) as r1, (
SELECT count(*) AS doAss
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da. defineid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
AND da.ttId = '$xttId'
) as r2
")){
return 1;
}else {
return 0;
}
}
function SearchResultIXbarSDByAcadSemDefineidOfficerIdClassIdSectionRQidttId($xacadYear,$xsemester,$xdefineid,$xofficerId,$xclassId,$xsectionRQid,$xttId){
if ($this->SetQuery("
SELECT total / (doAss * numRQ) AS xbar, SQRT((sumpow / (doAss * numRQ))-pow(total/(doAss * numRQ),2)) AS sd
FROM
(
SELECT sum( point ) AS total, sum(point *point) AS sumpow
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
AND da.ttId = '$xttId'
AND rrq.sectionRQid = '$xsectionRQid'
)r1, (
SELECT count(*) AS doAss
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da. defineid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
AND da.ttId = '$xttId'
)r2, (
SELECT count( DISTINCT RQid ) AS numRQ
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear = '$xacadYear'
AND df.semester = '$xsemester'
AND df.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
AND da.ttId = '$xttId'
AND rrq.sectionRQid = '$xsectionRQid'
)r3
")){
return 1;
}else {
return 0;
}
}
} //--End class ResultRQ--
?>
|