Viewing file: clsClassAssess.php (19.33 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//--Class ClassAssess--------------------------
//--PK of ClassAssess ::
// 1. classId
class ClassAssess extends clsDB{
var $result;
var $classId;
var $programId;
var $acadYear;
var $semester;
var $studentYear;
var $courseId;
var $sectionClass;
var $section;
var $totalSeat;
var $enrollSeat;
var $classTime;
var $officerId;
function ClassAssess(&$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->classId=$this->GetNextCode();
$sql = "insert into ClassAssess values(
'$this->classId',
'$this->programId',
'$this->acadYear',
'$this->semester',
'$this->studentYear',
'$this->courseId',
'$this->sectionClass',
'$this->section',
'$this->totalSeat',
'$this->enrollSeat',
'$this->classTime',
'$this->officerId'
)";
}else {
$sql = "update ClassAssess set
programId='$this->programId',
acadYear='$this->acadYear',
semester='$this->semester',
studentYear='$this->studentYear',
courseId='$this->courseId',
sectionClass='$this->sectionClass',
section='$this->section',
totalSeat='$this->totalSeat',
enrollSeat='$this->enrollSeat',
classTime='$this->classTime',
officerId='$this->officerId'
where classId='$this->classId'";
}
return $this->Dml($sql);
}
function Delete(){
//--ลบข้อมูลเดิมในอ๊อบเจ๊ก, เป็นการลบข้อมูลทีละ 1 เรคอร์ด
//--ต้องเรียกเมธอดตามลำดับดังนี้ SearchByKey()-->GetRecord()-->Delete()
return $this->Dml("delete from ClassAssess where classId='$this->classId'");
}
function GetNextCode(){
//--หาค่าสูงสุดของฟิลด์ที่ใช้เป็นคีย์ของตาราง ในลักษณะ auto increment
//--ต้องเป็นฟิลด์ชนิดตัวเลขจำนวนเต็มเท่านั้น และไม่ได้กำหนดรหัสเองทางจอภาพ
$this->SetQuery("select max(classId) as num from ClassAssess");
if ($result=$this->GetResult()) {
return $result['num']+1;
}
}
function RSClassAssess(){
//--เมธอดที่ขึ้นต้นด้วย RS (ResultSet) มีความหมายว่าจะได้รับข้อมูลกลับมาจากการ select มากกว่า 1 เรคอร์ด
//--จะต้องเรียกเมธอด GetRecord() ด้วยเสมอ นำข้อมูลจาก ResultSet เข้าอ๊อบเจ๊ก
//--โดยสามารถเพิ่มเมธอดได้ตามต้องการ แต่ต้องขึ้นต้นด้วย RS
$this->SetQuery("select * from ClassAssess order by classId");
}
function GetRecord(){
//--นำข้อมูลจาก ResultSet มากำหนดให้กับแอตทริบิวต์ของอ๊อบเจ็ก
//--เรียก GetRecord() หนึ่งครั้ง จะเลื่อนตัวชี้เรคอร์ดไปอีกหนึ่งเรคอร์ด
if ($this->result = $this->GetResult()) {
$this->classId = $this->result['classId'];
$this->programId = $this->result['programId'];
$this->acadYear = $this->result['acadYear'];
$this->semester = $this->result['semester'];
$this->studentYear = $this->result['studentYear'];
$this->courseId = $this->result['courseId'];
$this->sectionClass = $this->result['sectionClass'];
$this->section = $this->result['section'];
$this->totalSeat = $this->result['totalSeat'];
$this->enrollSeat = $this->result['enrollSeat'];
$this->classTime = $this->result['classTime'];
$this->officerId = $this->result['officerId'];
return 1;
}else {
return 0;
}
}
function GetRecordJoin(){
//--นำข้อมูลจาก ResultSet มากำหนดให้กับแอตทริบิวต์ของอ๊อบเจ็ก
//--เรียก GetRecord() หนึ่งครั้ง จะเลื่อนตัวชี้เรคอร์ดไปอีกหนึ่งเรคอร์ด
if ($this->result = $this->GetResult()) {
$this->classId = $this->result['classId'];
$this->programId = $this->result['programId'];
$this->acadYear = $this->result['acadYear'];
$this->semester = $this->result['semester'];
$this->studentYear = $this->result['studentYear'];
$this->courseId = $this->result['courseId'];
$this->sectionClass = $this->result['sectionClass'];
$this->section = $this->result['section'];
$this->totalSeat = $this->result['totalSeat'];
$this->enrollSeat = $this->result['enrollSeat'];
$this->classTime = $this->result['classTime'];
$this->officerId = $this->result['officerId'];
return 1;
}else {
return 0;
}
}
function SearchByKey($xKey){
//--ค้นหาข้อมูลตาม PK ต้องระบุพารามิเตอร์ด้วย และต้องตามด้วยเมธอด GetRecord() เสมอ
if ($this->SetQuery("select * from ClassAssess where classId= '$xKey'")){
return 1;
}else {
return 0;
}
}
//****************** You can add new functions below **********************//
function DeleteClassAssessByAcadSem($xacadYear,$xsemester){
return $this->Dml("delete from ClassAssess where acadYear = '$xacadYear' and semester = '$xsemester'");
}
function SearchClassIdByAcadSem($xacadYear,$xsemester){
if ($this->SetQuery("select classId from ClassAssess where acadYear = '$xacadYear' and semester = '$xsemester' order by classId")){
return 1;
}else {
return 0;
}
}
function SearchByAcadSem($xacadYear,$xsemester){
if ($this->SetQuery("select * from ClassAssess where acadYear = '$xacadYear' and semester = '$xsemester' order by classId")){
return 1;
}else {
return 0;
}
}
function SearchByCourseIdAcadSem($xcourseId,$xacadYear,$xsemester){
if ($this->SetQuery("select * from ClassAssess where courseId = '$xcourseId' and acadYear = '$xacadYear' and semester = '$xsemester' order by programId, studentYear, section, classId")){
return 1;
}else {
return 0;
}
}
function JoinSearchByCourseIdAcadSemGroupOfficerId($xcourseId,$xacadYear,$xsemester){
if ($this->SetQuery("select * from ClassAssess A, ClassInStructorAssess B WHERE A.courseId = '$xcourseId' and A.acadYear = '$xacadYear' and A.semester = '$xsemester' and A.classId = B.classId group by B.officerId")){
return 1;
}else {
return 0;
}
}
function JoinSearchByCourseIdAcadSemOfficerIdGroupClassId($xcourseId,$xacadYear,$xsemester,$xofficerId){
if ($this->SetQuery("select * from ClassAssess A, ClassInStructorAssess B WHERE A.courseId = '$xcourseId' and A.acadYear = '$xacadYear' and A.semester = '$xsemester' and B.officerId = '$xofficerId' and A.classId = B.classId group by A.classId order by programId,studentYear,section")){
return 1;
}else {
return 0;
}
}
function JoinSearchByCourseIdAcadSemGroupClassId($xcourseId,$xacadYear,$xsemester){
if ($this->SetQuery("select * from ClassAssess A, ClassInStructorAssess B WHERE A.courseId = '$xcourseId' and A.acadYear = '$xacadYear' and A.semester = '$xsemester' and A.classId = B.classId group by A.classId order by programId,studentYear,section")){
return 1;
}else {
return 0;
}
}
function JoinSearchByCourseIdAcadSemSectionGroupClassIdProgramId($xcourseId,$xacadYear,$xsemester,$xsection){
if ($this->SetQuery("select * from ClassAssess A, ClassInStructorAssess B WHERE A.courseId = '$xcourseId' and A.acadYear = '$xacadYear' and A.semester = '$xsemester' and A.classId = B.classId and A.section = '$xsection' group by A.classId, A.programId order by programId,studentYear,section")){
return 1;
}else {
return 0;
}
}
function SearchClassIdCourseIdByAcadSemOfficer($xacadYear,$xsemester,$xofficerId){
if ($this->SetQuery("select * From ClassAssess A, ClassInStructorAssess B where A.classId = B.classId and A.acadYear = '$xacadYear' and A.semester = '$xsemester' and B.officerId = '$xofficerId' order by A.programId, A.courseId,A.studentYear,A.section")){
return 1;
}else {
return 0;
}
}
function SearchClassIdCourseIdByAcadSemOfficerGroupClassId($xacadYear,$xsemester,$xofficerId){
if ($this->SetQuery("select * From ClassAssess A, ClassInStructorAssess B where A.classId = B.classId and A.acadYear = '$xacadYear' and A.semester = '$xsemester' and B.officerId = '$xofficerId' group by A.classId order by A.programId, A.courseId,A.studentYear,A.section ")){
return 1;
}else {
return 0;
}
}
// 8/11/2549
function SearchJoinByAcadSemOfficerSectionGroupClassId($xacadYear,$xsemester,$xofficerId,$xsection){
if ($this->SetQuery("select * From ClassAssess A, ClassInStructorAssess B where A.classId = B.classId and A.acadYear = '$xacadYear' and A.semester = '$xsemester' and B.officerId = '$xofficerId' and A.section = '$xsection' group by A.classId order by A.programId, A.courseId,A.studentYear,A.section ")){
return 1;
}else {
return 0;
}
}
// 12/11/2549
function SearchJoinByAcadSemSectionGroupClassId($xacadYear,$xsemester,$xsection){
if ($this->SetQuery("select * From ClassAssess A, ClassInStructorAssess B where A.classId = B.classId and A.acadYear = '$xacadYear' and A.semester = '$xsemester' and A.section = '$xsection' group by A.classId order by A.programId, A.courseId,A.studentYear,A.section ")){
return 1;
}else {
return 0;
}
}
function RSCourseIdTeachByAcadSemOfficer($xacadYear,$xsemester,$xofficerId){
if ($this->SetQuery("select A.courseId,A.studentYear,A.programId From ClassAssess A, ClassInStructorAssess B where A.classId = B.classId and A.acadYear = '$xacadYear' and A.semester = '$xsemester' and B.officerId = '$xofficerId' group by A.courseId,A.studentYear order by A.studentYear,A.courseId")){
return 1;
}else {
return 0;
}
}
function SearchByAcadSemGroupAndOrderByCourseId($xacadYear,$xsemester){
if ($this->SetQuery("select * from ClassAssess where acadYear = '$xacadYear' and semester = '$xsemester' group by courseId order by courseId")){
return 1;
}else {
return 0;
}
}
function SearchLimitJointClassCourseByAcadSemGroupAndOrderByCourseId($xacadYear,$xsemester,$xstart,$xpageSize){
if ($this->SetQuery("select * From ClassAssess A, CourseAssess B where acadYear = '$xacadYear' and semester = '$xsemester' and A.courseId = B.courseId group by A.courseId order by courseCode limit $xstart, $xpageSize")){
return 1;
}else {
return 0;
}
}
function CountClassIdAtAcadSem($xacadYear,$xsemester){
$this->SetQuery("select count(*) as num from ClassAssess where acadYear = '$xacadYear' and semester = '$xsemester'");
$result = $this->GetResult();
return $result['num'];
}
function SearchLimitPageByAcadSem($xacadYear,$xsemester,$xstart, $xpageSize){
$this->SetQuery("select * from ClassAssess where acadYear = '$xacadYear' and semester = '$xsemester' order by programId, studentYear, courseId, section limit $xstart, $xpageSize");
}
function SearchJoinClassCISByCourseIdGroupOfficerId($xcourseId){
$this->SetQuery("select * from ClassAssess A, ClassInStructorAssess B WHERE A.classId = B.classId and A.courseId = '$xcourseId' group by B.officerId");
}
// closeDate
function RSClassAssessByAcYAndSeAndOfIdGroupCoId($acY, $se, $ofId){
$this->SetQuery("select cl.courseId from ClassAssess cl, ClassInStructorAssess ci
where cl.acadYear='$acY' and cl.semester='$se' and cl.classId=ci.classId
and ci.officerId='$ofId' group by cl.courseId");
}
// หารายวิชาที่รับผิดชอบส่งเกรด
function SearchClassIdByAcadSemOfficerGroupClassId($xacadYear,$xsemester,$xofficerId){
if ($this->SetQuery("select * From ClassAssess
where acadYear = '$xacadYear'
and semester = '$xsemester'
and officerId = '$xofficerId'
order by studentYear , courseId,section")){
return 1;
}else {
return 0;
}
}
// For Flag 0 and 5
function RSClassIdByDefineidCourseId($defineid,$courseId){
if($this->SetQuery(" SELECT DISTINCT classId
FROM ClassAssess ca
JOIN DefineAssessment df
ON ca.acadYear = df.acadYear
AND ca.semester = df.semester
WHERE df.defineid = '$defineid'
AND ca.courseId = '$courseId'
ORDER BY classId"))
{
return 1;
}else{
return 0;
}
}
// For Flag 6 and 8
function RSClassIdHoldByDefineidCourseId($defineid,$courseId){
if($this->SetQuery(" SELECT DISTINCT hc.classId
FROM ClassAssess ca
JOIN DefineAssessment df
ON ca.acadYear = df.acadYear
AND ca.semester = df.semester
JOIN HoldCourse hc
ON hc.Defineid = df.Defineid
WHERE df.defineid = '$defineid'
AND ca.courseId = '$courseId'
ORDER BY hc.classId"))
{
return 1;
}else{
return 0;
}
}
function DistinctProgramIdByCourseIdAcYSem($courseId,$acadYear,$semester){
if($this->SetQuery("
(
select programId as programId from ClassAssess
where courseId = '$courseId' AND programId != '0'
AND acadYear = '$acadYear' AND semester = '$semester'
)
UNION DISTINCT
(
select cof.programId as programId from ClassAssess ca
join ClassOpenForAssess cof ON ca.classId = cof.classId
where ca.courseId = '$courseId' AND ca.acadYear = '$acadYear' AND ca.semester = '$semester'
)"))
{
return 1;
}else{
return 0;
}
}
function RSByAcYSemPgIdCoIdOfId($xacadYear,$xsemester,$xprogramId,$xcourseId,$xofficerId){
// echo $xacadYear.' '.$xsemester.' '.$xprogramId.' '.$xcourseId.' '.$xofficerId;
if($this->SetQuery("
SELECT DISTINCT ca2.classId ,ca2.studentYear ,ca2.section FROM ClassAssess ca2
JOIN ClassInStructorAssess cis ON ca2.classId = cis.classId
JOIN
((
select classId from ClassAssess
where acadYear = '$xacadYear' AND semester = '$xsemester'
AND programId = '$xprogramId' AND courseId = '$xcourseId'
)
UNION DISTINCT
(
select cof.classId from ClassAssess ca
join ClassOpenForAssess cof ON ca.classId = cof.classId
where ca.acadYear = '$xacadYear' AND ca.semester = '$xsemester'
AND cof.programId = '$xprogramId' AND ca.courseId = '$xcourseId'
))r1 ON cis.classId = r1.classId
WHERE cis.officerId LIKE '$xofficerId'
ORDER BY ca2.classId
"))
{
return 1;
}else{
return 0;
}
}
function RSClassOfficerByUnionCisTT($xacadYear,$xsemester){
if($this->SetQuery("
SELECT ca.classId, cis.officerId
FROM ClassAssess ca
JOIN ClassInStructorAssessTmp cis ON ca.classId = cis.classId
WHERE ca.acadYear = '$xacadYear'
AND ca.semester = '$xsemester'
UNION
SELECT distinct ca.classId, tt.ttOfId as officerId
FROM ClassAssess ca
JOIN TimeTableAssessTmp tt ON ca.classId = tt.ttClId
WHERE ca.acadYear = '$xacadYear'
AND ca.semester = '$xsemester'
"))
{
return 1;
}else{
return 0;
}
}
// HoldPlace
function RSHoldPlaceLimitByAcadSem($xacadYear,$xsemester,$xstart, $xpageSize){
$this->SetQuery("SELECT cl.*
FROM ClassAssess cl
JOIN TimeTableAssess tt ON ttClId = classId
WHERE acadYear = '$xacadYear'
AND semester = '$xsemester'
AND ( ttRmId = 0 || ttRmId IS NULL )
AND ttEpMepId > 0
group by classId
order by programId, studentYear, courseId,section
limit $xstart, $xpageSize");
return 1;
}
function CountClassIdHoldPlaceAByAcYSem($xacadYear,$xsemester){
$sql = "SELECT COUNT( DISTINCT (classId) ) as num
FROM ClassAssess cl
JOIN TimeTableAssess tt ON ttClId = classId
WHERE acadYear = '$xacadYear'
AND semester = '$xsemester'
AND ( ttRmId = 0 || ttRmId IS NULL )
AND ttEpMepId > 0";
$this->SetQuery($sql);
$result = $this->GetResult();
return $result['num'];
}
function RSByAcYSePgCoMepSep($acY,$se,$pg,$co,$mep,$sep){
if($this->SetQuery("
SELECT cl.*
FROM ClassAssess cl
JOIN TimeTableAssess tt
ON ttClId = cl.classId
JOIN ea_MainExternalPlace mep
ON ttEpMepId = mepId
JOIN ea_SubExternalPlace sep
ON ttEpSepId = sepId
LEFT JOIN ClassOpenForAssess cof
ON cl.classId = cof.classId
WHERE acadYear = '$acY'
AND semester = '$se'
AND ( cl.programId = '$pg' OR cof.programId = '$pg' )
AND courseId = '$co'
AND ttEpMepId = '$mep'
AND ttEpSepId = '$sep'
GROUP BY cl.classId
"))
{
return 1;
}else{
return 0;
}
}
// ค้นหารรายวิชาที่ส่งเกรด
function RSClassOfficer($xacadYear,$xsemester,$xofficerId){
if ($this->SetQuery("select *
from ClassAssess
where acadYear = '$xacadYear'
and semester = '$xsemester'
and officerId = '$xofficerId'
group by courseId,studentYear
order by studentYear,courseId")){
return 1;
}else {
return 0;
}
}
// ค้นหารรายวิชาที่สอน
function RSClassTeach($xacadYear,$xsemester,$xofficerId){
if ($this->SetQuery("
SELECT cl .*
FROM ClassAssess cl
INNER JOIN ClassInStructorAssess cla ON cla.classId = cl.classId
WHERE cl.acadYear = '$xacadYear'
AND cl.semester = '$xsemester'
AND cla.officerId = '$xofficerId'
group by courseId,studentYear
order by studentYear,courseId
")){
return 1;
}else {
return 0;
}
}
// ค้นหากลุ่มที่เปิดสอน ในรายวิชาที่สอน
function RSByAcYSemCoIdOfId($xacadYear,$xsemester,$xcourseId,$xofficerId){
// echo $xacadYear.' '.$xsemester.' '.$xprogramId.' '.$xcourseId.' '.$xofficerId;
$con = ($xofficerId!='%')?"AND cis.officerId = $xofficerId":'';
$scon = '';
$scon = ($xsemester!='%')?"AND semester = $xsemester":'';
$scon = ($xcourseId!='%')?"AND courseId = $xcourseId":'';
if($this->SetQuery("
SELECT DISTINCT ca2.classId ,ca2.studentYear ,ca2.section FROM ClassAssess ca2
JOIN ClassInStructorAssess cis ON ca2.classId = cis.classId
JOIN
((
select classId from ClassAssess
where acadYear = '$xacadYear'
$scon
)
UNION DISTINCT
(
select cof.classId from ClassAssess ca
join ClassOpenForAssess cof ON ca.classId = cof.classId
where ca.acadYear = '$xacadYear'
$scon
))r1 ON cis.classId = r1.classId
WHERE 1=1 $con
ORDER BY ca2.classId
"))
{
return 1;
}else{
return 0;
}
}
// หลักหลักสูตรของผู้รับผิดวิชา
function getProgramIdOwner($xacadYear,$xsemester,$xofficerId){
if($this->SetQuery("
(
select distinct programId
from ClassAssess ca
where ca.acadYear = '$xacadYear'
AND ca.semester = '$xsemester'
AND ca.officerId = '$xofficerId'
)
UNION DISTINCT
(
select distinct ca.programId
from ClassAssess ca
join ClassOpenForAssess cof ON ca.classId = cof.classId
where ca.acadYear = '$xacadYear'
AND ca.semester = '$xsemester'
AND ca.officerId = '$xofficerId'
)
"))
{
return 1;
}else{
return 0;
}
}
// หลักหลักสูตรของผู้สอน
function getProgramIdOfficer($xacadYear,$xsemester,$xofficerId){
if($this->SetQuery("
(
select distinct programId
from ClassAssess ca
inner join ClassInStructorAssess cis ON ca.classId = cis.classId
where ca.acadYear = '$xacadYear'
AND ca.semester = '$xsemester'
AND cis.officerId = '$xofficerId'
)
UNION DISTINCT
(
select distinct ca.programId
from ClassAssess ca
inner join ClassOpenForAssess cof ON ca.classId = cof.classId
inner join ClassInStructorAssess cis ON ca.classId = cis.classId
where ca.acadYear = '$xacadYear'
AND ca.semester = '$xsemester'
AND cis.officerId = '$xofficerId'
)
"))
{
return 1;
}else{
return 0;
}
}
} //--End class ClassAssess--
?>
|