Notes
This commit is contained in:
25
inc/catc.php
25
inc/catc.php
@@ -12,7 +12,8 @@ class CATC extends Main
|
||||
{
|
||||
$asClasses = array(
|
||||
array('name'=>'auth', 'project'=>true),
|
||||
array('name'=>'course', 'project'=>true)
|
||||
array('name'=>'course', 'project'=>true),
|
||||
array('name'=>'note', 'project'=>true)
|
||||
);
|
||||
parent::__construct($oClassManagement, $sProcessPage, $asClasses);
|
||||
|
||||
@@ -73,7 +74,7 @@ class CATC extends Main
|
||||
);
|
||||
|
||||
//Pages
|
||||
$asPages = array('logon', 'logoff', 'template', 'workshops');
|
||||
$asPages = array('logon', 'logoff', 'template', 'workshops', 'course');
|
||||
foreach($asPages as $sPage) $asGlobalVars['consts']['pages'][$sPage] = $this->getPageContent($sPage);
|
||||
|
||||
//Main Page
|
||||
@@ -136,12 +137,30 @@ class CATC extends Main
|
||||
return $this->oAuth->checkApiKey($sApiKey);
|
||||
}
|
||||
|
||||
/* Managing Courses */
|
||||
/* Workshops / Courses */
|
||||
|
||||
public function getWorkshops() {
|
||||
return self::getJsonResult(true, '', (new Course($this->oDb))->getWorkshops());
|
||||
}
|
||||
|
||||
/* Notes*/
|
||||
|
||||
public function getNote($iCourseId) {
|
||||
$oCourse = new Course($this->oDb, $iCourseId);
|
||||
$asNote = $oCourse->getNote();
|
||||
$iCourseId = $asNote[Db::getId(Course::COURSE_TABLE)];
|
||||
|
||||
return self::getJsonResult(($iCourseId > 0), '', array('id'=>$iCourseId, 'ops'=>$asNote['notes'], 'led'=>$asNote['led']));
|
||||
}
|
||||
|
||||
public function setNote($iCourseId, $asOps) {
|
||||
$oCourse = new Course($this->oDb, $iCourseId);
|
||||
$sError = $oCourse->setNote($asOps);
|
||||
$bSuccess = ($sError=='');
|
||||
|
||||
return self::getJsonResult(($sError==''), $sError, array('led' => $oCourse->getNote()['led']));
|
||||
}
|
||||
|
||||
/*
|
||||
public function upload()
|
||||
{
|
||||
|
||||
@@ -11,10 +11,41 @@ class Course extends PhpObject {
|
||||
*/
|
||||
private $oDb;
|
||||
|
||||
public function __construct(Db &$oDb)
|
||||
private $iCourseId;
|
||||
|
||||
public function __construct(Db &$oDb, $iCourseId=0)
|
||||
{
|
||||
parent::__construct(__CLASS__, Settings::DEBUG);
|
||||
$this->oDb = &$oDb;
|
||||
$this->setCourseId($iCourseId);
|
||||
}
|
||||
|
||||
public function getCourseId() {
|
||||
return $this->iCourseId;
|
||||
}
|
||||
|
||||
public function setCourseId($iCourseId) {
|
||||
$this->iCourseId = $iCourseId;
|
||||
}
|
||||
|
||||
public function getNote() {
|
||||
$asCourse = $this->oDb->selectRow(self::COURSE_TABLE, $this->getCourseId(), array(Db::getId(self::COURSE_TABLE), 'notes', 'led'));
|
||||
$asCourse['notes'] = json_decode($asCourse['notes'], true);
|
||||
|
||||
return $asCourse;
|
||||
}
|
||||
|
||||
public function setNote($asOps) {
|
||||
$sError = '';
|
||||
$sIdCol = Db::getId(self::COURSE_TABLE);
|
||||
|
||||
if($this->getCourseId() > 0) {
|
||||
$iCourseId = $this->oDb->insertUpdateRow(self::COURSE_TABLE, array($sIdCol=>$this->getCourseId(), 'notes'=>json_encode($asOps)), array($sIdCol));
|
||||
if(!$iCourseId) $sError = $this->oDb->getLastError();
|
||||
}
|
||||
else $sError = 'Course ID not set';
|
||||
|
||||
return $sError;
|
||||
}
|
||||
|
||||
public function getWorkshops() {
|
||||
|
||||
Reference in New Issue
Block a user