Viewing file: 2553-04-05-1.1.11-clsResultRQ.php (26.33 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//--Class ResultRQ--------------------------
//--PK of ResultRQ ::
// 1. resultRQid
// avg( point ) AS xbar, STDDEV(point)
class ResultRQ extends clsDB{
var $result;
var $resultRQid;
var $doid;
var $sectionRQid;
var $RQid;
var $point;
var $xbar;
var $sd;
var $section;
var $per;
var $num;
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'];
$this->per = $this->result['per'];
$this->num = $this->result['num'];
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 SearchByDoid($xKey){
//--ค้นหาข้อมูลตาม PK ต้องระบุพารามิเตอร์ด้วย และต้องตามด้วยเมธอด GetRecord() เสมอ
if ($this->SetQuery("select * from ResultRQ where doid= '$xKey' order by resultRQid")){
return 1;
}else {
return 0;
}
}
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 CountPointJoinByRQidDefineidOfficerIdClassIdPointCo($xRQid,$xdefineid,$xofficerId,$xclassId,$xscore,$xcourseId,$ttId='%',$mepId='%',$sepId='%'){
$cond = '';
$cond.= ($xclassId!='%')? " and classId = $xclassId" : '' ;
$cond.= ($xofficerId!='%')? " and officerId = $xofficerId" : '' ;
$cond.= ($xcourseId!='%')? " and courseId = $xcourseId" : '' ;
$cond.= ($ttId!='%')? " and ttId = $ttId" : '' ;
$cond.= ($mepId!='%')? " and mepId = $mepId" : '' ;
$cond.= ($sepId!='%')? " and sepId = $sepId" : '' ;
$this->SetQuery("select count(point) as num
from DoAssessment A
JOIN ResultRQ B on A.doid = B.doid
WHERE RQid = '$xRQid'
and defineid = '$xdefineid'
and point = '$xscore'
$cond
");
$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'];
}
//2009 - 2010
function SearchResultIXbarSDByAcadSemDefineidOfficerIdClassIdSectionRQidCo($full,$xacadYear,$xsemester,$xdefineid,$xofficerId,$xclassId,$xsectionRQid,$xcourseId,$mepId='%',$sepId='%'){
$cond = '';
$cond.= ($xclassId!='%')? " and da.classId = $xclassId" : '' ;
$cond.= ($xofficerId!='%')? " and da.officerId = $xofficerId" : '' ;
$cond.= ($xcourseId!='%')? " and da.courseId = $xcourseId" : '' ;
$cond.= ($sepId!='%')? " and da.sepId = $sepId" : '' ;
$cond.= ($sepId!='%')? " and da.sepId = $sepId" : '' ;
if ($this->SetQuery("
SELECT (xbar/$full)*100 AS per, xbar, sd
FROM(
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 rrq.sectionRQid = '$xsectionRQid'
$cond
)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'
$cond
)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 rrq.sectionRQid = '$xsectionRQid'
$cond
)r3
)r4
")){
return 1;
}else {
return 0;
}
}
function SearchResultIXbarSDEachRQidByAcadSemDefineidOfficerIdClassIdSectionRQidCo($Full,$xacadYear,$xsemester,$xdefineid,$xofficerId,$xclassId,$xsectionRQid,$xRQid,$xcourseId,$mepId='%',$sepId='%'){
$cond = '';
$cond.= ($xclassId!='%')? " and da.classId = $xclassId" : '' ;
$cond.= ($xofficerId!='%')? " and da.officerId = $xofficerId" : '' ;
$cond.= ($xcourseId!='%')? " and da.courseId = $xcourseId" : '' ;
$cond.= ($mepId!='%')? " and da.mepId = $mepId" : '' ;
$cond.= ($sepId!='%')? " and da.sepId = $sepId" : '' ;
if ($this->SetQuery("
SELECT ( xbar/$Full )*100 AS per, xbar, sd
FROM (
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 rrq.sectionRQid = '$xsectionRQid'
AND rrq.RQid = '$xRQid'
$cond
)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'
$cond
)r2
)r3
")){
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($Full,$xacadYear,$xsemester,$xdefineid,$xofficerId,$xclassId,$xsectionRQid,$xRQid,$xttId){
$cond = '';
$cond.= ($xclassId!='%')? " and da.classId = $xclassId" : '' ;
$cond.= ($xofficerId!='%')? " and da.officerId = $xofficerId" : '' ;
$cond.= ($xttId!='%')? " and da.ttId = $xttId" : '' ;
if ($this->SetQuery("
SELECT ( xbar /$Full ) *100 AS per, xbar, sd
FROM (
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 rrq.sectionRQid = '$xsectionRQid'
AND rrq.RQid = '$xRQid'
$cond
) 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'
$cond
) as r2
)r3
")){
return 1;
}else {
return 0;
}
}
function SearchResultIXbarSDByAcadSemDefineidOfficerIdClassIdSectionRQidttId($full,$xacadYear,$xsemester,$xdefineid,$xofficerId,$xclassId,$xsectionRQid,$xttId){
$cond = '';
$cond.= ($xclassId!='%')? " and da.classId = $xclassId" : '' ;
$cond.= ($xofficerId!='%')? " and da.officerId = $xofficerId" : '' ;
$cond.= ($xttId!='%')? " and da.ttId = $xttId" : '' ;
if ($this->SetQuery("
SELECT (xbar/$full)*100 AS per, xbar, sd
FROM(
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 rrq.sectionRQid = '$xsectionRQid'
$cond
)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'
$cond
)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 rrq.sectionRQid = '$xsectionRQid'
$cond
)r3
)r4
")){
return 1;
}else {
return 0;
}
}
function RSXbarSDEachRQidByAcadSemDefineidOfficerIdCourseIdSectionRQid($fullMark,$xacadYear,$xsemester,$xdefineid,$xofficerId,$xcourseId,$xsectionRQid,$xRQid){
//echo $fullMark.' , '.$xacadYear.' , '.$xsemester.' , '.$xdefineid.' , '.$xofficerId.' , '.$xcourseId.' , '.$xsectionRQid.' , '.$xRQid.'<br>';
if ($this->SetQuery("
SELECT section, (xbar/$fullMark)*100 AS per, xbar, sd
FROM(
SELECT r1.section ,total / (doAss) AS xbar, SQRT((sumpow / (doAss))-pow(total/(doAss),2)) AS sd
FROM
(
SELECT da.section,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.courseId = '$xcourseId'
AND rrq.sectionRQid = '$xsectionRQid'
AND rrq.RQid = '$xRQid'
group by da.section
)r1, (
SELECT da.section ,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.courseId = '$xcourseId'
group by da.section
)r2
where r1.section = r2.section
)r3 where 1
")){
return 1;
}else {
return 0;
}
}
function RSXbarSDByAcadSemDefineidOfficerIdCourseIdSectionRQid($fullMark,$xacadYear,$xsemester,$xdefineid,$xofficerId,$xcourseId,$xsectionRQid){
if ($this->SetQuery("
SELECT r1.section, ((total / (doAss * numRQ))/$fullMark)*100 AS per, total / (doAss * numRQ) AS xbar, SQRT((sumpow / (doAss * numRQ))-pow(total/(doAss * numRQ),2)) AS sd
FROM
(
SELECT da.section, 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.courseId = '$xcourseId'
AND rrq.sectionRQid = '$xsectionRQid'
GROUP BY da.section
)r1, (
SELECT da.section ,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.courseId = '$xcourseId'
GROUP BY da.section
)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 rrq.sectionRQid = '$xsectionRQid'
)r3
WHERE r1.section=r2.section
GROUP BY r1.section
")){
return 1;
}else {
return 0;
}
}
function Search54ByAcadSemDefineidCourseIdOfficerIdClassIdSectionRQid($xacadYear,$xsemester,$xdefineid,$xofficerId,$xcourseId,$xclassId,$xsectionRQid){
$cond = '';
$cond.= ($xclassId!='%')? " and da.classId = $xclassId" : '' ;
$cond.= ($xofficerId!='%')? " and da.officerId = $xofficerId" : '' ;
$cond.= ($xcourseId!='%')? " and da.courseId = $xcourseId" : '' ;
if ($this->SetQuery("
SELECT r1.num ,r1.num/(r2.doAss*r3.RQid)*100 AS per
FROM (
SELECT count( * ) AS num
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'
$cond
AND rrq.sectionRQid = '$xsectionRQid'
AND point <= '5' AND point >= '4'
)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'
$cond
)r2,(
SELECT count(*) AS RQid
FROM RadioQuestion rq
WHERE sectionRQid = '$xsectionRQid'
AND subtract = '1'
)r3
")){
return 1;
}else {
return 0;
}
}
function surplusRRQ($xdefineid,$xofficerId,$xclassId){
if ($this->SetQuery("SELECT *
FROM (
SELECT rrq. * , dateAss, officerId
FROM ResultRQ rrq
JOIN DoAssessment da ON rrq.doid = da.doid
WHERE da.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
)r1
INNER JOIN (
SELECT rrq. *
FROM ResultRQ rrq
JOIN DoAssessment da ON rrq.doid = da.doid
WHERE da.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
)r2 ON r1.doid = r2.doid
WHERE r1.resultRQid < r2.resultRQid
AND r1.sectionRQid = r2.sectionRQid
AND r1.RQid = r2.RQid
ORDER BY r1.RQid, r1.sectionRQid, r1.doid, r1.resultRQid
")){
return 1;
}else {
return 0;
}
}
function overRRQ($xdefineid,$xofficerId,$xclassId){
if ($this->SetQuery("SELECT r1.*
FROM (
SELECT rrq. *
FROM ResultRQ rrq
JOIN DoAssessment da ON rrq.doid = da.doid
WHERE da.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
)r1
INNER JOIN (
SELECT rrq. *
FROM ResultRQ rrq
JOIN DoAssessment da ON rrq.doid = da.doid
WHERE da.defineid = '$xdefineid'
AND da.officerId = '$xofficerId'
AND da.classId = '$xclassId'
)r2 ON r1.doid = r2.doid
WHERE r1.resultRQid < r2.resultRQid
AND r1.sectionRQid = r2.sectionRQid
AND r1.RQid = r2.RQid
ORDER BY r1.RQid, r1.sectionRQid, r1.doid, r1.resultRQid
")){
return 1;
}else {
return 0;
}
}
function deleteByKey($key){
return $this->Dml("delete from ResultRQ where resultRQid='$key'");
}
function RSXbarSD($acadYear, $semester, $assid, $defineid, $courseId, $classId, $officerId, $ttId, $mepId, $sepId, $RQid, $sectionRQid){
$cond = '';
$cond.= ($defineid!='%')? " AND df.defineid = $defineid" : '' ;
$cond.= ($courseId!='%')? " AND da.courseId = $courseId" : '' ;
$cond.= ($classId!='%')? " AND da.classId = $classId" : '' ;
$cond.= ($officerId!='%')? " AND da.officerId = $officerId" : '' ;
$cond.= ($ttId!='%')? " AND da.ttId = $ttId" : '' ;
$cond.= ($mepId!='%')? " and da.mepId = $mepId" : '' ;
$cond.= ($sepId!='%')? " and da.sepId = $sepId" : '' ;
$cond.= ($RQid!='%')? " AND rrq.RQid = $RQid" : '' ;
$cond.= ($sectionRQid!='%')? " AND rrq.sectionRQid = $sectionRQid" : '' ;
$sql = "
SELECT (r1.xbar/r2.score)*100 AS per, r1.xbar AS xbar, r1.sd AS sd
FROM
(
SELECT rrq.sectionRQid, avg( point ) AS xbar, STDDEV(point) AS sd
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear = '$acadYear'
AND df.semester = '$semester'
AND df.assid = '$assid'
$cond
GROUP BY rrq.RQid, rrq.sectionRQid
)r1,(
SELECT MAX(score) AS score
FROM HeaderQuestion hq
INNER JOIN DetailScore ds ON ds.Hsid = hq.Hsid
WHERE hq.assid = '$assid'
)r2
";
if ($this->SetQuery($sql)){
return 1;
}else {
return 0;
}
}
function SumSectionRQidXbarSD($acadYear, $semester, $assid, $defineid, $courseId, $classId, $officerId, $ttId, $mepId, $sepId, $RQid, $sectionRQid){
$cond = '';
$cond.= ($defineid!='%')? " AND df.defineid = $defineid" : '' ;
$cond.= ($courseId!='%')? " AND da.courseId = $courseId" : '' ;
$cond.= ($classId!='%')? " AND da.classId = $classId" : '' ;
$cond.= ($officerId!='%')? " AND da.officerId = $officerId" : '' ;
$cond.= ($ttId!='%')? " AND da.ttId = $ttId" : '' ;
$cond.= ($mepId!='%')? " and da.mepId = $mepId" : '' ;
$cond.= ($sepId!='%')? " and da.sepId = $sepId" : '' ;
$cond.= ($RQid!='%')? " AND rrq.RQid = $RQid" : '' ;
$cond.= ($sectionRQid!='%')? " AND rrq.sectionRQid = $sectionRQid" : '' ;
$sql = "
SELECT r1.sectionRQid, (r1.xbar/r2.score)*100 AS per, r1.xbar AS xbar, r1.sd AS sd
FROM
(
SELECT rrq.sectionRQid, avg( point ) AS xbar, STDDEV(point) AS sd
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear = '$acadYear'
AND df.semester = '$semester'
AND df.assid = '$assid'
$cond
GROUP BY rrq.sectionRQid
)r1,(
SELECT MAX(score) AS score
FROM HeaderQuestion hq
INNER JOIN DetailScore ds ON ds.Hsid = hq.Hsid
WHERE hq.assid = '$assid'
)r2
";
if ($this->SetQuery($sql)){
return 1;
}else {
return 0;
}
}
function SumXbarSD($acadYear, $semester, $assid, $defineid, $courseId, $classId, $officerId, $ttId, $mepId, $sepId){
$cond = '';
$cond.= ($defineid!='%')? " AND df.defineid = $defineid" : '' ;
$cond.= ($courseId!='%')? " AND da.courseId = $courseId" : '' ;
$cond.= ($classId!='%')? " AND da.classId = $classId" : '' ;
$cond.= ($officerId!='%')? " AND da.officerId = $officerId" : '' ;
$cond.= ($ttId!='%')? " AND da.ttId = $ttId" : '' ;
$cond.= ($mepId!='%')? " and da.mepId = $mepId" : '' ;
$cond.= ($sepId!='%')? " and da.sepId = $sepId" : '' ;
$sql = "
SELECT (r1.xbar/r2.score)*100 AS per, r1.xbar AS xbar, r1.sd AS sd
FROM
(
SELECT rrq.sectionRQid, avg( point ) AS xbar, STDDEV(point) AS sd
FROM DefineAssessment df
INNER JOIN DoAssessment da ON df.defineid = da.defineid
INNER JOIN ResultRQ rrq ON rrq.doid = da.doid
WHERE df.acadYear = '$acadYear'
AND df.semester = '$semester'
AND df.assid = '$assid'
$cond
)r1,(
SELECT MAX(score) AS score
FROM HeaderQuestion hq
INNER JOIN DetailScore ds ON ds.Hsid = hq.Hsid
WHERE hq.assid = '$assid'
)r2
";
if ($this->SetQuery($sql)){
return 1;
}else {
return 0;
}
}
} //--End class ResultRQ--
?>
|