From 92bc99ee8aee2ac57880c4240fb1a70e185cac34 Mon Sep 17 00:00:00 2001 From: Ashton Power <48048360+powertashton@users.noreply.github.com> Date: Fri, 13 Aug 2021 12:39:31 +0800 Subject: [PATCH 01/57] ATLColumnGateway and atl_manage --- ATL/atl_manage.php | 109 ++++++++-------------------- ATL/src/Domain/ATLColumnGateway.php | 24 ++++++ 2 files changed, 55 insertions(+), 78 deletions(-) create mode 100644 ATL/src/Domain/ATLColumnGateway.php diff --git a/ATL/atl_manage.php b/ATL/atl_manage.php index 24d2866..30dfb84 100644 --- a/ATL/atl_manage.php +++ b/ATL/atl_manage.php @@ -18,22 +18,21 @@ */ use Gibbon\Services\Format; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Domain\DataSet; +use Gibbon\Tables\DataTable; //Module includes include './modules/'.$session->get('module').'/moduleFunctions.php'; if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage.php') == false) { //Acess denied - echo "
"; - echo __('Your request failed because you do not have access to this action.'); - echo '
'; + $page->addError(__('You do not have access to this action.')); } else { //Get action with highest precendence $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; + $page->addError(__('The highest grouped action cannot be determined.')); } else { //Get class variable $gibbonCourseClassID = null; @@ -129,78 +128,32 @@ } echo ''; } - - //Print mark - echo '

'; - echo __('ATL Columns'); - echo '

'; - - //Set pagination variable - $page = 1; - if (isset($_GET['page'])) { - $page = $_GET['page']; - } - if ((!is_numeric($page)) or $page < 1) { - $page = 1; - } - - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT * FROM atlColumn WHERE gibbonCourseClassID=:gibbonCourseClassID ORDER BY completeDate DESC, name'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result->rowCount() < 1) { - echo "
"; - echo __('There are no records to display.'); - echo '
'; - } else { - echo ""; - echo ""; - echo ''; - echo ''; - echo ''; - echo ''; - - $count = 0; - $rowNum = 'odd'; - while ($row = $result->fetch()) { - if ($count % 2 == 0) { - $rowNum = 'even'; - } else { - $rowNum = 'odd'; - } - - //COLOR ROW BY STATUS! - echo ""; - echo ''; - echo ''; - echo ''; - echo ''; - - ++$count; - } - echo '
'; - echo __('Name'); - echo ''; - echo __('Date
Complete'); - echo '
'; - echo __('Actions'); - echo '
'; - echo ''.$row['name'].'
'; - echo '
'; - if ($row['complete'] == 'Y') { - echo dateConvertBack($guid, $row['completeDate']); - } - echo ''; - echo "get('module')."/atl_manage_edit.php&gibbonCourseClassID=$gibbonCourseClassID&atlColumnID=".$row['atlColumnID']."'> "; - echo "get('module')."/atl_manage_delete.php&gibbonCourseClassID=$gibbonCourseClassID&atlColumnID=".$row['atlColumnID']."&width=650&height=135'> "; - echo "get('module')."/atl_write_data.php&gibbonCourseClassID=$gibbonCourseClassID&atlColumnID=".$row['atlColumnID']."'> "; - echo '
'; - } + //TABLE + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlColumnData = $atlColumnGateway->selectBy(['gibbonCourseClassID' => $gibbonCourseClassID])->fetchAll(); + + $table = DataTable::create('atlColumns'); + $table->setTitle('ATL Columns'); + + $table->addColumn('name', __('Name')); + $table->addColumn('completeDate', __('Date Complete')); + $table->addActionColumn() + ->addParam('gibbonCourseClassID', $gibbonCourseClassID) + ->addParam('atlColumnID') + ->format(function ($row, $actions) use ($session) { + $actions->addAction('edit', __('Edit')) + ->setURL('/modules/' . $session->get('module') . '/atl_manage_edit.php'); + + $actions->addAction('delete', __('Delete')) + ->setURL('/modules/' . $session->get('module') . '/atl_manage_delete.php'); + + $actions->addAction('enterData', __('Enter Data')) + ->setURL('/modules/' . $session->get('module') . '/atl_write_data.php') + ->setIcon('markbook'); + + }); + + echo $table->render($atlColumnData); } } } diff --git a/ATL/src/Domain/ATLColumnGateway.php b/ATL/src/Domain/ATLColumnGateway.php new file mode 100644 index 0000000..566be22 --- /dev/null +++ b/ATL/src/Domain/ATLColumnGateway.php @@ -0,0 +1,24 @@ + Date: Fri, 13 Aug 2021 12:50:55 +0800 Subject: [PATCH 02/57] some refactored errors --- ATL/atl_manage_add.php | 12 +++--------- ATL/atl_manage_delete.php | 16 ++++------------ 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/ATL/atl_manage_add.php b/ATL/atl_manage_add.php index 152a5c1..e6bb90f 100644 --- a/ATL/atl_manage_add.php +++ b/ATL/atl_manage_add.php @@ -24,15 +24,11 @@ if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_add.php') == false) { //Acess denied - echo "
"; - echo __('You do not have access to this action.'); - echo '
'; + $page->addError(__('You do not have access to this action.')); } else { $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; if ($gibbonCourseClassID == '') { - echo "
"; - echo __('You have not specified one or more required parameters.'); - echo '
'; + $page->addError(__('You have not specified one or more required parameters.')); } else { try { $data = array('gibbonCourseClassID' => $gibbonCourseClassID); @@ -44,9 +40,7 @@ } if ($result->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { $class = $result->fetch(); diff --git a/ATL/atl_manage_delete.php b/ATL/atl_manage_delete.php index 6f189bd..7d5ae57 100644 --- a/ATL/atl_manage_delete.php +++ b/ATL/atl_manage_delete.php @@ -24,17 +24,13 @@ if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_delete.php') == false) { //Acess denied - echo "
"; - echo __('You do not have access to this action.'); - echo '
'; + $page->addError(__('You do not have access to this action.')); } else { //Check if school year specified $gibbonCourseClassID = $_GET['gibbonCourseClassID']; $atlColumnID = $_GET['atlColumnID']; if ($gibbonCourseClassID == '' or $atlColumnID == '') { - echo "
"; - echo __('You have not specified one or more required parameters.'); - echo '
'; + $page->addError(__('You have not specified one or more required parameters.'));; } else { try { $data = array('gibbonCourseClassID' => $gibbonCourseClassID); @@ -46,9 +42,7 @@ } if ($result->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { try { $data2 = array('atlColumnID' => $atlColumnID); @@ -60,9 +54,7 @@ } if ($result2->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { //Let's go! $row = $result->fetch(); From 388550c0893727839ba874450729c0bcdb2f001d Mon Sep 17 00:00:00 2001 From: Ashton Power <48048360+powertashton@users.noreply.github.com> Date: Fri, 13 Aug 2021 12:53:05 +0800 Subject: [PATCH 03/57] Update atl_manage_edit.php --- ATL/atl_manage_edit.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/ATL/atl_manage_edit.php b/ATL/atl_manage_edit.php index bbd2078..96f47d6 100644 --- a/ATL/atl_manage_edit.php +++ b/ATL/atl_manage_edit.php @@ -24,24 +24,18 @@ if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_edit.php') == false) { //Acess denied - echo "
"; - echo __('You do not have access to this action.'); - echo '
'; + $page->addError(__('You do not have access to this action.')); } else { //Get action with highest precendence $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; + $page->addError(__('The highest grouped action cannot be determined.')); } else { //Check if school year specified $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; $atlColumnID = $_GET['atlColumnID'] ?? ''; if ($gibbonCourseClassID == '' or $atlColumnID == '') { - echo "
"; - echo __('You have not specified one or more required parameters.'); - echo '
'; + $page->addError(__('You have not specified one or more required parameters.')); } else { try { $data = array('gibbonCourseClassID' => $gibbonCourseClassID); @@ -53,9 +47,7 @@ } if ($result->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { try { $data2 = array('atlColumnID' => $atlColumnID); @@ -67,9 +59,7 @@ } if ($result2->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { //Let's go! $class = $result->fetch(); From c082caec4a5b3bdae81004d157a491da42171770 Mon Sep 17 00:00:00 2001 From: Ashton Power <48048360+powertashton@users.noreply.github.com> Date: Fri, 13 Aug 2021 12:54:53 +0800 Subject: [PATCH 04/57] partial error refactor --- ATL/atl_view.php | 8 ++------ ATL/atl_view_rubric.php | 20 +++++--------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/ATL/atl_view.php b/ATL/atl_view.php index fd86bfc..25c7432 100644 --- a/ATL/atl_view.php +++ b/ATL/atl_view.php @@ -26,9 +26,7 @@ if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { //Acess denied - echo "
"; - echo __('Your request failed because you do not have access to this action.'); - echo '
'; + $page->addError(__('You do not have access to this action.')); } else { // Register scripts available to the core, but not included by default $page->scripts->add('chart'); @@ -36,9 +34,7 @@ //Get action with highest precendence $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; + $page->addError(__('The highest grouped action cannot be determined.')); } else { if ($highestAction == 'View ATLs_all') { //ALL STUDENTS $page->breadcrumbs->add(__('View All ATLs')); diff --git a/ATL/atl_view_rubric.php b/ATL/atl_view_rubric.php index a07114a..1842b70 100644 --- a/ATL/atl_view_rubric.php +++ b/ATL/atl_view_rubric.php @@ -24,9 +24,7 @@ if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { //Acess denied - echo "
"; - echo __('Your request failed because you do not have access to this action.'); - echo '
'; + $page->addError(__('You do not have access to this action.')); } else { //Proceed! //Check if school year specified @@ -64,9 +62,7 @@ } if ($result->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { try { $data2 = array('atlColumnID' => $atlColumnID); @@ -78,9 +74,7 @@ } if ($result2->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { try { $data3 = array('gibbonRubricID' => $gibbonRubricID); @@ -92,9 +86,7 @@ } if ($result3->rowCount() != 1) { - echo "
"; - echo __('The specified record does not exist.'); - echo '
'; + $page->addError(__('The selected record does not exist.')); } else { try { $data4 = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); @@ -106,9 +98,7 @@ } if ($result4->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { //Let's go! $row = $result->fetch(); From ad6d8e10793109649a635ca0425d6afb85e5a36f Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Tue, 14 Sep 2021 11:33:16 +1000 Subject: [PATCH 05/57] Added ATLColumnGateway --- ATL/src/Domain/ATLColumnGateway.php | 62 +++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 ATL/src/Domain/ATLColumnGateway.php diff --git a/ATL/src/Domain/ATLColumnGateway.php b/ATL/src/Domain/ATLColumnGateway.php new file mode 100644 index 0000000..32baaf7 --- /dev/null +++ b/ATL/src/Domain/ATLColumnGateway.php @@ -0,0 +1,62 @@ +newQuery() + ->from($this->getTableName()) + ->cols([ + 'atlColumnID', 'gibbonCourseClassID', 'groupingID', 'name', 'description', 'gibbonRubricID', 'complete', 'completeDate', 'gibbonPersonIDCreator', 'gibbonPersonIDLastEdit' + ]) + ->where('atlColumn.gibbonCourseClassID = :gibbonCourseClassID') + ->bindValue('gibbonCourseClassID', $gibbonCourseClassID); + + return $this->runQuery($query, $criteria); + } + + /** + * @param QueryCriteria $criteria + * @return DataSet + */ + public function queryATLColumnsByStudent(QueryCriteria $criteria, $gibbonSchoolYearID, $gibbonPersonID) + { + $query = $this + ->newQuery() + ->from($this->getTableName()) + ->cols([ + 'atlColumn.name' + ]) + ->leftJoin('atlEntry', 'atlColumn.atlColumnID=atlEntry.atlColumnID AND atlEntry.gibbonPersonIDStudent = :gibbonPersonID') + ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') + ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID') + ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') + ->where('gibbonCourseClassPerson.gibbonPersonID = :gibbonPersonID') + ->where("gibbonCourseClassPerson.role = 'Student'") + ->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') + ->bindValue('gibbonPersonID', $gibbonPersonID) + ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); + + return $this->runQuery($query, $criteria); + } +} From 947bb07ddaa815ba519f7251d7ef486fc2d22e30 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Tue, 14 Sep 2021 11:36:00 +1000 Subject: [PATCH 06/57] Incremented version to 1.6.00 --- ATL/version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ATL/version.php b/ATL/version.php index 7bbdfee..b20c25a 100644 --- a/ATL/version.php +++ b/ATL/version.php @@ -20,5 +20,5 @@ /** * Sets version information. */ -$moduleVersion = '1.5.01'; +$moduleVersion = '1.6.00'; $coreVersion = '22.0.00'; From 00d875c6f74255d2d4443c6b36c90f836ed9d549 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Tue, 14 Sep 2021 11:36:37 +1000 Subject: [PATCH 07/57] Added forStudent Y/N to atlColumns, Added Fill ATLs for students and clean up --- ATL/manifest.php | 325 ++++++++++++++++++++++++++--------------------- 1 file changed, 180 insertions(+), 145 deletions(-) diff --git a/ATL/manifest.php b/ATL/manifest.php index 7698859..9ec0140 100644 --- a/ATL/manifest.php +++ b/ATL/manifest.php @@ -19,155 +19,190 @@ //This file describes the module, including database tables -//Basica variables -$name = 'ATL'; -$description = 'The ATL module allows schools to run a program of Approaches To Learning assessments, based on a rubric.'; -$entryURL = 'atl_write.php'; -$type = 'Additional'; -$category = 'Assess'; -$version = '1.5.01'; -$author = 'Ross Parker'; -$url = 'http://rossparker.org'; +//Basic variables +$name = 'ATL'; +$description = 'The ATL module allows schools to run a program of Approaches To Learning assessments, based on a rubric.'; +$entryURL = 'atl_write.php'; +$type = 'Additional'; +$category = 'Assess'; +$version = '1.6.00'; +$author = 'Ross Parker'; +$url = 'http://rossparker.org'; //Module tables -$moduleTables[0] = "CREATE TABLE `atlColumn` ( - `atlColumnID` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT, - `gibbonCourseClassID` int(8) unsigned zerofill NOT NULL, - `groupingID` int(8) unsigned zerofill DEFAULT NULL COMMENT 'A value used to group multiple ATL columns.', - `name` varchar(20) NOT NULL, - `description` text NOT NULL, - `gibbonRubricID` int(8) unsigned zerofill DEFAULT NULL, - `complete` enum('N','Y') NOT NULL, - `completeDate` date DEFAULT NULL, - `gibbonPersonIDCreator` int(10) unsigned zerofill NOT NULL, - `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, - PRIMARY KEY (`atlColumnID`), - KEY `gibbonCourseClassID` (`gibbonCourseClassID`), - KEY `gibbonRubricID` (`gibbonRubricID`) +$moduleTables[] = "CREATE TABLE `atlColumn` ( + `atlColumnID` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT, + `gibbonCourseClassID` int(8) unsigned zerofill NOT NULL, + `groupingID` int(8) unsigned zerofill DEFAULT NULL COMMENT 'A value used to group multiple ATL columns.', + `name` varchar(20) NOT NULL, + `description` text NOT NULL, + `gibbonRubricID` int(8) unsigned zerofill DEFAULT NULL, + `complete` enum('N','Y') NOT NULL, + `completeDate` date DEFAULT NULL, + `forStudents` enum('Y','N') NOT NULL DEFAULT 'N', + `gibbonPersonIDCreator` int(10) unsigned zerofill NOT NULL, + `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, + PRIMARY KEY (`atlColumnID`), + KEY `gibbonCourseClassID` (`gibbonCourseClassID`), + KEY `gibbonRubricID` (`gibbonRubricID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; -$moduleTables[1] = "CREATE TABLE `atlEntry` ( - `atlEntryID` int(12) unsigned zerofill NOT NULL AUTO_INCREMENT, - `atlColumnID` int(10) unsigned zerofill NOT NULL, - `gibbonPersonIDStudent` int(10) unsigned zerofill NOT NULL, - `complete` enum('Y','N') NOT NULL DEFAULT 'N', - `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, - PRIMARY KEY (`atlEntryID`), - KEY (`atlColumnID`), - KEY (`gibbonPersonIDStudent`) +$moduleTables[] = "CREATE TABLE `atlEntry` ( + `atlEntryID` int(12) unsigned zerofill NOT NULL AUTO_INCREMENT, + `atlColumnID` int(10) unsigned zerofill NOT NULL, + `gibbonPersonIDStudent` int(10) unsigned zerofill NOT NULL, + `complete` enum('Y','N') NOT NULL DEFAULT 'N', + `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, + PRIMARY KEY (`atlEntryID`), + KEY (`atlColumnID`), + KEY (`gibbonPersonIDStudent`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; //Action rows -$actionRows[0]['name'] = 'Manage ATLs_all'; -$actionRows[0]['precedence'] = '0'; -$actionRows[0]['category'] = 'Manage & Assess'; -$actionRows[0]['description'] = 'Allows privileged users to create and manage ATL columns.'; -$actionRows[0]['URLList'] = 'atl_manage.php, atl_manage_add.php, atl_manage_edit.php, atl_manage_delete.php'; -$actionRows[0]['entryURL'] = 'atl_manage.php'; -$actionRows[0]['defaultPermissionAdmin'] = 'Y'; -$actionRows[0]['defaultPermissionTeacher'] = 'N'; -$actionRows[0]['defaultPermissionStudent'] = 'N'; -$actionRows[0]['defaultPermissionParent'] = 'N'; -$actionRows[0]['defaultPermissionSupport'] = 'N'; -$actionRows[0]['categoryPermissionStaff'] = 'Y'; -$actionRows[0]['categoryPermissionStudent'] = 'N'; -$actionRows[0]['categoryPermissionParent'] = 'N'; -$actionRows[0]['categoryPermissionOther'] = 'N'; - -$actionRows[1]['name'] = 'Write ATLs_myClasses'; -$actionRows[1]['precedence'] = '0'; -$actionRows[1]['category'] = 'Manage & Assess'; -$actionRows[1]['description'] = 'Allows teachers to enter ATL assessment data to columns in their classes.'; -$actionRows[1]['URLList'] = 'atl_write.php, atl_write_data.php'; -$actionRows[1]['entryURL'] = 'atl_write.php'; -$actionRows[1]['defaultPermissionAdmin'] = 'N'; -$actionRows[1]['defaultPermissionTeacher'] = 'Y'; -$actionRows[1]['defaultPermissionStudent'] = 'N'; -$actionRows[1]['defaultPermissionParent'] = 'N'; -$actionRows[1]['defaultPermissionSupport'] = 'N'; -$actionRows[1]['categoryPermissionStaff'] = 'Y'; -$actionRows[1]['categoryPermissionStudent'] = 'N'; -$actionRows[1]['categoryPermissionParent'] = 'N'; -$actionRows[1]['categoryPermissionOther'] = 'N'; - -$actionRows[2]['name'] = 'Write ATLs_all'; -$actionRows[2]['precedence'] = '1'; -$actionRows[2]['category'] = 'Manage & Assess'; -$actionRows[2]['description'] = 'Allows privileged users to enter ATL assessment data to columns in all classes.'; -$actionRows[2]['URLList'] = 'atl_write.php, atl_write_data.php'; -$actionRows[2]['entryURL'] = 'atl_write.php'; -$actionRows[2]['defaultPermissionAdmin'] = 'Y'; -$actionRows[2]['defaultPermissionTeacher'] = 'N'; -$actionRows[2]['defaultPermissionStudent'] = 'N'; -$actionRows[2]['defaultPermissionParent'] = 'N'; -$actionRows[2]['defaultPermissionSupport'] = 'N'; -$actionRows[2]['categoryPermissionStaff'] = 'Y'; -$actionRows[2]['categoryPermissionStudent'] = 'N'; -$actionRows[2]['categoryPermissionParent'] = 'N'; -$actionRows[2]['categoryPermissionOther'] = 'N'; - -$actionRows[3]['name'] = 'View ATLs_mine'; -$actionRows[3]['precedence'] = '0'; -$actionRows[3]['category'] = 'View'; -$actionRows[3]['description'] = 'Allows students to view their own ATL results.'; -$actionRows[3]['URLList'] = 'atl_view.php'; -$actionRows[3]['entryURL'] = 'atl_view.php'; -$actionRows[3]['defaultPermissionAdmin'] = 'N'; -$actionRows[3]['defaultPermissionTeacher'] = 'N'; -$actionRows[3]['defaultPermissionStudent'] = 'Y'; -$actionRows[3]['defaultPermissionParent'] = 'N'; -$actionRows[3]['defaultPermissionSupport'] = 'N'; -$actionRows[3]['categoryPermissionStaff'] = 'N'; -$actionRows[3]['categoryPermissionStudent'] = 'Y'; -$actionRows[3]['categoryPermissionParent'] = 'N'; -$actionRows[3]['categoryPermissionOther'] = 'N'; - -$actionRows[4]['name'] = 'View ATLs_myChildrens'; -$actionRows[4]['precedence'] = '1'; -$actionRows[4]['category'] = 'View'; -$actionRows[4]['description'] = "Allows parents to view their childrens' ATL results."; -$actionRows[4]['URLList'] = 'atl_view.php'; -$actionRows[4]['entryURL'] = 'atl_view.php'; -$actionRows[4]['defaultPermissionAdmin'] = 'N'; -$actionRows[4]['defaultPermissionTeacher'] = 'N'; -$actionRows[4]['defaultPermissionStudent'] = 'N'; -$actionRows[4]['defaultPermissionParent'] = 'Y'; -$actionRows[4]['defaultPermissionSupport'] = 'N'; -$actionRows[4]['categoryPermissionStaff'] = 'N'; -$actionRows[4]['categoryPermissionStudent'] = 'N'; -$actionRows[4]['categoryPermissionParent'] = 'Y'; -$actionRows[4]['categoryPermissionOther'] = 'N'; - -$actionRows[5]['name'] = 'View ATLs_all'; -$actionRows[5]['precedence'] = '2'; -$actionRows[5]['category'] = 'View'; -$actionRows[5]['description'] = 'Allows staff to see ATL results for all children.'; -$actionRows[5]['URLList'] = 'atl_view.php'; -$actionRows[5]['entryURL'] = 'atl_view.php'; -$actionRows[5]['defaultPermissionAdmin'] = 'Y'; -$actionRows[5]['defaultPermissionTeacher'] = 'Y'; -$actionRows[5]['defaultPermissionStudent'] = 'N'; -$actionRows[5]['defaultPermissionParent'] = 'N'; -$actionRows[5]['defaultPermissionSupport'] = 'N'; -$actionRows[5]['categoryPermissionStaff'] = 'Y'; -$actionRows[5]['categoryPermissionStudent'] = 'N'; -$actionRows[5]['categoryPermissionParent'] = 'N'; -$actionRows[5]['categoryPermissionOther'] = 'N'; - -$array = array(); -$array['sourceModuleName'] = 'ATL'; -$array['sourceModuleAction'] = 'View ATLs_all'; -$array['sourceModuleInclude'] = 'hook_studentProfile_atlView.php'; -$hooks[0] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Profile', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; - -$array = array(); -$array['sourceModuleName'] = 'ATL'; -$array['sourceModuleAction'] = 'View ATLs_myChildrens'; -$array['sourceModuleInclude'] = 'hook_parentalDashboard_atlView.php'; -$hooks[1] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Parental Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; - -$array = array(); -$array['sourceModuleName'] = 'ATL'; -$array['sourceModuleAction'] = 'View ATLs_mine'; -$array['sourceModuleInclude'] = 'hook_studentDashboard_atlView.php'; -$hooks[2] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; +$actionRows[] = [ + 'name' => 'Manage ATLs_all', + 'precedence' => '0', + 'category' => 'Manage & Assess', + 'description' => 'Allows privileged users to create and manage ATL columns.', + 'URLList' => 'atl_manage.php, atl_manage_add.php, atl_manage_edit.php, atl_manage_delete.php', + 'entryURL' => 'atl_manage.php', + 'defaultPermissionAdmin' => 'Y', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'Write ATLs_myClasses', + 'precedence' => '0', + 'category' => 'Manage & Assess', + 'description' => 'Allows teachers to enter ATL assessment data to columns in their classes.', + 'URLList' => 'atl_write.php, atl_write_data.php', + 'entryURL' => 'atl_write.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'Y', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'Write ATLs_all', + 'precedence' => '1', + 'category' => 'Manage & Assess', + 'description' => 'Allows privileged users to enter ATL assessment data to columns in all classes.', + 'URLList' => 'atl_write.php, atl_write_data.php', + 'entryURL' => 'atl_write.php', + 'defaultPermissionAdmin' => 'Y', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'View ATLs_mine', + 'precedence' => '0', + 'category' => 'View', + 'description' => 'Allows students to view their own ATL results.', + 'URLList' => 'atl_view.php', + 'entryURL' => 'atl_view.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'Y', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'N', + 'categoryPermissionStudent' => 'Y', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'View ATLs_myChildrens', + 'precedence' => '1', + 'category' => 'View', + 'description' => "Allows parents to view their childrens' ATL results.", + 'URLList' => 'atl_view.php', + 'entryURL' => 'atl_view.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'Y', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'N', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'Y', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'View ATLs_all', + 'precedence' => '2', + 'category' => 'View', + 'description' => 'Allows staff to see ATL results for all children.', + 'URLList' => 'atl_view.php', + 'entryURL' => 'atl_view.php', + 'defaultPermissionAdmin' => 'Y', + 'defaultPermissionTeacher' => 'Y', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'Fill ATLs', + 'precedence' => '0', + 'category' => 'View', + 'description' => 'Allows students to enter ATL assessment data to columns in their classes.', + 'URLList' => 'atl_write_student.php', + 'entryURL' => 'atl_write_student.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'Y', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'N', + 'categoryPermissionStudent' => 'Y', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +//Hooks +$array = [ + 'sourceModuleName' => 'ATL'; + 'sourceModuleAction' => 'View ATLs_all'; + 'sourceModuleInclude' => 'hook_studentProfile_atlView.php'; +]; +$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Profile', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; + +$array = [ + 'sourceModuleName' => 'ATL'; + 'sourceModuleAction' => 'View ATLs_myChildrens'; + 'sourceModuleInclude' => 'hook_parentalDashboard_atlView.php'; +]; +$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Parental Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; + +$array = [ + 'sourceModuleName' => 'ATL'; + 'sourceModuleAction' => 'View ATLs_mine'; + 'sourceModuleInclude' => 'hook_studentDashboard_atlView.php'; +]; +$hooks[$] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; From a468a8bdbf7d3bbbdbb36fca30ee40e6b2e7be1e Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Tue, 14 Sep 2021 11:36:46 +1000 Subject: [PATCH 08/57] Added student ATLs --- ATL/CHANGELOG.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ATL/CHANGELOG.txt b/ATL/CHANGELOG.txt index f885ef8..81e0d75 100644 --- a/ATL/CHANGELOG.txt +++ b/ATL/CHANGELOG.txt @@ -1,5 +1,9 @@ CHANGELOG ========= +v1.6.00 +------- +Added student ATLs + v1.5.01 ------- Refactoring session variables From 348de877895c70fe0ed85b3db8d9a7f8a1c3bda4 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Tue, 14 Sep 2021 11:36:56 +1000 Subject: [PATCH 09/57] Added forStudents Y/N enum to atlColumns --- ATL/CHANGEDB.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ATL/CHANGEDB.php b/ATL/CHANGEDB.php index 01a6bf6..19ed1c5 100644 --- a/ATL/CHANGEDB.php +++ b/ATL/CHANGEDB.php @@ -136,3 +136,10 @@ ++$count; $sql[$count][0] = '1.5.01'; $sql[$count][1] = ''; + +//v1.6.00 +++$count; +$sql[$count][0] = '1.6.00'; +$sql[$count][1] = " +ALTER TABLE `atlEntry` ADD `forStudents` ENUM('Y','N') NOT NULL DEFAULT 'N' AFTER `completeDate`;end +"; From 6da4fd3fba9aa4f8df6e5233e9c5aa15f1f14eab Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Tue, 14 Sep 2021 12:09:55 +1000 Subject: [PATCH 10/57] Added For Students setting --- ATL/atl_manage.php | 2 ++ ATL/atl_manage_add.php | 6 ++++++ ATL/atl_manage_addProcess.php | 38 +++++++++++++++++++++-------------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/ATL/atl_manage.php b/ATL/atl_manage.php index 30dfb84..f375bfb 100644 --- a/ATL/atl_manage.php +++ b/ATL/atl_manage.php @@ -137,6 +137,8 @@ $table->addColumn('name', __('Name')); $table->addColumn('completeDate', __('Date Complete')); + $table->addColumn('forStudents', __('For Students?')) + ->format(Format::using('yesNo', ['forStudents'])); $table->addActionColumn() ->addParam('gibbonCourseClassID', $gibbonCourseClassID) ->addParam('atlColumnID') diff --git a/ATL/atl_manage_add.php b/ATL/atl_manage_add.php index e6bb90f..c7017e5 100644 --- a/ATL/atl_manage_add.php +++ b/ATL/atl_manage_add.php @@ -107,6 +107,12 @@ $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); $row->addDate('completeDate'); + $row = $form->addRow(); + $row->addLabel('forStudents', __('For Students?'))->description(__('Is this column meant to be filled out by students?')); + $row->addYesNo('forStudents') + ->selected('N') + ->required(); + $row = $form->addRow(); $row->addFooter(); $row->addSubmit(); diff --git a/ATL/atl_manage_addProcess.php b/ATL/atl_manage_addProcess.php index 18bc895..ef5c7d5 100644 --- a/ATL/atl_manage_addProcess.php +++ b/ATL/atl_manage_addProcess.php @@ -17,6 +17,8 @@ along with this program. If not, see . */ +use Gibbon\Module\ATL\Domain\ATLColumnGateway; + include '../../gibbon.php'; @@ -50,6 +52,7 @@ $completeDate = dateConvert($guid, $completeDate); $complete = 'Y'; } + $forStudents = $_POST['forStudents'] ?? ''; $gibbonPersonIDCreator = $session->get('gibbonPersonID'); $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); @@ -82,24 +85,31 @@ $groupingID = ($rowGrouping['groupingID'] + 1); } - if (is_array($gibbonCourseClassIDMulti) == false or is_numeric($groupingID) == false or $groupingID < 1 or $name == '' or $description == '') { + if (is_array($gibbonCourseClassIDMulti) == false or is_numeric($groupingID) == false or $groupingID < 1 or $name == '' or $description == '' or $forStudents == '') { //Fail 3 $URL .= '&return=error3'; header("Location: {$URL}"); + exit(); } else { $partialFail = false; + $atlColumnGateway = $container->get(ATLColumnGateway::class); + + $data = [ + 'groupingID' => $groupingID, + 'name' => $name, + 'description' => $description, + 'gibbonRubricID' => $gibbonRubricID, + 'completeDate' => $completeDate, + 'forStudents' => $forStudents, + 'complete' => $complete, + 'gibbonPersonIDCreator' => $gibbonPersonIDCreator, + 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit + ]; foreach ($gibbonCourseClassIDMulti as $gibbonCourseClassIDSingle) { //Write to database - try { - $data = array('groupingID' => $groupingID, 'gibbonCourseClassID' => $gibbonCourseClassIDSingle, 'name' => $name, 'description' => $description, 'gibbonRubricID' => $gibbonRubricID, 'completeDate' => $completeDate, 'complete' => $complete, 'gibbonPersonIDCreator' => $gibbonPersonIDCreator, 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit); - $sql = 'INSERT INTO atlColumn SET groupingID=:groupingID, gibbonCourseClassID=:gibbonCourseClassID, name=:name, description=:description, gibbonRubricID=:gibbonRubricID, completeDate=:completeDate, complete=:complete, gibbonPersonIDCreator=:gibbonPersonIDCreator, gibbonPersonIDLastEdit=:gibbonPersonIDLastEdit'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - //Fail 2 - $partialFail = true; - } + $data['gibbonCourseClassID'] = $gibbonCourseClassIDSingle; + $partialFail |= empty($atlColumnGateway->insert($data)); } //Unlock module table @@ -109,15 +119,13 @@ } catch (PDOException $e) { } - if ($partialFail != false) { - //Success 0 + if ($partialFail) { $URL .= '&return=error6'; - header("Location: {$URL}"); } else { - //Success 0 $URL .= '&return=success0'; - header("Location: {$URL}"); } + header("Location: {$URL}"); + exit(); } } } From 38de82ccd4394853f16664dcb7a13004f45ff2bb Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Tue, 14 Sep 2021 12:10:08 +1000 Subject: [PATCH 11/57] Fixed adding coulmn and added new action/permissions --- ATL/CHANGEDB.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ATL/CHANGEDB.php b/ATL/CHANGEDB.php index 19ed1c5..4f7c076 100644 --- a/ATL/CHANGEDB.php +++ b/ATL/CHANGEDB.php @@ -141,5 +141,7 @@ ++$count; $sql[$count][0] = '1.6.00'; $sql[$count][1] = " -ALTER TABLE `atlEntry` ADD `forStudents` ENUM('Y','N') NOT NULL DEFAULT 'N' AFTER `completeDate`;end +ALTER TABLE `atlColumn` ADD `forStudents` ENUM('Y','N') NOT NULL DEFAULT 'N' AFTER `completeDate`;end +INSERT INTO gibbonAction SET name='Fill ATLs', precedence=0, category='View', description='Allows students to enter ATL assessment data to columns in their classes.', URLList='atl_write_student.php', entryURL='atl_write_student.php', defaultPermissionAdmin='N', defaultPermissionTeacher='N', defaultPermissionStudent='Y', defaultPermissionParent='N', defaultPermissionSupport='N', categoryPermissionStaff='N', categoryPermissionStudent='Y', categoryPermissionParent='N', categoryPermissionOther='N', gibbonModuleID=(SELECT gibbonModuleID FROM gibbonModule WHERE name='ATL');end +INSERT INTO `gibbonPermission` (`permissionID` ,`gibbonRoleID` ,`gibbonActionID`) VALUES (NULL , (SELECT gibbonRoleID FROM gibbonRole WHERE gibbonRole.name='Student'), (SELECT gibbonActionID FROM gibbonAction JOIN gibbonModule ON (gibbonAction.gibbonModuleID=gibbonModule.gibbonModuleID) WHERE gibbonModule.name='ATL' AND gibbonAction.name='Fill ATLs'));end "; From c2c01be130c2bf025dc1c5da5429f47234f4818b Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Fri, 1 Oct 2021 08:34:45 +1000 Subject: [PATCH 12/57] OOification and added For Students column --- ATL/atl_manage.php | 149 ++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 91 deletions(-) diff --git a/ATL/atl_manage.php b/ATL/atl_manage.php index f375bfb..5f61a05 100644 --- a/ATL/atl_manage.php +++ b/ATL/atl_manage.php @@ -19,6 +19,7 @@ use Gibbon\Services\Format; use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Domain\Timetable\CourseGateway; use Gibbon\Domain\DataSet; use Gibbon\Tables\DataTable; @@ -35,10 +36,8 @@ $page->addError(__('The highest grouped action cannot be determined.')); } else { //Get class variable - $gibbonCourseClassID = null; - if (isset($_GET['gibbonCourseClassID'])) { - $gibbonCourseClassID = $_GET['gibbonCourseClassID']; - } else { + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + if (empty($gibbonCourseClassID)) { try { $data = array('gibbonPersonID' => $session->get('gibbonPersonID')); $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND gibbonCourse.gibbonSchoolYearID=(SELECT gibbonSchoolYearID FROM gibbonSchoolYear WHERE status='Current') AND gibbonCourseClass.reportable='Y' ORDER BY course, class"; @@ -50,113 +49,81 @@ if ($result->rowCount() > 0) { $row = $result->fetch(); $gibbonCourseClassID = $row['gibbonCourseClassID']; - } + } } - if ($gibbonCourseClassID == '') { + + $courseGateway = $container->get(CourseGateway::class); + $class = $courseGateway->getCourseClassByID($gibbonCourseClassID); + if (empty($class)) { + $page->breadcrumbs->add(__('Manage ATLs')); echo '

'; - echo 'Manage ATL'; + echo __('Manage ATL'); echo '

'; - echo "
"; - echo __('Use the class listing on the right to choose a ATL to edit.'); - echo '
'; + echo Format::alert(__('Use the class listing on the right to choose a ATL to edit.'), 'warning'); } else { - //Check existence of and access to this class. + $page->breadcrumbs->add(__('Manage {courseClass} ATLs', ['courseClass' => $class['courseName'].'.'.$class['name']])); + + //Get teacher list + $teaching = false; try { $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class'; + $sql = "SELECT gibbonPerson.gibbonPersonID, title, surname, preferredName, gibbonCourseClassPerson.reportable FROM gibbonCourseClassPerson JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE (role='Teacher' OR role='Assistant') AND gibbonCourseClassID=:gibbonCourseClassID ORDER BY surname, preferredName"; $result = $connection2->prepare($sql); $result->execute($data); } catch (PDOException $e) { echo "
".$e->getMessage().'
'; } + if ($result->rowCount() > 0) { + echo '

'; + echo __('Teachers'); + echo '

'; + echo '
    '; + while ($row = $result->fetch()) { + if ($row['reportable'] != 'Y') continue; - if ($result->rowCount() != 1) { - echo '

    '; - echo __('Manage ATL'); - echo '

    '; - echo "
    "; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
    '; - } else { - $row = $result->fetch(); - $page->breadcrumbs->add(__('Manage {courseClass} ATLs', ['courseClass' => $row['course'].'.'.$row['class']])); - - if (isset($_GET['deleteReturn'])) { - $deleteReturn = $_GET['deleteReturn']; - } else { - $deleteReturn = ''; - } - $deleteReturnMessage = ''; - $class = 'error'; - if (!($deleteReturn == '')) { - if ($deleteReturn == 'success0') { - $deleteReturnMessage = __('Your request was completed successfully.'); - $class = 'success'; + echo '
  • '.Format::name($row['title'], $row['preferredName'], $row['surname'], 'Staff').'
  • '; + if ($row['gibbonPersonID'] == $session->get('gibbonPersonID')) { + $teaching = true; } - echo "
    "; - echo $deleteReturnMessage; - echo '
    '; } + echo '
'; + } + //TABLE + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlColumnData = $atlColumnGateway->selectBy(['gibbonCourseClassID' => $gibbonCourseClassID])->fetchAll(); + + $table = DataTable::create('atlColumns'); + $table->setTitle('ATL Columns'); - //Add multiple columns - echo "'; - - //Get teacher list - $teaching = false; - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonPerson.gibbonPersonID, title, surname, preferredName, gibbonCourseClassPerson.reportable FROM gibbonCourseClassPerson JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE (role='Teacher' OR role='Assistant') AND gibbonCourseClassID=:gibbonCourseClassID ORDER BY surname, preferredName"; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - if ($result->rowCount() > 0) { - echo '

'; - echo __('Teachers'); - echo '

'; - echo '
    '; - while ($row = $result->fetch()) { - if ($row['reportable'] != 'Y') continue; - - echo '
  • '.Format::name($row['title'], $row['preferredName'], $row['surname'], 'Staff').'
  • '; - if ($row['gibbonPersonID'] == $session->get('gibbonPersonID')) { - $teaching = true; - } - } - echo '
'; - } - //TABLE - $atlColumnGateway = $container->get(ATLColumnGateway::class); - $atlColumnData = $atlColumnGateway->selectBy(['gibbonCourseClassID' => $gibbonCourseClassID])->fetchAll(); - - $table = DataTable::create('atlColumns'); - $table->setTitle('ATL Columns'); - - $table->addColumn('name', __('Name')); - $table->addColumn('completeDate', __('Date Complete')); - $table->addColumn('forStudents', __('For Students?')) - ->format(Format::using('yesNo', ['forStudents'])); - $table->addActionColumn() - ->addParam('gibbonCourseClassID', $gibbonCourseClassID) - ->addParam('atlColumnID') - ->format(function ($row, $actions) use ($session) { - $actions->addAction('edit', __('Edit')) - ->setURL('/modules/' . $session->get('module') . '/atl_manage_edit.php'); + $table->addHeaderAction('add', __('Add Multiple Columns')) + ->displayLabel() + ->addParam('gibbonCourseClassID', $gibbonCourseClassID) + ->setURL('/modules/ATL/atl_manage_add.php') + ->setIcon('page_new_multi'); + + $table->addColumn('name', __('Name')); + $table->addColumn('completeDate', __('Date Complete')); + $table->addColumn('forStudents', __('For Students?')) + ->format(Format::using('yesNo', ['forStudents'])); + $table->addActionColumn() + ->addParam('gibbonCourseClassID', $gibbonCourseClassID) + ->addParam('atlColumnID') + ->format(function ($row, $actions) use ($session) { + $actions->addAction('edit', __('Edit')) + ->setURL('/modules/' . $session->get('module') . '/atl_manage_edit.php'); - $actions->addAction('delete', __('Delete')) - ->setURL('/modules/' . $session->get('module') . '/atl_manage_delete.php'); - + $actions->addAction('delete', __('Delete')) + ->setURL('/modules/' . $session->get('module') . '/atl_manage_delete.php'); + + if ($row['forStudents'] == 'N') { $actions->addAction('enterData', __('Enter Data')) ->setURL('/modules/' . $session->get('module') . '/atl_write_data.php') ->setIcon('markbook'); + } - }); - - echo $table->render($atlColumnData); - } + }); + + echo $table->render($atlColumnData); } } From 8abb549ba791b9aa0ce87497118b40efd10af344 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Fri, 1 Oct 2021 08:35:46 +1000 Subject: [PATCH 13/57] OOification --- ATL/atl_manage_add.php | 24 +++++------------- ATL/atl_manage_delete.php | 21 ++++++---------- ATL/atl_manage_deleteProcess.php | 43 +++++++++++--------------------- 3 files changed, 27 insertions(+), 61 deletions(-) diff --git a/ATL/atl_manage_add.php b/ATL/atl_manage_add.php index c7017e5..21b02ba 100644 --- a/ATL/atl_manage_add.php +++ b/ATL/atl_manage_add.php @@ -17,7 +17,9 @@ along with this program. If not, see . */ +use Gibbon\Forms\DatabaseFormFactory; use Gibbon\Forms\Form; +use Gibbon\Services\Format; //Module includes include './modules/'.$session->get('module').'/moduleFunctions.php'; @@ -36,7 +38,7 @@ $result = $connection2->prepare($sql); $result->execute($data); } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; + $page->addError(__('A database error has occured.')); } if ($result->rowCount() != 1) { @@ -45,14 +47,11 @@ $class = $result->fetch(); $page->breadcrumbs - ->add(__('Manage {courseClass} ATLs', ['courseClass' => $class['course'].'.'.$class['class']]), 'atl_manage.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) + ->add(__('Manage {courseClass} ATLs', ['courseClass' => Format::courseClassName($class['course'], $class['class'])]), 'atl_manage.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) ->add(__('Add Multiple Columns')); - if (isset($_GET['return'])) { - returnProcess($guid, $_GET['return'], null, null); - } - $form = Form::create('ATL', $session->get('absoluteURL').'/modules/ATL/atl_manage_addProcess.php?gibbonCourseClassID='.$gibbonCourseClassID.'&address='.$session->get('address')); + $form->setFactory(DatabaseFormFactory::create($pdo)); $form->addHiddenValue('address', $session->get('address')); $form->addRow()->addHeading(__('Basic Information')); @@ -78,20 +77,9 @@ $form->addRow()->addHeading(__('Assessment')); - $data = array('gibbonYearGroupIDList' => $class['gibbonYearGroupIDList'], 'gibbonDepartmentID' => $class['gibbonDepartmentID'], 'rubrics' => __('Rubrics')); - $sql = "SELECT CONCAT(scope, ' ', :rubrics) as groupBy, gibbonRubricID as value, - (CASE WHEN category <> '' THEN CONCAT(category, ' - ', gibbonRubric.name) ELSE gibbonRubric.name END) as name - FROM gibbonRubric - JOIN gibbonYearGroup ON (FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, gibbonRubric.gibbonYearGroupIDList)) - WHERE gibbonRubric.active='Y' - AND FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, :gibbonYearGroupIDList) - AND (scope='School' OR (scope='Learning Area' AND gibbonDepartmentID=:gibbonDepartmentID)) - GROUP BY gibbonRubric.gibbonRubricID - ORDER BY scope, category, name"; - $row = $form->addRow(); $row->addLabel('gibbonRubricID', __('Rubric')); - $rubrics = $row->addSelect('gibbonRubricID')->fromQuery($pdo, $sql, $data, 'groupBy')->placeholder(); + $rubrics = $row->addSelectRubric('gibbonRubricID', $class['gibbonYearGroupIDList'], $class['gibbonDepartmentID']); // Look for and select an Approach to Learning rubric $rubrics->selected(array_reduce($rubrics->getOptions(), function ($result, $items) { diff --git a/ATL/atl_manage_delete.php b/ATL/atl_manage_delete.php index 7d5ae57..5d1e44a 100644 --- a/ATL/atl_manage_delete.php +++ b/ATL/atl_manage_delete.php @@ -18,6 +18,7 @@ */ use Gibbon\Forms\Prefab\DeleteForm; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; //Module includes include './modules/'.$session->get('module').'/moduleFunctions.php'; @@ -27,9 +28,9 @@ $page->addError(__('You do not have access to this action.')); } else { //Check if school year specified - $gibbonCourseClassID = $_GET['gibbonCourseClassID']; - $atlColumnID = $_GET['atlColumnID']; - if ($gibbonCourseClassID == '' or $atlColumnID == '') { + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + if (empty($gibbonCourseClassID) || empty($atlColumnID)) { $page->addError(__('You have not specified one or more required parameters.'));; } else { try { @@ -44,21 +45,13 @@ if ($result->rowCount() != 1) { $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { - try { - $data2 = array('atlColumnID' => $atlColumnID); - $sql2 = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result2 = $connection2->prepare($sql2); - $result2->execute($data2); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result2->rowCount() != 1) { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + + if (!$atlColumnGateway->exists($atlColumnID)) { $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { //Let's go! $row = $result->fetch(); - $row2 = $result2->fetch(); $page->breadcrumbs ->add(__('Manage {courseClass} ATLs', ['courseClass' => $row['course'].'.'.$row['class']]), 'atl_manage.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) diff --git a/ATL/atl_manage_deleteProcess.php b/ATL/atl_manage_deleteProcess.php index e441ead..7033abf 100644 --- a/ATL/atl_manage_deleteProcess.php +++ b/ATL/atl_manage_deleteProcess.php @@ -17,13 +17,13 @@ along with this program. If not, see . */ -include '../../gibbon.php'; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +include '../../gibbon.php'; -$gibbonCourseClassID = $_POST['gibbonCourseClassID']; -$atlColumnID = $_GET['atlColumnID']; -$URL = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_POST['address'])."/atl_manage_delete.php&atlColumnID=$atlColumnID&gibbonCourseClassID=$gibbonCourseClassID"; -$URLDelete = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_POST['address'])."/atl_manage.php&gibbonCourseClassID=$gibbonCourseClassID"; +$gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; +$atlColumnID = $_GET['atlColumnID'] ?? ''; +$URL = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_POST['address'])."/atl_manage.php&gibbonCourseClassID=$gibbonCourseClassID"; if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_delete.php') == false) { //Fail 0 @@ -32,44 +32,29 @@ } else { //Proceed! //Check if school year specified - if ($atlColumnID == '' or $gibbonCourseClassID == '') { + if (empty($atlColumnID)) { //Fail1 $URL .= '&return=error1'; header("Location: {$URL}"); } else { - try { - $data = array('atlColumnID' => $atlColumnID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID AND gibbonCourseClassID=:gibbonCourseClassID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - //Fail2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } + $atlColumnGateway = $container->get(ATLColumnGateway::class); - if ($result->rowCount() != 1) { + if (!$atlColumnGateway->exists($atlColumnID)) { //Fail 2 - $URL .= '&return=error2'; + $URL .= '&return=error1'; header("Location: {$URL}"); + exit(); } else { //Write to database - try { - $data = array('atlColumnID' => $atlColumnID); - $sql = 'DELETE FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - //Fail 2 - $URL .= '&return=error2'; + if (!$atlColumnGateway->delete($atlColumnID)) { + $URL .= '&return=error1'; header("Location: {$URL}"); exit(); } //Success 0 - $URLDelete = $URLDelete.'&return=success0'; - header("Location: {$URLDelete}"); + $URL .= '&return=success0'; + header("Location: {$URL}"); } } } From ab3f82b404e6855d8accd7427bd1c9185b1f0c89 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Fri, 1 Oct 2021 08:36:01 +1000 Subject: [PATCH 14/57] Removed highestAction as it wasn't used --- ATL/moduleFunctions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ATL/moduleFunctions.php b/ATL/moduleFunctions.php index cfeb394..febce3e 100644 --- a/ATL/moduleFunctions.php +++ b/ATL/moduleFunctions.php @@ -113,7 +113,7 @@ function getATLRecord($guid, $connection2, $gibbonPersonID) return $output; } -function sidebarExtra($guid, $connection2, $gibbonCourseClassID, $mode = 'manage', $highestAction = '') +function sidebarExtra($guid, $connection2, $gibbonCourseClassID, $mode = 'manage') { $output = ''; From 34ef24d48dfe64f550f0cd4483e0bd74889a85e1 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Fri, 1 Oct 2021 08:36:28 +1000 Subject: [PATCH 15/57] Added complete flag and isForStudents function --- ATL/src/Domain/ATLColumnGateway.php | 36 +++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/ATL/src/Domain/ATLColumnGateway.php b/ATL/src/Domain/ATLColumnGateway.php index 7eafc53..305dd0d 100644 --- a/ATL/src/Domain/ATLColumnGateway.php +++ b/ATL/src/Domain/ATLColumnGateway.php @@ -9,8 +9,8 @@ /** * ATL Column Gateway * - * @version v20 - * @since v20 + * @version v22 + * @since v22 */ class ATLColumnGateway extends QueryableGateway { @@ -42,25 +42,53 @@ public function queryATLColumnsByClass(QueryCriteria $criteria, $gibbonCourseCla * @param QueryCriteria $criteria * @return DataSet */ - public function queryATLColumnsByStudent(QueryCriteria $criteria, $gibbonSchoolYearID, $gibbonPersonID) + public function queryATLColumnsByStudent(QueryCriteria $criteria, $gibbonSchoolYearID, $gibbonPersonID, $complete = '') { $query = $this ->newQuery() ->from($this->getTableName()) ->cols([ - 'atlColumn.name' + 'atlColumn.atlColumnID', 'atlColumn.gibbonRubricID', 'atlColumn.gibbonCourseClassID', 'atlEntry.atlEntryID', 'atlColumn.name', 'atlColumn.description', 'atlColumn.complete', 'atlColumn.completeDate', 'gibbonCourse.nameShort AS course', 'gibbonCourseClass.nameShort AS class', 'atlEntry.complete as entryComplete' ]) ->leftJoin('atlEntry', 'atlColumn.atlColumnID=atlEntry.atlColumnID AND atlEntry.gibbonPersonIDStudent = :gibbonPersonID') ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID') ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') + ->where("atlColumn.forStudents = 'Y'") ->where('gibbonCourseClassPerson.gibbonPersonID = :gibbonPersonID') ->where("gibbonCourseClassPerson.role = 'Student'") ->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') ->bindValue('gibbonPersonID', $gibbonPersonID) ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); + if (!empty($complete)) { + $query->where('atlEntry.complete = :complete') + ->bindValue('complete', $complete); + } + return $this->runQuery($query, $criteria); } + public function isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID) { + $select = $this + ->newSelect() + ->from($this->getTableName()) + ->cols([ + 'atlColumn.atlColumnID' + ]) + ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') + ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID') + ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') + ->where('atlColumn.atlColumnID = :atlColumnID') + ->where("atlColumn.forStudents = 'Y'") + ->where('gibbonCourseClassPerson.gibbonPersonID = :gibbonPersonID') + ->where("gibbonCourseClassPerson.role = 'Student'") + ->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') + ->bindValue('atlColumnID', $atlColumnID) + ->bindValue('gibbonPersonID', $gibbonPersonID) + ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); + + $result = $this->runSelect($select); + return $result->isNotEmpty(); + } } From 3ab1d4cfa1b0c28fad05f55c16f01d37d396cbef Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Fri, 1 Oct 2021 08:36:49 +1000 Subject: [PATCH 16/57] OOified and added forStudents --- ATL/atl_manage_addProcess.php | 167 ++++++++++++++++----------------- ATL/atl_manage_edit.php | 148 ++++++++++++++--------------- ATL/atl_manage_editProcess.php | 158 ++++++++++++------------------- 3 files changed, 207 insertions(+), 266 deletions(-) diff --git a/ATL/atl_manage_addProcess.php b/ATL/atl_manage_addProcess.php index ef5c7d5..4223c4a 100644 --- a/ATL/atl_manage_addProcess.php +++ b/ATL/atl_manage_addProcess.php @@ -23,109 +23,100 @@ $gibbonCourseClassID = $_GET['gibbonCourseClassID']; -$URL = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_GET['address'])."/atl_manage_add.php&gibbonCourseClassID=$gibbonCourseClassID"; +$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/'; "atl_manage_add.php&gibbonCourseClassID=$gibbonCourseClassID"; if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_add.php') == false) { //Fail 0 - $URL .= '&return=error0'; + $URL .= 'atl_manage.php&return=error0'; header("Location: {$URL}"); } else { - if (empty($_POST)) { - $URL .= '&return=error5'; + //Proceed! + //Validate Inputs + $gibbonCourseClassIDMulti = array_unique($_POST['gibbonCourseClassIDMulti']) ?? ''; + $name = $_POST['name'] ?? ''; + $description = $_POST['description'] ?? ''; + $gibbonRubricID = $_POST['gibbonRubricID'] ?? ''; + $completeDate = $_POST['completeDate'] ?? ''; + if ($completeDate == '') { + $completeDate = null; + $complete = 'N'; + } else { + $completeDate = dateConvert($guid, $completeDate); + $complete = 'Y'; + }} + $forStudents = $_POST['forStudents'] ?? ''; + $gibbonPersonIDCreator = $session->get('gibbonPersonID'); + $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); + + //Lock markbook column table + try { + $sqlLock = 'LOCK TABLES atlColumn WRITE'; + $resultLock = $connection2->query($sqlLock); + } catch (PDOException $e) { + //Fail 2 + $URL .= '&return=error2'; header("Location: {$URL}"); + exit(); + } + + //Get next groupingID + try { + $sqlGrouping = 'SELECT DISTINCT groupingID FROM atlColumn WHERE NOT groupingID IS NULL ORDER BY groupingID DESC'; + $resultGrouping = $connection2->query($sqlGrouping); + } catch (PDOException $e) { + //Fail 2 + $URL .= '&return=error2'; + header("Location: {$URL}"); + exit(); + } + + $rowGrouping = $resultGrouping->fetch(); + if (is_null($rowGrouping['groupingID'])) { + $groupingID = 1; } else { - //Proceed! - //Validate Inputs - $gibbonCourseClassIDMulti = null; - if (isset($_POST['gibbonCourseClassIDMulti'])) { - $gibbonCourseClassIDMulti = $_POST['gibbonCourseClassIDMulti']; - $gibbonCourseClassIDMulti = array_unique($gibbonCourseClassIDMulti); - } - $name = $_POST['name']; - $description = $_POST['description']; - $gibbonRubricID = $_POST['gibbonRubricID']; - $completeDate = $_POST['completeDate']; - if ($completeDate == '') { - $completeDate = null; - $complete = 'N'; - } else { - $completeDate = dateConvert($guid, $completeDate); - $complete = 'Y'; - } - $forStudents = $_POST['forStudents'] ?? ''; - $gibbonPersonIDCreator = $session->get('gibbonPersonID'); - $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); + $groupingID = ($rowGrouping['groupingID'] + 1); + } - //Lock markbook column table - try { - $sqlLock = 'LOCK TABLES atlColumn WRITE'; - $resultLock = $connection2->query($sqlLock); - } catch (PDOException $e) { - //Fail 2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); + if (!is_array($gibbonCourseClassIDMulti) || !is_numeric($groupingID) || $groupingID < 1 || empty($name) || empty($description) || empty($forStudents)) { + //Fail 3 + $URL .= '&return=error1'; + header("Location: {$URL}"); + exit(); + } else { + $partialFail = false; + + $atlColumnGateway = $container->get(ATLColumnGateway::class); + + $data = [ + 'groupingID' => $groupingID, + 'name' => $name, + 'description' => $description, + 'gibbonRubricID' => $gibbonRubricID, + 'completeDate' => $completeDate, + 'forStudents' => $forStudents, + 'complete' => $complete, + 'gibbonPersonIDCreator' => $gibbonPersonIDCreator, + 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit + ]; + foreach ($gibbonCourseClassIDMulti as $gibbonCourseClassIDSingle) { + //Write to database + $data['gibbonCourseClassID'] = $gibbonCourseClassIDSingle; + $partialFail |= empty($atlColumnGateway->insert($data)); } - //Get next groupingID + //Unlock module table try { - $sqlGrouping = 'SELECT DISTINCT groupingID FROM atlColumn WHERE NOT groupingID IS NULL ORDER BY groupingID DESC'; - $resultGrouping = $connection2->query($sqlGrouping); + $sql = 'UNLOCK TABLES'; + $result = $connection2->query($sql); } catch (PDOException $e) { - //Fail 2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); } - $rowGrouping = $resultGrouping->fetch(); - if (is_null($rowGrouping['groupingID'])) { - $groupingID = 1; + if ($partialFail) { + $URL .= '&return=warning1'; } else { - $groupingID = ($rowGrouping['groupingID'] + 1); - } - - if (is_array($gibbonCourseClassIDMulti) == false or is_numeric($groupingID) == false or $groupingID < 1 or $name == '' or $description == '' or $forStudents == '') { - //Fail 3 - $URL .= '&return=error3'; - header("Location: {$URL}"); - exit(); - } else { - $partialFail = false; - - $atlColumnGateway = $container->get(ATLColumnGateway::class); - - $data = [ - 'groupingID' => $groupingID, - 'name' => $name, - 'description' => $description, - 'gibbonRubricID' => $gibbonRubricID, - 'completeDate' => $completeDate, - 'forStudents' => $forStudents, - 'complete' => $complete, - 'gibbonPersonIDCreator' => $gibbonPersonIDCreator, - 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit - ]; - foreach ($gibbonCourseClassIDMulti as $gibbonCourseClassIDSingle) { - //Write to database - $data['gibbonCourseClassID'] = $gibbonCourseClassIDSingle; - $partialFail |= empty($atlColumnGateway->insert($data)); - } - - //Unlock module table - try { - $sql = 'UNLOCK TABLES'; - $result = $connection2->query($sql); - } catch (PDOException $e) { - } - - if ($partialFail) { - $URL .= '&return=error6'; - } else { - $URL .= '&return=success0'; - } - header("Location: {$URL}"); - exit(); + $URL .= '&return=success0'; } + header("Location: {$URL}"); + exit(); } } diff --git a/ATL/atl_manage_edit.php b/ATL/atl_manage_edit.php index 96f47d6..25aeba4 100644 --- a/ATL/atl_manage_edit.php +++ b/ATL/atl_manage_edit.php @@ -18,6 +18,7 @@ */ use Gibbon\Forms\Form; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; //Module includes include './modules/'.$session->get('module').'/moduleFunctions.php'; @@ -26,105 +27,96 @@ //Acess denied $page->addError(__('You do not have access to this action.')); } else { - //Get action with highest precendence - $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); - if ($highestAction == false) { - $page->addError(__('The highest grouped action cannot be determined.')); + //Check if school year specified + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + if ($gibbonCourseClassID == '' || $atlColumnID == '') { + $page->addError(__('You have not specified one or more required parameters.')); } else { - //Check if school year specified - $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; - $atlColumnID = $_GET['atlColumnID'] ?? ''; - if ($gibbonCourseClassID == '' or $atlColumnID == '') { - $page->addError(__('You have not specified one or more required parameters.')); - } else { - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID, gibbonCourse.gibbonDepartmentID, gibbonYearGroupIDList FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' ORDER BY course, class"; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } + try { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID, gibbonCourse.gibbonDepartmentID, gibbonYearGroupIDList FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' ORDER BY course, class"; + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + $page->addError(__('A database error has occured.')); + } - if ($result->rowCount() != 1) { + if ($result->rowCount() != 1) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlColumn = $atlColumnGateway->getByID($atlColumnID); + if (empty($atlColumn)) { $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { - try { - $data2 = array('atlColumnID' => $atlColumnID); - $sql2 = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result2 = $connection2->prepare($sql2); - $result2->execute($data2); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } + //Let's go! + $class = $result->fetch(); - if ($result2->rowCount() != 1) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - //Let's go! - $class = $result->fetch(); - $values = $result2->fetch(); + $page->breadcrumbs + ->add(__('Manage {courseClass} ATLs', ['courseClass' => $class['course'].'.'.$class['class']]), 'atl_manage.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) + ->add(__('Edit Column')); - $page->breadcrumbs - ->add(__('Manage {courseClass} ATLs', ['courseClass' => $class['course'].'.'.$class['class']]), 'atl_manage.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) - ->add(__('Edit Column')); + if (isset($_GET['return'])) { + returnProcess($guid, $_GET['return'], null, null); + } - if (isset($_GET['return'])) { - returnProcess($guid, $_GET['return'], null, null); - } + $form = Form::create('ATL', $session->get('absoluteURL').'/modules/ATL/atl_manage_editProcess.php?atlColumnID='.$atlColumnID.'&gibbonCourseClassID='.$gibbonCourseClassID.'&address='.$session->get('address')); + $form->addHiddenValue('address', $session->get('address')); - $form = Form::create('ATL', $session->get('absoluteURL').'/modules/ATL/atl_manage_editProcess.php?atlColumnID='.$atlColumnID.'&gibbonCourseClassID='.$gibbonCourseClassID.'&address='.$session->get('address')); - $form->addHiddenValue('address', $session->get('address')); + $form->addRow()->addHeading(__('Basic Information')); - $form->addRow()->addHeading(__('Basic Information')); + $row = $form->addRow(); + $row->addLabel('className', __('Class')); + $row->addTextField('className')->readonly()->setValue(htmlPrep($class['course']).'.'.htmlPrep($class['class'])); - $row = $form->addRow(); - $row->addLabel('className', __('Class')); - $row->addTextField('className')->readonly()->setValue(htmlPrep($class['course']).'.'.htmlPrep($class['class'])); + $row = $form->addRow(); + $row->addLabel('name', __('Name')); + $row->addTextField('name')->isRequired()->maxLength(20); - $row = $form->addRow(); - $row->addLabel('name', __('Name')); - $row->addTextField('name')->isRequired()->maxLength(20); + $row = $form->addRow(); + $row->addLabel('description', __('Description')); + $row->addTextField('description')->isRequired()->maxLength(1000); - $row = $form->addRow(); - $row->addLabel('description', __('Description')); - $row->addTextField('description')->isRequired()->maxLength(1000); + $form->addRow()->addHeading(__('Assessment')); - $form->addRow()->addHeading(__('Assessment')); + $data = array('gibbonYearGroupIDList' => $class['gibbonYearGroupIDList'], 'gibbonDepartmentID' => $class['gibbonDepartmentID'], 'rubrics' => __('Rubrics')); + $sql = "SELECT CONCAT(scope, ' ', :rubrics) as groupBy, gibbonRubricID as value, + (CASE WHEN category <> '' THEN CONCAT(category, ' - ', gibbonRubric.name) ELSE gibbonRubric.name END) as name + FROM gibbonRubric + JOIN gibbonYearGroup ON (FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, gibbonRubric.gibbonYearGroupIDList)) + WHERE gibbonRubric.active='Y' + AND FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, :gibbonYearGroupIDList) + AND (scope='School' OR (scope='Learning Area' AND gibbonDepartmentID=:gibbonDepartmentID)) + GROUP BY gibbonRubric.gibbonRubricID + ORDER BY scope, category, name"; - $data = array('gibbonYearGroupIDList' => $class['gibbonYearGroupIDList'], 'gibbonDepartmentID' => $class['gibbonDepartmentID'], 'rubrics' => __('Rubrics')); - $sql = "SELECT CONCAT(scope, ' ', :rubrics) as groupBy, gibbonRubricID as value, - (CASE WHEN category <> '' THEN CONCAT(category, ' - ', gibbonRubric.name) ELSE gibbonRubric.name END) as name - FROM gibbonRubric - JOIN gibbonYearGroup ON (FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, gibbonRubric.gibbonYearGroupIDList)) - WHERE gibbonRubric.active='Y' - AND FIND_IN_SET(gibbonYearGroup.gibbonYearGroupID, :gibbonYearGroupIDList) - AND (scope='School' OR (scope='Learning Area' AND gibbonDepartmentID=:gibbonDepartmentID)) - GROUP BY gibbonRubric.gibbonRubricID - ORDER BY scope, category, name"; + $row = $form->addRow(); + $row->addLabel('gibbonRubricID', __('Rubric')); + $row->addSelect('gibbonRubricID')->fromQuery($pdo, $sql, $data, 'groupBy')->placeholder(); - $row = $form->addRow(); - $row->addLabel('gibbonRubricID', __('Rubric')); - $row->addSelect('gibbonRubricID')->fromQuery($pdo, $sql, $data, 'groupBy')->placeholder(); + $form->addRow()->addHeading(__('Access')); - $form->addRow()->addHeading(__('Access')); + $row = $form->addRow(); + $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); + $row->addDate('completeDate'); - $row = $form->addRow(); - $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); - $row->addDate('completeDate'); + $row = $form->addRow(); + $row->addLabel('forStudents', __('For Students?'))->description(__('Is this column meant to be filled out by students?')); + $row->addYesNo('forStudents') + ->required(); - $row = $form->addRow(); - $row->addFooter(); - $row->addSubmit(); + $row = $form->addRow(); + $row->addFooter(); + $row->addSubmit(); - $form->loadAllValuesFrom($values); + $form->loadAllValuesFrom($atlColumn); - echo $form->getOutput(); - } + echo $form->getOutput(); } - - //Print sidebar - $session->set('sidebarExtra', sidebarExtra($guid, $connection2, $gibbonCourseClassID, 'manage', $highestAction)); } + + //Print sidebar + $session->set('sidebarExtra', sidebarExtra($guid, $connection2, $gibbonCourseClassID, 'manage')); } } diff --git a/ATL/atl_manage_editProcess.php b/ATL/atl_manage_editProcess.php index 555e582..e613a05 100644 --- a/ATL/atl_manage_editProcess.php +++ b/ATL/atl_manage_editProcess.php @@ -17,119 +17,77 @@ along with this program. If not, see . */ -include '../../gibbon.php'; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +include '../../gibbon.php'; -$gibbonCourseClassID = $_GET['gibbonCourseClassID']; -$atlColumnID = $_GET['atlColumnID']; -$URL = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_GET['address'])."/atl_manage_edit.php&atlColumnID=$atlColumnID&gibbonCourseClassID=$gibbonCourseClassID"; +$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/'; if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_edit.php') == false) { //Fail 0 - $URL .= '&return=error0'; + $URL .= 'atl_manage.php&return=error0'; header("Location: {$URL}"); + exit(); } else { - $highestAction = getHighestGroupedAction($guid, $_GET['address'], $connection2); - if ($highestAction == false) { - //Fail 0 - $URL .= '&return=error0'; + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlColumn = $atlColumnGateway->getByID($atlColumnID); + //Proceed! + //Check if school year specified + if (empty($atlColumn) || $atlColumn['gibbonCourseClassID'] != $gibbonCourseClassID) { + //Fail1 + $URL .= 'atl_manage.php&return=error1'; header("Location: {$URL}"); + exit(); } else { - if (empty($_POST)) { - $URL .= '&return=error5'; + $URL .= "atl_manage_edit.php&atlColumnID=$atlColumnID&gibbonCourseClassID=$gibbonCourseClassID"; + + //Validate Inputs + $name = $_POST['name'] ?? ''; + $description = $_POST['description'] ?? ''; + $gibbonRubricID = $_POST['gibbonRubricID'] ?? $atlColumn['gibbonRubricID']; + $completeDate = $_POST['completeDate'] ?? ''; + if ($completeDate == '') { + $completeDate = null; + $complete = 'N'; + } else { + $completeDate = dateConvert($guid, $completeDate); + $complete = 'Y'; + } + $forStudents = $_POST['forStudents'] ?? $atlColumn['forStudents']; + $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); + $groupingID = $atlColumn['groupingID']; + + if (empty($name) || empty($description) || empty($forStudents)) { + //Fail 3 + $URL .= '&return=error1'; header("Location: {$URL}"); + exit(); } else { - //Proceed! - //Check if school year specified - if ($atlColumnID == '' or $gibbonCourseClassID == '') { - //Fail1 - $URL .= '&return=error1'; + $data = [ + 'groupingID' => $groupingID, + 'name' => $name, + 'description' => $description, + 'gibbonCourseClassID' => $gibbonCourseClassID, + 'gibbonRubricID' => $gibbonRubricID, + 'completeDate' => $completeDate, + 'forStudents' => $forStudents, + 'complete' => $complete, + 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit + ]; + + if (!$atlColumnGateway->update($atlColumnID, $data)) { + //Fail 6 + $URL .= '&return=error2'; header("Location: {$URL}"); + exit(); } else { - try { - $data = array('atlColumnID' => $atlColumnID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID AND gibbonCourseClassID=:gibbonCourseClassID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - //Fail2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } - - if ($result->rowCount() != 1) { - //Fail 2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - } else { - $row = $result->fetch(); - - //Validate Inputs - $name = $_POST['name']; - $description = $_POST['description']; - $gibbonRubricID = $_POST['gibbonRubricID']; - $completeDate = $_POST['completeDate']; - if ($completeDate == '') { - $completeDate = null; - $complete = 'N'; - } else { - $completeDate = dateConvert($guid, $completeDate); - $complete = 'Y'; - } - $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); - $groupingID = $row['groupingID']; - - if ($name == '' or $description == '') { - //Fail 3 - $URL .= '&return=error3'; - header("Location: {$URL}"); - } else { - //ATTEMPT TO UPDATE LINKED COLUMNS - $partialFail = false; - if (isset($_POST['gibbonCourseClassID'])) { - if (is_array($_POST['gibbonCourseClassID'])) { - $gibbonCourseClassIDs = $_POST['gibbonCourseClassID']; - foreach ($gibbonCourseClassIDs as $gibbonCourseClassID2) { - //Write to database - try { - $data = array('name' => $name, 'description' => $description, 'gibbonRubricID' => $gibbonRubricID, 'completeDate' => $completeDate, 'complete' => $complete, 'gibbonPersonIDLastEdit' => $session->get('gibbonPersonID'), 'groupingID' => $groupingID, 'gibbonCourseClassID' => $gibbonCourseClassID2); - $sql = 'UPDATE atlColumn SET name=:name, description=:description, gibbonRubricID=:gibbonRubricID, completeDate=:completeDate, complete=:complete, gibbonPersonIDLastEdit=:gibbonPersonIDLastEdit WHERE groupingID=:groupingID AND gibbonCourseClassID=:gibbonCourseClassID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - $partialFail = true; - echo $e->getMessage(); - } - - } - } - } - - //Write to database - try { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'name' => $name, 'description' => $description, 'gibbonRubricID' => $gibbonRubricID, 'completeDate' => $completeDate, 'complete' => $complete, 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit, 'atlColumnID' => $atlColumnID); - $sql = 'UPDATE atlColumn SET gibbonCourseClassID=:gibbonCourseClassID, name=:name, description=:description, gibbonRubricID=:gibbonRubricID, completeDate=:completeDate, complete=:complete, gibbonPersonIDLastEdit=:gibbonPersonIDLastEdit WHERE atlColumnID=:atlColumnID'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - //Fail 2 - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } - - if ($partialFail == true) { - //Fail 6 - $URL .= '&return=warning1'; - header("Location: {$URL}"); - } else { - //Success 0 - $URL .= '&return=success0'; - header("Location: {$URL}"); - } - } - } + //Success 0 + $URL .= '&return=success0'; + header("Location: {$URL}"); + exit(); } } } From 0c8300d6bd0772e63118e41c4ed34d69f4a9e378 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Fri, 1 Oct 2021 08:37:02 +1000 Subject: [PATCH 17/57] OOification --- ATL/atl_view_rubric.php | 89 ++++++++++++--------------- ATL/atl_write_rubric.php | 127 +++++++++++++++++---------------------- 2 files changed, 92 insertions(+), 124 deletions(-) diff --git a/ATL/atl_view_rubric.php b/ATL/atl_view_rubric.php index 1842b70..ece9022 100644 --- a/ATL/atl_view_rubric.php +++ b/ATL/atl_view_rubric.php @@ -17,6 +17,12 @@ along with this program. If not, see . */ +use Gibbon\Domain\Rubrics\RubricGateway; +use Gibbon\Domain\Timetable\CourseEnrolmentGateway; +use Gibbon\Domain\Timetable\CourseGateway; +use Gibbon\Domain\User\RoleGateway; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; use Gibbon\Services\Format; //Rubric includes @@ -24,69 +30,51 @@ if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { //Acess denied - $page->addError(__('You do not have access to this action.')); + $page->addError(__('Your request failed because you do not have access to this action.')); } else { //Proceed! //Check if school year specified - $gibbonCourseClassID = $_GET['gibbonCourseClassID']; - $atlColumnID = $_GET['atlColumnID']; - $gibbonPersonID = $_GET['gibbonPersonID']; - $gibbonRubricID = $_GET['gibbonRubricID']; - if ($gibbonCourseClassID == '' or $atlColumnID == '' or $gibbonPersonID == '' or $gibbonRubricID == '') { echo "
"; - echo __('You have not specified one or more required parameters.'); - echo '
'; + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + $gibbonPersonID = $_GET['gibbonPersonID'] ?? ''; + $gibbonRubricID = $_GET['gibbonRubricID'] ?? ''; + if (empty($gibbonCourseClassID) || empty($atlColumnID) || empty($gibbonPersonID) || empty($gibbonRubricID)) { + $page->addError(__('You have not specified one or more required parameters.')); } else { - $roleCategory = getRoleCategory($session->get('gibbonRoleIDPrimary'), $connection2); - $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; - if ($_GET['type'] == 'attainment') { + $type = $_GET['type'] ?? ''; + $contextDBTableGibbonRubricIDField = ''; + if ($type == 'attainment') { $contextDBTableGibbonRubricIDField = 'gibbonRubricIDAttainment'; - } elseif ($_GET['type'] == 'effort') { + } else { $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; } - try { - if ($roleCategory == 'Staff') { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class'; - } elseif ($roleCategory == 'Student') { - $data = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND role='Student' AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class"; - } elseif ($roleCategory == 'Parent') { - $data = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND role='Student' AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class"; - } - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; + $allowed = false; + $roleGateway = $container->get(RoleGateway::class); + $roleCategory = $roleGateway->getByID($session->get('gibbonRoleIDPrimary'))['category'] ?? ''; + + if ($roleCategory == 'Staff') { + $courseGateway = $container->get(CourseGateway::class); + $result = $courseGateway->getCourseClassByID($gibbonCourseClassID); + $allowed = !empty($result); + } elseif ($roleCategory == 'Student' || $roleCategory == 'Parent') { + $courseEnrolmentGateway = $container->get(CourseEnrolmentGateway::class); + $result = $courseEnrolmentGateway->selectBy(['gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID, 'role' => 'Student']); + $allowed = $result->isNotEmpty(); } - if ($result->rowCount() != 1) { + if (!$allowed) { $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { - try { - $data2 = array('atlColumnID' => $atlColumnID); - $sql2 = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result2 = $connection2->prepare($sql2); - $result2->execute($data2); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result2->rowCount() != 1) { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + if (!$atlColumnGateway->exists($atlColumnID)) { $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { - try { - $data3 = array('gibbonRubricID' => $gibbonRubricID); - $sql3 = 'SELECT * FROM gibbonRubric WHERE gibbonRubricID=:gibbonRubricID'; - $result3 = $connection2->prepare($sql3); - $result3->execute($data3); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } + $rubricGateway = $container->get(RubricGateway::class); + $rubric = $rubricGateway->getByID($gibbonRubricID); - if ($result3->rowCount() != 1) { - $page->addError(__('The selected record does not exist.')); + if (empty($rubric)) { + $page->addError(__('The specified record does not exist.')); } else { try { $data4 = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); @@ -101,13 +89,10 @@ $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { //Let's go! - $row = $result->fetch(); - $row2 = $result2->fetch(); - $row3 = $result3->fetch(); $row4 = $result4->fetch(); echo "

"; - echo $row3['name'].'
'; + echo $rubric['name'].'
'; echo "".Format::name('', $row4['preferredName'], $row4['surname'], 'Student', true).''; echo '

'; diff --git a/ATL/atl_write_rubric.php b/ATL/atl_write_rubric.php index f0326fb..93e91df 100644 --- a/ATL/atl_write_rubric.php +++ b/ATL/atl_write_rubric.php @@ -17,84 +17,65 @@ along with this program. If not, see . */ +use Gibbon\Domain\Rubrics\RubricGateway; +use Gibbon\Domain\Timetable\CourseEnrolmentGateway; +use Gibbon\Domain\Timetable\CourseGateway; +use Gibbon\Domain\User\RoleGateway; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; use Gibbon\Services\Format; //Rubric includes include './modules/Rubrics/moduleFunctions.php'; -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write.php') == false) { +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write.php') == false + && isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { //Acess denied - echo "
"; - echo __('Your request failed because you do not have access to this action.'); - echo '
'; + $page->addError(__('Your request failed because you do not have access to this action.')); } else { //Proceed! //Check if school year specified - $gibbonCourseClassID = $_GET['gibbonCourseClassID']; - $atlColumnID = $_GET['atlColumnID']; - $gibbonPersonID = $_GET['gibbonPersonID']; - $gibbonRubricID = $_GET['gibbonRubricID']; - if ($gibbonCourseClassID == '' or $atlColumnID == '' or $gibbonPersonID == '' or $gibbonRubricID == '') { echo "
"; - echo __('You have not specified one or more required parameters.'); - echo '
'; + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + $gibbonPersonID = $_GET['gibbonPersonID'] ?? ''; + $gibbonRubricID = $_GET['gibbonRubricID'] ?? ''; + if (empty($gibbonCourseClassID) || empty($atlColumnID) || empty($gibbonPersonID) || empty($gibbonRubricID)) { + $page->addError(__('You have not specified one or more required parameters.')); } else { - $roleCategory = getRoleCategory($session->get('gibbonRoleIDPrimary'), $connection2); - $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; - if ($_GET['type'] == 'attainment') { + $type = $_GET['type'] ?? ''; + $contextDBTableGibbonRubricIDField = ''; + if ($type == 'attainment') { $contextDBTableGibbonRubricIDField = 'gibbonRubricIDAttainment'; - } elseif ($_GET['type'] == 'effort') { + } else { $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; } - try { - if ($roleCategory == 'Staff') { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = 'SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class'; - } elseif ($roleCategory == 'Student') { - $data = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND role='Student' AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class"; - } elseif ($roleCategory == 'Parent') { - $data = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND role='Student' AND gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID ORDER BY course, class"; - } - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; + $allowed = false; + $roleGateway = $container->get(RoleGateway::class); + $roleCategory = $roleGateway->getByID($session->get('gibbonRoleIDPrimary'))['category'] ?? ''; + + if ($roleCategory == 'Staff') { + $courseGateway = $container->get(CourseGateway::class); + $result = $courseGateway->getCourseClassByID($gibbonCourseClassID); + $allowed = !empty($result); + } elseif ($roleCategory == 'Student' || $roleCategory == 'Parent') { + $courseEnrolmentGateway = $container->get(CourseEnrolmentGateway::class); + $result = $courseEnrolmentGateway->selectBy(['gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID, 'role' => 'Student']); + $allowed = $result->isNotEmpty(); } - if ($result->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + if (!$allowed) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { - try { - $data2 = array('atlColumnID' => $atlColumnID); - $sql2 = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result2 = $connection2->prepare($sql2); - $result2->execute($data2); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result2->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $atlColumnGateway = $container->get(ATLColumnGateway::class); + if (!$atlColumnGateway->exists($atlColumnID)) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { - try { - $data3 = array('gibbonRubricID' => $gibbonRubricID); - $sql3 = 'SELECT * FROM gibbonRubric WHERE gibbonRubricID=:gibbonRubricID'; - $result3 = $connection2->prepare($sql3); - $result3->execute($data3); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } + $rubricGateway = $container->get(RubricGateway::class); + $rubric = $rubricGateway->getByID($gibbonRubricID); - if ($result3->rowCount() != 1) { - echo "
"; - echo __('The specified record does not exist.'); - echo '
'; + if (empty($rubric)) { + $page->addError(__('The specified record does not exist.')); } else { try { $data4 = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); @@ -106,27 +87,29 @@ } if ($result4->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { //Let's go! - $row = $result->fetch(); - $row2 = $result2->fetch(); - $row3 = $result3->fetch(); $row4 = $result4->fetch(); + if ($row4['gibbonPersonID'] == $session->get('gibbonPersonID')) { + $atlEntryGateway = $container->get(ATLEntryGateway::class); + $atlEntry = $atlEntryGateway->selectBy(['gibbonPersonIDStudent' => $gibbonPersonID, 'atlColumnID' => $atlColumnID]); + if (!$atlEntry->isNotEmpty()) { + $atlEntryGateway->insert([ + 'atlColumnID' => $atlColumnID, + 'gibbonPersonIDStudent' => $gibbonPersonID, + 'complete' => 'N', + 'gibbonPersonIDLastEdit' => $gibbonPersonID + ]); + } + } echo "

"; - echo $row3['name'].'
'; + echo $rubric['name'].'
'; echo "".Format::name('', $row4['preferredName'], $row4['surname'], 'Student', true).''; echo '

'; - $mark = true; - if (isset($_GET['mark'])) { - if ($_GET['mark'] == 'FALSE') { - $mark = false; - } - } + $mark = ($_GET['mark'] ?? '') !== 'FALSE'; echo rubricView($guid, $connection2, $gibbonRubricID, $mark, $row4['gibbonPersonID'], 'atlColumn', 'atlColumnID', $atlColumnID, $contextDBTableGibbonRubricIDField, 'name', 'completeDate'); } } From 7c9d6522ad6a2a8e7d0303a117b9d30604ed1013 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Fri, 1 Oct 2021 08:37:19 +1000 Subject: [PATCH 18/57] Added forStudents check --- ATL/atl_write.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ATL/atl_write.php b/ATL/atl_write.php index 8ac29bb..1cad207 100644 --- a/ATL/atl_write.php +++ b/ATL/atl_write.php @@ -298,7 +298,7 @@ echo ''; } - $columnID = array(); + $columnID = []; for ($i = 0; $i < $columnsThisPage; ++$i) { $row = $result->fetch(); if ($row === false) { @@ -321,13 +321,21 @@ echo ""; echo "".$row['name'].'
'; echo ""; - if ($row['completeDate'] != '') { - echo __('Marked on').' '.dateConvertBack($guid, $row['completeDate']).'
'; + if ($row['forStudents'] == 'Y') { + if ($row['completeDate'] != '') { + echo __('Due on').' '.dateConvertBack($guid, $row['completeDate']).'
'; + } else { + echo __('Incomplete').'
'; + } } else { - echo __('Unmarked').'
'; + if ($row['completeDate'] != '') { + echo __('Marked on').' '.dateConvertBack($guid, $row['completeDate']).'
'; + } else { + echo __('Unmarked').'
'; + } } echo '

'; - if (isActionAccessible($guid, $connection2, '/modules/Markbook/markbook_edit.php')) { + if (isActionAccessible($guid, $connection2, '/modules/Markbook/markbook_edit.php') && $row['forStudents'] == 'N') { //TODO: Change for students check to be more sensible echo " "; } echo ''; From ec3501d45faec889662f68cf4d46943bfc0e05df Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Fri, 1 Oct 2021 08:37:39 +1000 Subject: [PATCH 19/57] added forStudent check --- ATL/atl_write_data.php | 149 ++++++++++++++++++---------------- ATL/atl_write_dataProcess.php | 8 +- 2 files changed, 84 insertions(+), 73 deletions(-) diff --git a/ATL/atl_write_data.php b/ATL/atl_write_data.php index c455d26..983c8fb 100644 --- a/ATL/atl_write_data.php +++ b/ATL/atl_write_data.php @@ -92,6 +92,7 @@ $class = $result->fetch(); $values = $result2->fetch(); + $page->breadcrumbs ->add(__('Write {courseClass} ATLs', ['courseClass' => $class['course'].'.'.$class['class']]), 'atl_write.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) ->add(__('Enter ATL Results')); @@ -100,86 +101,90 @@ returnProcess($guid, $_GET['return'], null, null); } - $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'atlColumnID' => $atlColumnID, 'today' => date('Y-m-d')); - $sql = "SELECT gibbonPerson.gibbonPersonID, gibbonPerson.title, gibbonPerson.surname, gibbonPerson.preferredName, gibbonPerson.dateStart, atlEntry.* - FROM gibbonCourseClassPerson - JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) - LEFT JOIN atlEntry ON (atlEntry.gibbonPersonIDStudent=gibbonPerson.gibbonPersonID AND atlEntry.atlColumnID=:atlColumnID) - WHERE gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID - AND gibbonCourseClassPerson.reportable='Y' AND gibbonCourseClassPerson.role='Student' - AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) - ORDER BY gibbonPerson.surname, gibbonPerson.preferredName"; - $result = $pdo->executeQuery($data, $sql); - $students = ($result->rowCount() > 0)? $result->fetchAll() : array(); - - $form = Form::create('internalAssessment', $session->get('absoluteURL').'/modules/'.$session->get('module').'/atl_write_dataProcess.php?gibbonCourseClassID='.$gibbonCourseClassID.'&atlColumnID='.$atlColumnID.'&address='.$session->get('address')); - $form->setFactory(DatabaseFormFactory::create($pdo)); - $form->addHiddenValue('address', $session->get('address')); - - $form->addRow()->addHeading(__('Assessment Details')); - - if (count($students) == 0) { - $form->addRow()->addHeading(__('Students')); - $form->addRow()->addAlert(__('There are no records to display.'), 'error'); + if ($values['forStudents'] == 'Y') { + $page->addError(__('You cannot mark this ATL')); } else { - $table = $form->addRow()->addTable()->setClass('smallIntBorder fullWidth colorOddEven noMargin noPadding noBorder'); - - $completeText = !empty($values['completeDate'])? __('Marked on').' '.dateConvertBack($guid, $values['completeDate']) : __('Unmarked'); - - $header = $table->addHeaderRow(); - $header->addTableCell(__('Student'))->rowSpan(2); - $header->addTableCell($values['name']) - ->setTitle($values['description']) - ->append('
'.$completeText.'') - ->setClass('textCenter') - ->colSpan(3); - - $header = $table->addHeaderRow(); - $header->addContent(__('Complete'))->setClass('textCenter'); - $header->addContent(__('Rubric'))->setClass('textCenter'); - } - - foreach ($students as $index => $student) { - $count = $index+1; - $row = $table->addRow(); - - $row->addWebLink(Format::name('', $student['preferredName'], $student['surname'], 'Student', true)) - ->setURL($session->get('absoluteURL').'/index.php?q=/modules/Students/student_view_details.php') + $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'atlColumnID' => $atlColumnID, 'today' => date('Y-m-d')); + $sql = "SELECT gibbonPerson.gibbonPersonID, gibbonPerson.title, gibbonPerson.surname, gibbonPerson.preferredName, gibbonPerson.dateStart, atlEntry.* + FROM gibbonCourseClassPerson + JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) + LEFT JOIN atlEntry ON (atlEntry.gibbonPersonIDStudent=gibbonPerson.gibbonPersonID AND atlEntry.atlColumnID=:atlColumnID) + WHERE gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID + AND gibbonCourseClassPerson.reportable='Y' AND gibbonCourseClassPerson.role='Student' + AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) + ORDER BY gibbonPerson.surname, gibbonPerson.preferredName"; + $result = $pdo->executeQuery($data, $sql); + $students = ($result->rowCount() > 0)? $result->fetchAll() : array(); + + $form = Form::create('internalAssessment', $session->get('absoluteURL').'/modules/'.$session->get('module').'/atl_write_dataProcess.php?gibbonCourseClassID='.$gibbonCourseClassID.'&atlColumnID='.$atlColumnID.'&address='.$session->get('address')); + $form->setFactory(DatabaseFormFactory::create($pdo)); + $form->addHiddenValue('address', $session->get('address')); + + $form->addRow()->addHeading(__('Assessment Details')); + + if (count($students) == 0) { + $form->addRow()->addHeading(__('Students')); + $form->addRow()->addAlert(__('There are no records to display.'), 'error'); + } else { + $table = $form->addRow()->addTable()->setClass('smallIntBorder fullWidth colorOddEven noMargin noPadding noBorder'); + + $completeText = !empty($values['completeDate'])? __('Marked on').' '.dateConvertBack($guid, $values['completeDate']) : __('Unmarked'); + + $header = $table->addHeaderRow(); + $header->addTableCell(__('Student'))->rowSpan(2); + $header->addTableCell($values['name']) + ->setTitle($values['description']) + ->append('
'.$completeText.'') + ->setClass('textCenter') + ->colSpan(3); + + $header = $table->addHeaderRow(); + $header->addContent(__('Complete'))->setClass('textCenter'); + $header->addContent(__('Rubric'))->setClass('textCenter'); + } + + foreach ($students as $index => $student) { + $count = $index+1; + $row = $table->addRow(); + + $row->addWebLink(Format::name('', $student['preferredName'], $student['surname'], 'Student', true)) + ->setURL($session->get('absoluteURL').'/index.php?q=/modules/Students/student_view_details.php') + ->addParam('gibbonPersonID', $student['gibbonPersonID']) + ->addParam('subpage', 'Markbook') + ->wrap('', '') + ->prepend($count.') '); + + $row->addCheckbox('complete'.$count)->setValue('Y')->checked($student['complete'])->setClass('textCenter'); + + $row->addWebLink('') + ->setURL($session->get('absoluteURL').'/fullscreen.php?q=/modules/'.$session->get('module').'/atl_write_rubric.php') + ->setClass('thickbox textCenter') + ->addParam('gibbonRubricID', $values['gibbonRubricID']) + ->addParam('gibbonCourseClassID', $gibbonCourseClassID) ->addParam('gibbonPersonID', $student['gibbonPersonID']) - ->addParam('subpage', 'Markbook') - ->wrap('', '') - ->prepend($count.') '); - - $row->addCheckbox('complete'.$count)->setValue('Y')->checked($student['complete'])->setClass('textCenter'); - - $row->addWebLink('') - ->setURL($session->get('absoluteURL').'/fullscreen.php?q=/modules/'.$session->get('module').'/atl_write_rubric.php') - ->setClass('thickbox textCenter') - ->addParam('gibbonRubricID', $values['gibbonRubricID']) - ->addParam('gibbonCourseClassID', $gibbonCourseClassID) - ->addParam('gibbonPersonID', $student['gibbonPersonID']) - ->addParam('atlColumnID', $atlColumnID) - ->addParam('type', 'effort') - ->addParam('width', '1100') - ->addParam('height', '550'); - - $form->addHiddenValue($count.'-gibbonPersonID', $student['gibbonPersonID']); - } + ->addParam('atlColumnID', $atlColumnID) + ->addParam('type', 'effort') + ->addParam('width', '1100') + ->addParam('height', '550'); - $form->addHiddenValue('count', $count); + $form->addHiddenValue($count.'-gibbonPersonID', $student['gibbonPersonID']); + } - $form->addRow()->addHeading(__('Assessment Complete?')); + $form->addHiddenValue('count', $count); - $row = $form->addRow(); - $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); - $row->addDate('completeDate'); + $form->addRow()->addHeading(__('Assessment Complete?')); - $row = $form->addRow(); - $row->addSubmit(); + $row = $form->addRow(); + $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); + $row->addDate('completeDate'); - $form->loadAllValuesFrom($values); + $row = $form->addRow(); + $row->addSubmit(); - echo $form->getOutput(); + $form->loadAllValuesFrom($values); + + echo $form->getOutput(); + } } } } diff --git a/ATL/atl_write_dataProcess.php b/ATL/atl_write_dataProcess.php index 3da26e3..552be38 100644 --- a/ATL/atl_write_dataProcess.php +++ b/ATL/atl_write_dataProcess.php @@ -58,10 +58,16 @@ header("Location: {$URL}"); } else { $row = $result->fetch(); - $name = $row['name' ]; + $name = $row['name']; $count = $_POST['count']; $partialFail = false; + if ($row['forStudents'] == 'Y') { + $URL .= '&return=error1'; + header("Location: {$URL}"); + exit(); + } + for ($i = 1;$i <= $count;++$i) { $gibbonPersonIDStudent = $_POST["$i-gibbonPersonID"]; //Complete From d096d233cd39c8fef51c570a9125dabfcdfc2ee3 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Fri, 1 Oct 2021 08:37:52 +1000 Subject: [PATCH 20/57] Implemented atl_write_student --- ATL/atl_write_student.php | 69 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 ATL/atl_write_student.php diff --git a/ATL/atl_write_student.php b/ATL/atl_write_student.php new file mode 100644 index 0000000..e4d8aba --- /dev/null +++ b/ATL/atl_write_student.php @@ -0,0 +1,69 @@ +. +*/ + +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Services\Format; +use Gibbon\Tables\DataTable; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +$page->breadcrumbs->add('Fill ATLs'); +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { + //Acess denied + $page->addError(__('Your request failed because you do not have access to this action.')); +} else { + $page->scripts->add('chart'); + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $criteria = $atlColumnGateway->newQueryCriteria() + ->sortBy('completeDate'); + + $gibbonPersonID = $session->get('gibbonPersonID'); + $atlColumns = $atlColumnGateway->queryATLColumnsByStudent($criteria, $session->get('gibbonSchoolYearID'), $gibbonPersonID, 'N'); + + $table = DataTable::createPaginated('studentATLs', $criteria); + + $table->addColumn('course', __('Class')) + ->format(Format::using('courseClassName', ['course', 'class'])); + + $table->addColumn('name', __('ATL')); + + $table->addColumn('completeDate', __('Due Date')) + ->format(Format::using('date', ['completeDate'])); + + $table->addActionColumn() + ->addParam('gibbonRubricID') + ->addParam('gibbonCourseClassID') + ->addParam('gibbonPersonID', $gibbonPersonID) + ->addParam('atlColumnID') + ->addParam('type', 'effort') + ->format(function ($column, $actions) { + $actions->addAction('data', __('Enter Data')) + ->setURL('/modules/ATL/atl_write_rubric.php') + ->setIcon('markbook') + ->modalWindow(1100, 550); + + $actions->addAction('complete', __('Complete')) + ->setURL('/modules/ATL/atl_write_student_complete.php') + ->setIcon('iconTick') + ->modalWindow(); + }); + + echo $table->render($atlColumns); +} \ No newline at end of file From 7a4d108306db9f0ac75e27d7f465db6c3841ec4a Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Fri, 1 Oct 2021 08:38:08 +1000 Subject: [PATCH 21/57] Implemented student atl write complete form and process --- ATL/atl_write_student_complete.php | 62 +++++++++++++++++++ ATL/atl_write_student_completeProcess.php | 74 +++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 ATL/atl_write_student_complete.php create mode 100644 ATL/atl_write_student_completeProcess.php diff --git a/ATL/atl_write_student_complete.php b/ATL/atl_write_student_complete.php new file mode 100644 index 0000000..7acb07d --- /dev/null +++ b/ATL/atl_write_student_complete.php @@ -0,0 +1,62 @@ +. +*/ + +use Gibbon\Forms\Form; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { + //Acess denied + $page->addError(__('Your request failed because you do not have access to this action.')); +} else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlEntryGateway = $container->get(ATLEntryGateway::class); + + $atlColumnID = $_GET['atlColumnID'] ?? ''; + $gibbonPersonID = $session->get('gibbonPersonID'); + $gibbonSchoolYearID = $session->get('gibbonSchoolYearID'); + + //Check if atl column is for student + if ($atlColumnGateway->isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID)) { + //Check if student has already completed atl + $atlEntry = $atlEntryGateway->selectBy(['gibbonPersonIDStudent' => $gibbonPersonID, 'atlColumnID' => $atlColumnID, 'complete' => 'Y']); + if ($atlEntry->isNotEmpty()) { + $page->addError(__('You have already completed this ATL.')); + } else { + $form = Form::create('ATL', $session->get('absoluteURL').'/modules/ATL/atl_write_student_completeProcess.php'); + $form->addHiddenValue('address', $session->get('address')); + $form->addHiddenValue('atlColumnID', $atlColumnID); + + $row = $form->addRow(); + $col = $row->addColumn(); + $col->addContent(__('Are you sure you want to mark this ATL as complete?'))->wrap('', ''); + $col->addContent(__('Once marked as complete, you will not be able to edit your ATL.')) + ->wrap('', ''); + + $form->addRow()->addConfirmSubmit(); + + echo $form->getOutput(); + } + } else { + $page->addError(__('Your request failed because you do not have access to this action.')); + } +} \ No newline at end of file diff --git a/ATL/atl_write_student_completeProcess.php b/ATL/atl_write_student_completeProcess.php new file mode 100644 index 0000000..ddfc9f9 --- /dev/null +++ b/ATL/atl_write_student_completeProcess.php @@ -0,0 +1,74 @@ +. +*/ + +include '../../gibbon.php'; + +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; + +$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/atl_write_student.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { + //Fail 0 + $URL .= '&return=error0'; + header("Location: {$URL}"); + exit(); +} else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlEntryGateway = $container->get(ATLEntryGateway::class); + + $atlColumnID = $_POST['atlColumnID'] ?? ''; + $gibbonPersonID = $session->get('gibbonPersonID'); + $gibbonSchoolYearID = $session->get('gibbonSchoolYearID'); + + //Check if atl column is for student + if ($atlColumnGateway->isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID)) { + $data = [ + 'atlColumnID' => $atlColumnID, + 'gibbonPersonIDStudent' => $gibbonPersonID, + 'complete' => 'Y', + 'gibbonPersonIDLastEdit' => $gibbonPersonID + ]; + + $atlEntry = $atlEntryGateway->selectBy(['gibbonPersonIDStudent' => $gibbonPersonID, 'atlColumnID' => $atlColumnID]); + $atlEntry = $atlEntry->isNotEmpty() ? $atlEntry->fetch() : []; + + if (empty($atlEntry)) { + if (!$atlEntryGateway->insert($data)) { + $URL .= '&return=error2'; + header("Location: {$URL}"); + exit(); + } + } else { + if (!$atlEntryGateway->update($atlEntry['atlEntryID'], $data)) { + $URL .= '&return=error2'; + header("Location: {$URL}"); + exit(); + } + } + + $URL .= '&return=success0'; + header("Location: {$URL}"); + exit(); + } else { + $URL .= '&return=error0'; + header("Location: {$URL}"); + exit(); + } +} From 03998355a93ae5dcb187183630a8da4588e75ed3 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Fri, 1 Oct 2021 08:38:16 +1000 Subject: [PATCH 22/57] Added ATL Entry Gateway --- ATL/src/Domain/ATLEntryGateway.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ATL/src/Domain/ATLEntryGateway.php diff --git a/ATL/src/Domain/ATLEntryGateway.php b/ATL/src/Domain/ATLEntryGateway.php new file mode 100644 index 0000000..f4f0df6 --- /dev/null +++ b/ATL/src/Domain/ATLEntryGateway.php @@ -0,0 +1,23 @@ + Date: Sat, 2 Oct 2021 11:27:09 +1000 Subject: [PATCH 23/57] Fixed manifest --- ATL/manifest.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ATL/manifest.php b/ATL/manifest.php index 9ec0140..b58d227 100644 --- a/ATL/manifest.php +++ b/ATL/manifest.php @@ -187,22 +187,23 @@ //Hooks $array = [ - 'sourceModuleName' => 'ATL'; - 'sourceModuleAction' => 'View ATLs_all'; - 'sourceModuleInclude' => 'hook_studentProfile_atlView.php'; + 'sourceModuleName' => 'ATL', + 'sourceModuleAction' => 'View ATLs_all', + 'sourceModuleInclude' => 'hook_studentProfile_atlView.php' ]; $hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Profile', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; $array = [ - 'sourceModuleName' => 'ATL'; - 'sourceModuleAction' => 'View ATLs_myChildrens'; - 'sourceModuleInclude' => 'hook_parentalDashboard_atlView.php'; + 'sourceModuleName' => 'ATL', + 'sourceModuleAction' => 'View ATLs_myChildrens', + 'sourceModuleInclude' => 'hook_parentalDashboard_atlView.php' ]; $hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Parental Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; $array = [ - 'sourceModuleName' => 'ATL'; - 'sourceModuleAction' => 'View ATLs_mine'; - 'sourceModuleInclude' => 'hook_studentDashboard_atlView.php'; + 'sourceModuleName' => 'ATL', + 'sourceModuleAction' => 'View ATLs_mine', + 'sourceModuleInclude' => 'hook_studentDashboard_atlView.php' ]; -$hooks[$] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; +$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; + From 78069cce93b5f0fcdf6ed41ffa0fbc8347ab5155 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Sat, 9 Oct 2021 23:00:33 +1100 Subject: [PATCH 24/57] Fixed not complete flag --- ATL/src/Domain/ATLColumnGateway.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ATL/src/Domain/ATLColumnGateway.php b/ATL/src/Domain/ATLColumnGateway.php index 305dd0d..3670228 100644 --- a/ATL/src/Domain/ATLColumnGateway.php +++ b/ATL/src/Domain/ATLColumnGateway.php @@ -42,7 +42,7 @@ public function queryATLColumnsByClass(QueryCriteria $criteria, $gibbonCourseCla * @param QueryCriteria $criteria * @return DataSet */ - public function queryATLColumnsByStudent(QueryCriteria $criteria, $gibbonSchoolYearID, $gibbonPersonID, $complete = '') + public function queryATLColumnsByStudent(QueryCriteria $criteria, $gibbonSchoolYearID, $gibbonPersonID, $notComplete = false) { $query = $this ->newQuery() @@ -61,9 +61,8 @@ public function queryATLColumnsByStudent(QueryCriteria $criteria, $gibbonSchoolY ->bindValue('gibbonPersonID', $gibbonPersonID) ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); - if (!empty($complete)) { - $query->where('atlEntry.complete = :complete') - ->bindValue('complete', $complete); + if ($notComplete) { + $query->where("(atlEntry.complete = 'N' OR atlEntry.complete IS NULL)"); } return $this->runQuery($query, $criteria); From b4448ab5c9d53266efa21887caeaebc932958b4f Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Sat, 9 Oct 2021 23:00:48 +1100 Subject: [PATCH 25/57] Added queryATLsByStudent --- ATL/src/Domain/ATLEntryGateway.php | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/ATL/src/Domain/ATLEntryGateway.php b/ATL/src/Domain/ATLEntryGateway.php index f4f0df6..b4a54a7 100644 --- a/ATL/src/Domain/ATLEntryGateway.php +++ b/ATL/src/Domain/ATLEntryGateway.php @@ -19,5 +19,39 @@ class ATLEntryGateway extends QueryableGateway private static $tableName = 'atlEntry'; private static $primaryKey = 'atlEntryID'; private static $searchableColumns = []; + + /** + * @param QueryCriteria $criteria + * @return DataSet + */ + public function queryATLsByStudent(QueryCriteria $criteria, $gibbonPersonID) + { + $query = $this + ->newQuery() + ->from($this->getTableName()) + ->cols([ + 'gibbonSchoolYear.name as yearName', 'gibbonCourse.gibbonSchoolYearID', 'gibbonCourse.name as courseName', 'atlColumn.name as ATLName', 'atlColumn.description as ATLDescription', 'atlColumn.completeDate', 'atlColumn.gibbonRubricID', 'atlColumn.gibbonCourseClassID', 'atlColumn.atlColumnID' + ]) + ->leftJoin('atlColumn', 'atlEntry.atlColumnID=atlColumn.atlColumnID') + ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') + ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID AND atlEntry.gibbonPersonIDStudent = gibbonCourseClassPerson.gibbonPersonID') + ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') + ->leftJoin('gibbonSchoolYear', 'gibbonCourse.gibbonSchoolYearID = gibbonSchoolYear.gibbonSchoolYearID') + ->where('atlEntry.gibbonPersonIDStudent = :gibbonPersonID') + ->where('completeDate <= :today') + ->where("gibbonCourseClass.reportable = 'Y'") + ->where("gibbonCourseClassPerson.reportable = 'Y'") + ->bindValue('gibbonPersonID', $gibbonPersonID) + ->bindValue('today', date('Y-m-d')); + + $criteria->addFilterRules([ + 'gibbonSchoolYearID' => function($query, $gibbonSchoolYearID) { + return $query->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') + ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); + } + ]); + + return $this->runQuery($query, $criteria); + } } From 7770a7194ab4e58a6ff71230fb3fd6a8cd1efa9b Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Sat, 9 Oct 2021 23:01:18 +1100 Subject: [PATCH 26/57] OOified getATLRecord and removed unused arguments from sidebarExtra --- ATL/moduleFunctions.php | 151 +++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 89 deletions(-) diff --git a/ATL/moduleFunctions.php b/ATL/moduleFunctions.php index febce3e..9d47821 100644 --- a/ATL/moduleFunctions.php +++ b/ATL/moduleFunctions.php @@ -19,101 +19,74 @@ use Gibbon\Forms\Form; use Gibbon\Forms\DatabaseFormFactory; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; +use Gibbon\Services\Format; +use Gibbon\Tables\DataTable; -function getATLRecord($guid, $connection2, $gibbonPersonID) +function getATLRecord($gibbonPersonID) { + global $container, $session; $output = ''; - //Get school years in reverse order - try { - $dataYears = array('gibbonPersonID' => $gibbonPersonID); - $sqlYears = "SELECT * FROM gibbonSchoolYear JOIN gibbonStudentEnrolment ON (gibbonStudentEnrolment.gibbonSchoolYearID=gibbonSchoolYear.gibbonSchoolYearID) WHERE (status='Current' OR status='Past') AND gibbonPersonID=:gibbonPersonID ORDER BY sequenceNumber DESC"; - $resultYears = $connection2->prepare($sqlYears); - $resultYears->execute($dataYears); - } catch (PDOException $e) { - $output .= "
".$e->getMessage().'
'; - } - - if ($resultYears->rowCount() < 1) { - $output .= "
"; - $output .= __('There are no records to display.'); - $output .= '
'; - } else { - $results = false; - while ($rowYears = $resultYears->fetch()) { - //Get and output ATLs - try { - $dataATL = array('gibbonPersonID1' => $gibbonPersonID, 'gibbonPersonID2' => $gibbonPersonID, 'gibbonSchoolYearID' => $rowYears['gibbonSchoolYearID']); - $sqlATL = "SELECT DISTINCT atlColumn.*, atlEntry.*, gibbonCourse.name AS course, gibbonCourseClass.nameShort AS class, gibbonPerson.dateStart FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN atlColumn ON (atlColumn.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN atlEntry ON (atlEntry.atlColumnID=atlColumn.atlColumnID) JOIN gibbonPerson ON (atlEntry.gibbonPersonIDStudent=gibbonPerson.gibbonPersonID) WHERE gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID1 AND atlEntry.gibbonPersonIDStudent=:gibbonPersonID2 AND gibbonSchoolYearID=:gibbonSchoolYearID AND completeDate<='".date('Y-m-d')."' AND gibbonCourseClass.reportable='Y' AND gibbonCourseClassPerson.reportable='Y' ORDER BY completeDate DESC, gibbonCourse.nameShort, gibbonCourseClass.nameShort"; - $resultATL = $connection2->prepare($sqlATL); - $resultATL->execute($dataATL); - } catch (PDOException $e) { - $output .= "
".$e->getMessage().'
'; - } + $atlEntryGateway = $container->get(ATLEntryGateway::class); + $criteria = $atlEntryGateway->newQueryCriteria(true) + ->sortBy('gibbonSchoolYear.sequenceNumber', 'DESC') + ->sortBy('completeDate', 'DESC') + ->sortBy(['courseName']) + ->fromPOST(); + + $atls = $atlEntryGateway->queryATLsByStudent($criteria, $gibbonPersonID); + + $gibbonSchoolYearFilter = array_reduce($atls->toArray(), function ($group, $atl) { + $group['gibbonSchoolYearID:' . $atl['gibbonSchoolYearID']] = __('School Year') . ': ' . $atl['yearName']; + return $group; + }, []); + + $table = DataTable::createPaginated('atlView', $criteria); + + $table->addMetaData('filterOptions', $gibbonSchoolYearFilter); + + $table->addColumn('yearName', __('School Year')) + ->sortable('gibbonSchoolYear.sequenceNumber'); - if ($resultATL->rowCount() > 0) { - $results = true; - $output .= '

'; - $output .= $rowYears['name']; - $output .= '

'; - $output .= ""; - $output .= ""; - $output .= "'; - $output .= ''; - $output .= "'; - $output .= ''; - - $count = 0; - while ($rowATL = $resultATL->fetch()) { - if ($count % 2 == 0) { - $rowNum = 'even'; - } else { - $rowNum = 'odd'; - } - ++$count; - - $output .= ""; - $output .= ''; - if ($rowATL['gibbonRubricID'] == '') { - $output .= "'; - } else { - $output .= "'; - } - - $output .= ''; - } - - $output .= '
"; - $output .= 'Assessment'; - $output .= '"; - $output .= __('Rubric'); - $output .= '
'; - $output .= "".$rowATL['course'].'
'.$rowATL['name'].'

'; - $output .= ""; - if ($rowATL['completeDate'] != '') { - $output .= 'Marked on '.dateConvertBack($guid, $rowATL['completeDate']).'
'; - } else { - $output .= 'Unmarked
'; - } - $output .= '

'; - $output .= '
"; - $output .= __('N/A'); - $output .= '"; - $output .= ""; - $output .= '
'; + $table->addColumn('courseName', __('Course')); + + $table->addColumn('assessment', __('Assessment')) + ->sortable('completeDate') + ->description(__('Marked on')) + ->format(function($atl) { + $output = ''; + + $output .= Format::tag($atl['ATLName'], '', $atl['ATLDescription']); + $output .= '
'; + if (empty($atl['completeDate'])) { + $output .= __('N/A'); + } else { + $output .= Format::small(Format::dateReadable($atl['completeDate'])); } - } - if ($results == false) { - $output .= "
"; - $output .= __('There are no records to display.'); - $output .= '
'; - } - } + return $output; + }); + + $table->addActionColumn() + ->addParam('gibbonCourseClassID') + ->addParam('atlColumnID') + ->addParam('gibbonRubricID') + ->addParam('gibbonPersonID', $gibbonPersonID) + ->format(function($atl, $actions) use ($session) { + $actions->addAction('enterData', __('View Rubric')) + ->addParam('type', 'effort') + ->modalWindow(1100, 500) + ->setURL('/modules/' . $session->get('module') . '/atl_view_rubric.php') + ->setIcon('markbook'); + }); + + + $output .= $table->render($atls); return $output; } -function sidebarExtra($guid, $connection2, $gibbonCourseClassID, $mode = 'manage') +function sidebarExtra($gibbonCourseClassID, $mode = 'manage') { $output = ''; @@ -124,15 +97,15 @@ function sidebarExtra($guid, $connection2, $gibbonCourseClassID, $mode = 'manage $selectCount = 0; - global $pdo; + global $pdo, $session; - $form = Form::create('classSelect', $_SESSION[$guid]['absoluteURL'].'/index.php', 'get'); + $form = Form::create('classSelect', $session->get('absoluteURL').'/index.php', 'get'); $form->setFactory(DatabaseFormFactory::create($pdo)); - $form->addHiddenValue('q', '/modules/'.$_SESSION[$guid]['module'].'/'.($mode == 'write'? 'atl_write.php' : 'atl_manage.php')); + $form->addHiddenValue('q', '/modules/'.$session->get('module').'/'.($mode == 'write'? 'atl_write.php' : 'atl_manage.php')); $form->setClass('smallIntBorder w-full'); $row = $form->addRow(); - $row->addSelectClass('gibbonCourseClassID', $_SESSION[$guid]['gibbonSchoolYearID'], $_SESSION[$guid]['gibbonPersonID']) + $row->addSelectClass('gibbonCourseClassID', $session->get('gibbonSchoolYearID'), $session->get('gibbonPersonID')) ->selected($gibbonCourseClassID) ->placeholder() ->setClass('fullWidth'); From 9d1d6a700c612f644065ac3073f90ff8e1a70910 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Sat, 9 Oct 2021 23:01:27 +1100 Subject: [PATCH 27/57] Added missing comma --- ATL/manifest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ATL/manifest.php b/ATL/manifest.php index b58d227..153e289 100644 --- a/ATL/manifest.php +++ b/ATL/manifest.php @@ -201,7 +201,7 @@ $hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Parental Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; $array = [ - 'sourceModuleName' => 'ATL', + 'sourceModuleName' => 'ATL' 'sourceModuleAction' => 'View ATLs_mine', 'sourceModuleInclude' => 'hook_studentDashboard_atlView.php' ]; From bce75a55571f5babad430c486ed69cc23e7fc8c3 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Sat, 9 Oct 2021 23:05:30 +1100 Subject: [PATCH 28/57] Changed alert to use Format, removed unused arguments from getATLRecord --- ATL/hook_parentalDashboard_atlView.php | 10 +++++----- ATL/hook_studentDashboard_atlView.php | 10 +++++----- ATL/hook_studentProfile_atlView.php | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ATL/hook_parentalDashboard_atlView.php b/ATL/hook_parentalDashboard_atlView.php index 2beed15..945b2f3 100644 --- a/ATL/hook_parentalDashboard_atlView.php +++ b/ATL/hook_parentalDashboard_atlView.php @@ -17,22 +17,22 @@ along with this program. If not, see . */ +use Gibbon\Services\Format; + global $page; $returnInt = null; -require_once './modules/ATL/moduleFunctions.php'; +require_once __DIR__ . '/moduleFunctions.php'; if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { //Acess denied - $returnInt .= "
"; - $returnInt .= 'You do not have access to this action.'; - $returnInt .= '
'; + $returnInt .= Format::alert(__('You do not have access to this action.')); } else { // Register scripts available to the core, but not included by default $page->scripts->add('chart'); - $returnInt .= getATLRecord($guid, $connection2, $gibbonPersonID); + $returnInt .= getATLRecord($gibbonPersonID); } return $returnInt; diff --git a/ATL/hook_studentDashboard_atlView.php b/ATL/hook_studentDashboard_atlView.php index ea1926b..a12067e 100644 --- a/ATL/hook_studentDashboard_atlView.php +++ b/ATL/hook_studentDashboard_atlView.php @@ -17,22 +17,22 @@ along with this program. If not, see . */ +use Gibbon\Services\Format; + global $page; $returnInt = null; -require_once './modules/ATL/moduleFunctions.php'; +require_once __DIR__ . '/moduleFunctions.php'; if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { //Acess denied - $returnInt .= "
"; - $returnInt .= 'You do not have access to this action.'; - $returnInt .= '
'; + $returnInt .= Format::alert(__('You do not have access to this action.')); } else { // Register scripts available to the core, but not included by default $page->scripts->add('chart'); - $returnInt .= getATLRecord($guid, $connection2, $session->get('gibbonPersonID')); + $returnInt .= getATLRecord($session->get('gibbonPersonID')); } return $returnInt; diff --git a/ATL/hook_studentProfile_atlView.php b/ATL/hook_studentProfile_atlView.php index ba3ab5e..1f811ac 100644 --- a/ATL/hook_studentProfile_atlView.php +++ b/ATL/hook_studentProfile_atlView.php @@ -17,17 +17,17 @@ along with this program. If not, see . */ +use Gibbon\Services\Format; + //Module includes -require_once './modules/ATL/moduleFunctions.php'; +require_once __DIR__ . '/moduleFunctions.php'; if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { //Acess denied - echo "
"; - echo 'You do not have access to this action.'; - echo '
'; + echo Format::alert(__('You do not have access to this action.')); } else { // Register scripts available to the core, but not included by default $page->scripts->add('chart'); - echo getATLRecord($guid, $connection2, $gibbonPersonID); + echo getATLRecord($gibbonPersonID); } From 623f60e779dcf38818312166cb40a98799ce6270 Mon Sep 17 00:00:00 2001 From: Ray Clark Date: Sat, 9 Oct 2021 23:06:29 +1100 Subject: [PATCH 29/57] Removed unused arguments from sidebarExtra --- ATL/atl_manage_delete.php | 4 ++-- ATL/atl_manage_edit.php | 4 ++-- ATL/atl_write_data.php | 8 +++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ATL/atl_manage_delete.php b/ATL/atl_manage_delete.php index 5d1e44a..682788f 100644 --- a/ATL/atl_manage_delete.php +++ b/ATL/atl_manage_delete.php @@ -21,7 +21,7 @@ use Gibbon\Module\ATL\Domain\ATLColumnGateway; //Module includes -include './modules/'.$session->get('module').'/moduleFunctions.php'; +require_once __DIR__ . '/moduleFunctions.php'; if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_delete.php') == false) { //Acess denied @@ -68,6 +68,6 @@ } //Print sidebar - $session->set('sidebarExtra', sidebarExtra($guid, $connection2, $gibbonCourseClassID, 'manage', 'Manage ATLs_all')); + $session->set('sidebarExtra', sidebarExtra($gibbonCourseClassID, 'manage')); } } diff --git a/ATL/atl_manage_edit.php b/ATL/atl_manage_edit.php index 25aeba4..d2914f2 100644 --- a/ATL/atl_manage_edit.php +++ b/ATL/atl_manage_edit.php @@ -21,7 +21,7 @@ use Gibbon\Module\ATL\Domain\ATLColumnGateway; //Module includes -include './modules/'.$session->get('module').'/moduleFunctions.php'; +require_once __DIR__ . '/moduleFunctions.php'; if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_manage_edit.php') == false) { //Acess denied @@ -117,6 +117,6 @@ } //Print sidebar - $session->set('sidebarExtra', sidebarExtra($guid, $connection2, $gibbonCourseClassID, 'manage')); + $session->set('sidebarExtra', sidebarExtra($gibbonCourseClassID, 'manage')); } } diff --git a/ATL/atl_write_data.php b/ATL/atl_write_data.php index 983c8fb..a19a030 100644 --- a/ATL/atl_write_data.php +++ b/ATL/atl_write_data.php @@ -22,7 +22,7 @@ use Gibbon\Services\Format; //Module includes -include './modules/'.$session->get('module').'/moduleFunctions.php'; +require_once __DIR__ . '/moduleFunctions.php'; echo "'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_data.php') == false) { - //Acess denied - $page->addError(__('You do not have access to this action.')); -} else { - // Register scripts available to the core, but not included by default - $page->scripts->add('chart'); - - $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); - if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; - } else { - //Check if school year specified - $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; - $atlColumnID = $_GET['atlColumnID']; - if ($gibbonCourseClassID == '' or $atlColumnID == '') { - echo "
"; - echo __('You have not specified one or more required parameters.'); - echo '
'; - } else { - try { - if ($highestAction == 'Write ATLs_all') { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID); - $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) WHERE gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' "; - } else { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'gibbonPersonID' => $session->get('gibbonPersonID'), 'gibbonCourseClassID2' => $gibbonCourseClassID, 'gibbonPersonID2' => $session->get('gibbonPersonID'), 'gibbonSchoolYearID' => $session->get('gibbonSchoolYearID')); - $sql = "(SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonPersonID=:gibbonPersonID AND (role='Teacher' OR role='Assistant') AND gibbonCourseClass.reportable='Y') - UNION - (SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourseClass JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) JOIN gibbonDepartment ON (gibbonCourse.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) JOIN gibbonDepartmentStaff ON (gibbonDepartmentStaff.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID2 AND gibbonDepartmentStaff.gibbonPersonID=:gibbonPersonID2 AND gibbonDepartmentStaff.role='Coordinator' AND gibbonCourse.gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourseClass.reportable='Y')"; - } - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; - } else { - try { - $data2 = array('atlColumnID' => $atlColumnID); - $sql2 = 'SELECT * FROM atlColumn WHERE atlColumnID=:atlColumnID'; - $result2 = $connection2->prepare($sql2); - $result2->execute($data2); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result2->rowCount() != 1) { - echo "
"; - echo 'The selected column does not exist, or you do not have access to it.'; - echo '
'; - } else { - //Let's go! - $class = $result->fetch(); - $values = $result2->fetch(); - - - $page->breadcrumbs - ->add(__('Write {courseClass} ATLs', ['courseClass' => $class['course'].'.'.$class['class']]), 'atl_write.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) - ->add(__('Enter ATL Results')); - - if (isset($_GET['return'])) { - returnProcess($guid, $_GET['return'], null, null); - } - - if ($values['forStudents'] == 'Y') { - $page->addError(__('You cannot mark this ATL')); - } else { - $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'atlColumnID' => $atlColumnID, 'today' => date('Y-m-d')); - $sql = "SELECT gibbonPerson.gibbonPersonID, gibbonPerson.title, gibbonPerson.surname, gibbonPerson.preferredName, gibbonPerson.dateStart, atlEntry.* - FROM gibbonCourseClassPerson - JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) - LEFT JOIN atlEntry ON (atlEntry.gibbonPersonIDStudent=gibbonPerson.gibbonPersonID AND atlEntry.atlColumnID=:atlColumnID) - WHERE gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID - AND gibbonCourseClassPerson.reportable='Y' AND gibbonCourseClassPerson.role='Student' - AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) - ORDER BY gibbonPerson.surname, gibbonPerson.preferredName"; - $result = $pdo->executeQuery($data, $sql); - $students = ($result->rowCount() > 0)? $result->fetchAll() : array(); - - $form = Form::create('internalAssessment', $session->get('absoluteURL').'/modules/'.$session->get('module').'/atl_write_dataProcess.php?gibbonCourseClassID='.$gibbonCourseClassID.'&atlColumnID='.$atlColumnID.'&address='.$session->get('address')); - $form->setFactory(DatabaseFormFactory::create($pdo)); - $form->addHiddenValue('address', $session->get('address')); - - $form->addRow()->addHeading(__('Assessment Details')); - - if (count($students) == 0) { - $form->addRow()->addHeading(__('Students')); - $form->addRow()->addAlert(__('There are no records to display.'), 'error'); - } else { - $table = $form->addRow()->addTable()->setClass('smallIntBorder fullWidth colorOddEven noMargin noPadding noBorder'); - - $completeText = !empty($values['completeDate'])? __('Marked on').' '.dateConvertBack($guid, $values['completeDate']) : __('Unmarked'); - - $header = $table->addHeaderRow(); - $header->addTableCell(__('Student'))->rowSpan(2); - $header->addTableCell($values['name']) - ->setTitle($values['description']) - ->append('
'.$completeText.'') - ->setClass('textCenter') - ->colSpan(3); - - $header = $table->addHeaderRow(); - $header->addContent(__('Complete'))->setClass('textCenter'); - $header->addContent(__('Rubric'))->setClass('textCenter'); - } - - foreach ($students as $index => $student) { - $count = $index+1; - $row = $table->addRow(); - - $row->addWebLink(Format::name('', $student['preferredName'], $student['surname'], 'Student', true)) - ->setURL($session->get('absoluteURL').'/index.php?q=/modules/Students/student_view_details.php') - ->addParam('gibbonPersonID', $student['gibbonPersonID']) - ->addParam('subpage', 'Markbook') - ->wrap('', '') - ->prepend($count.') '); - - $row->addCheckbox('complete'.$count)->setValue('Y')->checked($student['complete'])->setClass('textCenter'); - - $row->addWebLink('') - ->setURL($session->get('absoluteURL').'/fullscreen.php?q=/modules/'.$session->get('module').'/atl_write_rubric.php') - ->setClass('thickbox textCenter') - ->addParam('gibbonRubricID', $values['gibbonRubricID']) - ->addParam('gibbonCourseClassID', $gibbonCourseClassID) - ->addParam('gibbonPersonID', $student['gibbonPersonID']) - ->addParam('atlColumnID', $atlColumnID) - ->addParam('type', 'effort') - ->addParam('width', '1100') - ->addParam('height', '550'); - - $form->addHiddenValue($count.'-gibbonPersonID', $student['gibbonPersonID']); - } - - $form->addHiddenValue('count', $count); - - $form->addRow()->addHeading(__('Assessment Complete?')); - - $row = $form->addRow(); - $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); - $row->addDate('completeDate'); - - $row = $form->addRow(); - $row->addSubmit(); - - $form->loadAllValuesFrom($values); - - echo $form->getOutput(); - } - } - } - } - - //Print sidebar - $session->set('sidebarExtra', sidebarExtra($gibbonCourseClassID, 'write')); - } -} +. +*/ + +use Gibbon\Forms\DatabaseFormFactory; +use Gibbon\Forms\Form; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Services\Format; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +echo "'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_data.php') == false) { + //Acess denied + $page->addError(__('You do not have access to this action.')); +} else { + // Register scripts available to the core, but not included by default + $page->scripts->add('chart'); + + $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); + if ($highestAction == false) { + $page->addError(__('The highest grouped action cannot be determined.')); + } else { + //Check if school year specified + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + if ($gibbonCourseClassID == '' || $atlColumnID == '') { + $page->addError(__('You have not specified one or more required parameters.')); + } else { + try { + if ($highestAction == 'Write ATLs_all') { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sql = "SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) WHERE gibbonCourseClassID=:gibbonCourseClassID AND gibbonCourseClass.reportable='Y' "; + } else { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'gibbonPersonID' => $session->get('gibbonPersonID'), 'gibbonCourseClassID2' => $gibbonCourseClassID, 'gibbonPersonID2' => $session->get('gibbonPersonID'), 'gibbonSchoolYearID' => $session->get('gibbonSchoolYearID')); + $sql = "(SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID AND gibbonPersonID=:gibbonPersonID AND (role='Teacher' OR role='Assistant') AND gibbonCourseClass.reportable='Y') + UNION + (SELECT gibbonCourse.nameShort AS course, gibbonCourse.name AS courseName, gibbonCourseClass.nameShort AS class, gibbonYearGroupIDList FROM gibbonCourseClass JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) JOIN gibbonDepartment ON (gibbonCourse.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) JOIN gibbonDepartmentStaff ON (gibbonDepartmentStaff.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) WHERE gibbonCourseClass.gibbonCourseClassID=:gibbonCourseClassID2 AND gibbonDepartmentStaff.gibbonPersonID=:gibbonPersonID2 AND gibbonDepartmentStaff.role='Coordinator' AND gibbonCourse.gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourseClass.reportable='Y')"; + } + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + } + + if ($result->rowCount() != 1) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlColumn = $atlColumnGateway->getByID($atlColumnID); + + if (empty($atlColumn)) { + $page->addError(__('The selected column does not exist, or you do not have access to it.')); + } else { + //Let's go! + $class = $result->fetch(); + + $page->breadcrumbs + ->add(__('Write {courseClass} ATLs', ['courseClass' => $class['course'].'.'.$class['class']]), 'atl_write.php', ['gibbonCourseClassID' => $gibbonCourseClassID]) + ->add(__('Enter ATL Results')); + + if ($atlColumn['forStudents'] == 'Y') { + $page->addError(__('You cannot mark this ATL')); + } else { + $data = array('gibbonCourseClassID' => $gibbonCourseClassID, 'atlColumnID' => $atlColumnID, 'today' => date('Y-m-d')); + $sql = "SELECT gibbonPerson.gibbonPersonID, gibbonPerson.title, gibbonPerson.surname, gibbonPerson.preferredName, gibbonPerson.dateStart, atlEntry.* + FROM gibbonCourseClassPerson + JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) + LEFT JOIN atlEntry ON (atlEntry.gibbonPersonIDStudent=gibbonPerson.gibbonPersonID AND atlEntry.atlColumnID=:atlColumnID) + WHERE gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID + AND gibbonCourseClassPerson.reportable='Y' AND gibbonCourseClassPerson.role='Student' + AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) + ORDER BY gibbonPerson.surname, gibbonPerson.preferredName"; + $result = $connection2->prepare($sql); + $result->execute($data); + $students = ($result->rowCount() > 0) ? $result->fetchAll() : []; + + $form = Form::create('internalAssessment', $session->get('absoluteURL').'/modules/'.$session->get('module').'/atl_write_dataProcess.php?gibbonCourseClassID='.$gibbonCourseClassID.'&atlColumnID='.$atlColumnID); + $form->setFactory(DatabaseFormFactory::create($pdo)); + $form->addHiddenValue('address', $session->get('address')); + + $form->addRow()->addHeading(__('Assessment Details')); + if (empty($students)) { + $form->addRow()->addHeading(__('Students')); + $form->addRow()->addAlert(__('There are no records to display.'), 'error'); + } else { + $table = $form->addRow()->addTable()->setClass('smallIntBorder fullWidth colorOddEven noMargin noPadding noBorder'); + + $completeText = !empty($atlColumn['completeDate']) ? __('Marked on') . ' ' . Format::date($atlColumn['completeDate']) : __('Unmarked'); + + $header = $table->addHeaderRow(); + $header->addTableCell(__('Student'))->rowSpan(2); + $header->addTableCell($atlColumn['name']) + ->setTitle($atlColumn['description']) + ->append('
'.$completeText.'') + ->setClass('textCenter') + ->colSpan(3); + + $header = $table->addHeaderRow(); + $header->addContent(__('Complete'))->setClass('textCenter'); + $header->addContent(__('Rubric'))->setClass('textCenter'); + } + + foreach ($students as $index => $student) { + $count = $index+1; + $row = $table->addRow(); + + $row->addWebLink(Format::name('', $student['preferredName'], $student['surname'], 'Student', true)) + ->setURL($session->get('absoluteURL').'/index.php?q=/modules/Students/student_view_details.php') + ->addParam('gibbonPersonID', $student['gibbonPersonID']) + ->addParam('subpage', 'Markbook') + ->wrap('', '') + ->prepend($count.') '); + + $row->addCheckbox('complete'.$count)->setValue('Y')->checked($student['complete'])->setClass('textCenter'); + + $row->addWebLink('') + ->setURL($session->get('absoluteURL').'/fullscreen.php?q=/modules/'.$session->get('module').'/atl_write_rubric.php') + ->setClass('thickbox textCenter') + ->addParam('gibbonRubricID', $atlColumn['gibbonRubricID']) + ->addParam('gibbonCourseClassID', $gibbonCourseClassID) + ->addParam('gibbonPersonID', $student['gibbonPersonID']) + ->addParam('atlColumnID', $atlColumnID) + ->addParam('type', 'effort') + ->addParam('width', '1100') + ->addParam('height', '550'); + + $form->addHiddenValue($count.'-gibbonPersonID', $student['gibbonPersonID']); + } + + $form->addHiddenValue('count', $count); + + $form->addRow()->addHeading(__('Assessment Complete?')); + + $row = $form->addRow(); + $row->addLabel('completeDate', __('Go Live Date'))->prepend('1. ')->append('
'.__('2. Column is hidden until date is reached.')); + $row->addDate('completeDate'); + + $row = $form->addRow(); + $row->addSubmit(); + + $form->loadAllValuesFrom($atlColumn); + + echo $form->getOutput(); + } + } + } + } + + //Print sidebar + $session->set('sidebarExtra', sidebarExtra($gibbonCourseClassID, 'write')); + } +} \ No newline at end of file diff --git a/ATL/atl_write_dataProcess.php b/ATL/atl_write_dataProcess.php index 2506d01..855ef25 100644 --- a/ATL/atl_write_dataProcess.php +++ b/ATL/atl_write_dataProcess.php @@ -1,107 +1,108 @@ -. -*/ - -use Gibbon\Module\ATL\Domain\ATLColumnGateway; -use Gibbon\Module\ATL\Domain\ATLEntryGateway; - -include '../../gibbon.php'; - -$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_data.php') == false) { - //Fail 0 - $URL .= 'atl_manage.php&return=error0'; - header("Location: {$URL}"); -} else { - $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; - $atlColumnID = $_GET['atlColumnID'] ?? ''; - - $atlColumnGateway = $container->get(ATLColumnGateway::class); - $atlColumn = $atlColumnGateway->getByID($atlColumnID); - - if (empty($atlColumn)) { - //Fail 2 - $URL .= 'atl_manage.php&return=error2'; - header("Location: {$URL}"); - exit(); - } else { - $URL .= "atl_write_data.php&atlColumnID=$atlColumnID&gibbonCourseClassID=$gibbonCourseClassID"; - $name = $atlColumn['name']; - $count = $_POST['count']; - $partialFail = false; - - if ($atlColumn['forStudents'] == 'Y') { - $URL .= '&return=error1'; - header("Location: {$URL}"); - exit(); - } - - $atlEntryGateway = $container->get(ATLEntryGateway::class); - - for ($i = 1; $i <= $count; ++$i) { - $gibbonPersonIDStudent = $_POST["$i-gibbonPersonID"]; - //Complete - $completeValue = $_POST["complete$i"] ?? 'N'; - $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); - - $data = [ - 'atlColumnID' => $atlColumnID, - 'gibbonPersonIDStudent' => $gibbonPersonIDStudent, - 'complete' => $completeValue, - 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit, - ]; - - $atlEntry = $atlEntryGateway->selectBy(['atlColumnID' => $atlColumnID, 'gibbonPersonIDStudent' => $gibbonPersonIDStudent]); - - if ($atlEntry->isNotEmpty()) { - $atlEntry = $atlEntry->fetch(); - $partialFail |= !$atlEntryGateway->update($atlEntry['atlEntryID'], $data); - } else { - $partialFail |= !$atlEntryGateway->insert($data); - } - } - - //Update column - $completeDate = $_POST['completeDate']; - if (empty($completeDate)) { - $data = [ - 'completeDate' => null, - 'complete' => 'N' - ]; - } else { - $data = [ - 'completeDate' => dateConvert($guid, $completeDate), - 'complete' => 'Y' - ]; - } - - $partialFail |= !$atlColumnGateway->update($atlColumnID, $data); - - //Return! - if ($partialFail) { - //Fail 3 - $URL .= '&return=error3'; - } else { - //Success 0 - $URL .= '&return=success0'; - } - header("Location: {$URL}"); - exit(); - } -} +. +*/ + +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; +use Gibbon\Services\Format; + +include '../../gibbon.php'; + +$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_data.php') == false) { + //Fail 0 + $URL .= 'atl_manage.php&return=error0'; + header("Location: {$URL}"); +} else { + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlColumn = $atlColumnGateway->getByID($atlColumnID); + + if (empty($atlColumn)) { + //Fail 2 + $URL .= 'atl_manage.php&return=error2'; + header("Location: {$URL}"); + exit(); + } else { + $URL .= "atl_write_data.php&atlColumnID=$atlColumnID&gibbonCourseClassID=$gibbonCourseClassID"; + $name = $atlColumn['name']; + $count = $_POST['count']; + $partialFail = false; + + if ($atlColumn['forStudents'] == 'Y') { + $URL .= '&return=error1'; + header("Location: {$URL}"); + exit(); + } + + $atlEntryGateway = $container->get(ATLEntryGateway::class); + + for ($i = 1; $i <= $count; ++$i) { + $gibbonPersonIDStudent = $_POST["$i-gibbonPersonID"]; + //Complete + $completeValue = $_POST["complete$i"] ?? 'N'; + $gibbonPersonIDLastEdit = $session->get('gibbonPersonID'); + + $data = [ + 'atlColumnID' => $atlColumnID, + 'gibbonPersonIDStudent' => $gibbonPersonIDStudent, + 'complete' => $completeValue, + 'gibbonPersonIDLastEdit' => $gibbonPersonIDLastEdit, + ]; + + $atlEntry = $atlEntryGateway->selectBy(['atlColumnID' => $atlColumnID, 'gibbonPersonIDStudent' => $gibbonPersonIDStudent]); + + if ($atlEntry->isNotEmpty()) { + $atlEntry = $atlEntry->fetch(); + $partialFail |= !$atlEntryGateway->update($atlEntry['atlEntryID'], $data); + } else { + $partialFail |= !$atlEntryGateway->insert($data); + } + } + + //Update column + $completeDate = $_POST['completeDate']; + if (empty($completeDate)) { + $data = [ + 'completeDate' => null, + 'complete' => 'N' + ]; + } else { + $data = [ + 'completeDate' => Format::dateConvert($completeDate), + 'complete' => 'Y' + ]; + } + + $partialFail |= !$atlColumnGateway->update($atlColumnID, $data); + + //Return! + if ($partialFail) { + //Fail 3 + $URL .= '&return=error3'; + } else { + //Success 0 + $URL .= '&return=success0'; + } + header("Location: {$URL}"); + exit(); + } +} diff --git a/ATL/atl_write_rubric.php b/ATL/atl_write_rubric.php index f9c720d..864f740 100644 --- a/ATL/atl_write_rubric.php +++ b/ATL/atl_write_rubric.php @@ -1,109 +1,144 @@ -. -*/ - -use Gibbon\Domain\Rubrics\RubricGateway; -use Gibbon\Domain\Timetable\CourseEnrolmentGateway; -use Gibbon\Domain\Timetable\CourseGateway; -use Gibbon\Domain\User\RoleGateway; -use Gibbon\Module\ATL\Domain\ATLColumnGateway; -use Gibbon\Module\ATL\Domain\ATLEntryGateway; -use Gibbon\Services\Format; - -//Rubric includes -include './modules/Rubrics/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write.php') == false - && isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { - //Acess denied - $page->addError(__('Your request failed because you do not have access to this action.')); -} else { - //Proceed! - //Check if school year specified - $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; - $atlColumnID = $_GET['atlColumnID'] ?? ''; - $gibbonPersonID = $_GET['gibbonPersonID'] ?? ''; - $gibbonRubricID = $_GET['gibbonRubricID'] ?? ''; - if (empty($gibbonCourseClassID) || empty($atlColumnID) || empty($gibbonPersonID) || empty($gibbonRubricID)) { - $page->addError(__('You have not specified one or more required parameters.')); - } else { - $type = $_GET['type'] ?? ''; - $contextDBTableGibbonRubricIDField = ''; - if ($type == 'attainment') { - $contextDBTableGibbonRubricIDField = 'gibbonRubricIDAttainment'; - } else { - $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; - } - - $allowed = false; - $roleGateway = $container->get(RoleGateway::class); - $roleCategory = $roleGateway->getByID($session->get('gibbonRoleIDPrimary'))['category'] ?? ''; - - if ($roleCategory == 'Staff') { - $courseGateway = $container->get(CourseGateway::class); - $result = $courseGateway->getCourseClassByID($gibbonCourseClassID); - $allowed = !empty($result); - } elseif ($roleCategory == 'Student' || $roleCategory == 'Parent') { - $courseEnrolmentGateway = $container->get(CourseEnrolmentGateway::class); - $result = $courseEnrolmentGateway->selectBy(['gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID, 'role' => 'Student']); - $allowed = $result->isNotEmpty(); - } - - if (!$allowed) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - $atlColumnGateway = $container->get(ATLColumnGateway::class); - if (!$atlColumnGateway->exists($atlColumnID)) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - $rubricGateway = $container->get(RubricGateway::class); - $rubric = $rubricGateway->getByID($gibbonRubricID); - - if (empty($rubric)) { - $page->addError(__('The specified record does not exist.')); - } else { - try { - $data4 = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); - $sql4 = "SELECT DISTINCT surname, preferredName, gibbonPerson.gibbonPersonID, image_240 FROM gibbonPerson JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE gibbonPerson.gibbonPersonID=:gibbonPersonID AND gibbonCourseClassID=:gibbonCourseClassID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND (role='Student' OR role='Student - Left')"; - $result4 = $connection2->prepare($sql4); - $result4->execute($data4); - } catch (PDOException $e) { - echo "
".$e->getMessage().'
'; - } - - if ($result4->rowCount() != 1) { - $page->addError(__('The selected record does not exist, or you do not have access to it.')); - } else { - //Let's go! - $row4 = $result4->fetch(); - - echo "

"; - echo $rubric['name'].'
'; - echo "".Format::name('', $row4['preferredName'], $row4['surname'], 'Student', true).''; - echo '

'; - - echo Format::photo($row4['image_240'], 75, 'inline-block align-top mt-1'); - - $mark = ($_GET['mark'] ?? '') !== 'FALSE'; - echo rubricView($guid, $connection2, $gibbonRubricID, $mark, $row4['gibbonPersonID'], 'atlColumn', 'atlColumnID', $atlColumnID, $contextDBTableGibbonRubricIDField, 'name', $gibbonPersonID == $session->get('gibbonPersonID') ? '' : 'completeDate'); - } - } - } - } - } -} +. +*/ + +use Gibbon\Domain\Rubrics\RubricGateway; +use Gibbon\Domain\Timetable\CourseEnrolmentGateway; +use Gibbon\Domain\Timetable\CourseGateway; +use Gibbon\Domain\User\RoleGateway; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; +use Gibbon\Services\Format; + +//Rubric includes +include './modules/Rubrics/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write.php') == false + && isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { + //Acess denied + $page->addError(__('Your request failed because you do not have access to this action.')); +} else { + //Proceed! + //Check if school year specified + $gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? ''; + $atlColumnID = $_GET['atlColumnID'] ?? ''; + $gibbonPersonID = $_GET['gibbonPersonID'] ?? ''; + $gibbonRubricID = $_GET['gibbonRubricID'] ?? ''; + if (empty($gibbonCourseClassID) || empty($atlColumnID) || empty($gibbonPersonID) || empty($gibbonRubricID)) { + $page->addError(__('You have not specified one or more required parameters.')); + } else { + $type = $_GET['type'] ?? ''; + $contextDBTableGibbonRubricIDField = ''; + if ($type == 'attainment') { + $contextDBTableGibbonRubricIDField = 'gibbonRubricIDAttainment'; + } else { + $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; + } + + $allowed = false; + $roleGateway = $container->get(RoleGateway::class); + $roleCategory = $roleGateway->getByID($session->get('gibbonRoleIDPrimary'))['category'] ?? ''; + + if ($roleCategory == 'Staff') { + $courseGateway = $container->get(CourseGateway::class); + $result = $courseGateway->getCourseClassByID($gibbonCourseClassID); + $allowed = !empty($result); + } elseif ($roleCategory == 'Student' || $roleCategory == 'Parent') { + $courseEnrolmentGateway = $container->get(CourseEnrolmentGateway::class); + $result = $courseEnrolmentGateway->selectBy(['gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID, 'role' => 'Student']); + $allowed = $result->isNotEmpty(); + + } + + if (!$allowed) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + if (!$atlColumnGateway->exists($atlColumnID)) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + $rubricGateway = $container->get(RubricGateway::class); + $rubric = $rubricGateway->getByID($gibbonRubricID); + + if (empty($rubric)) { + $page->addError(__('The specified record does not exist.')); + } else { + try { + $data4 = array('gibbonPersonID' => $gibbonPersonID, 'gibbonCourseClassID' => $gibbonCourseClassID); + $sql4 = "SELECT DISTINCT surname, preferredName, gibbonPerson.gibbonPersonID, image_240 FROM gibbonPerson JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE gibbonPerson.gibbonPersonID=:gibbonPersonID AND gibbonCourseClassID=:gibbonCourseClassID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND (role='Student' OR role='Student - Left')"; + $result4 = $connection2->prepare($sql4); + $result4->execute($data4); + } catch (PDOException $e) { + echo "
".$e->getMessage().'
'; + } + + if ($result4->rowCount() != 1) { + $page->addError(__('The selected record does not exist, or you do not have access to it.')); + } else { + //Let's go! + $row4 = $result4->fetch(); + + echo "

"; + echo $rubric['name'].'
'; + echo "".Format::name('', $row4['preferredName'], $row4['surname'], 'Student', true).''; + echo '

'; + + echo Format::photo($row4['image_240'], 75, 'inline-block align-top mt-1'); + + $mark = ($_GET['mark'] ?? '') !== 'FALSE'; + echo rubricView($guid, $connection2, $gibbonRubricID, $mark, $row4['gibbonPersonID'], 'atlColumn', 'atlColumnID', $atlColumnID, $contextDBTableGibbonRubricIDField, 'name', $gibbonPersonID == $session->get('gibbonPersonID') ? '' : 'completeDate'); + + if ($mark && $gibbonPersonID !== $session->get('gibbonPersonID')) { + try { + $dataStudents = array('gibbonCourseClassID' => $gibbonCourseClassID); + $sqlStudents = "SELECT gibbonPerson.gibbonPersonID, dateStart FROM gibbonCourseClassPerson JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE role='Student' AND gibbonCourseClassID=:gibbonCourseClassID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') AND gibbonCourseClassPerson.reportable='Y' ORDER BY surname, preferredName"; + $resultStudents = $connection2->prepare($sqlStudents); + $resultStudents->execute($dataStudents); + } catch (PDOException $e) { + } + + $prev = ''; + $next = ''; + while (($rowStudent = $resultStudents->fetch()) != null) { + if ($rowStudent['gibbonPersonID'] == $gibbonPersonID) { + $nextRowStudent = $resultStudents->fetch(); + if ($nextRowStudent != null) { + $next = $nextRowStudent['gibbonPersonID']; + } + break; + } else { + $prev = $rowStudent['gibbonPersonID']; + } + } + + echo ''; + } + } + } + } + } + } +} diff --git a/ATL/atl_write_student.php b/ATL/atl_write_student.php index e4d8aba..22b28c4 100644 --- a/ATL/atl_write_student.php +++ b/ATL/atl_write_student.php @@ -1,69 +1,69 @@ -. -*/ - -use Gibbon\Module\ATL\Domain\ATLColumnGateway; -use Gibbon\Services\Format; -use Gibbon\Tables\DataTable; - -//Module includes -require_once __DIR__ . '/moduleFunctions.php'; - -$page->breadcrumbs->add('Fill ATLs'); -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { - //Acess denied - $page->addError(__('Your request failed because you do not have access to this action.')); -} else { - $page->scripts->add('chart'); - $atlColumnGateway = $container->get(ATLColumnGateway::class); - $criteria = $atlColumnGateway->newQueryCriteria() - ->sortBy('completeDate'); - - $gibbonPersonID = $session->get('gibbonPersonID'); - $atlColumns = $atlColumnGateway->queryATLColumnsByStudent($criteria, $session->get('gibbonSchoolYearID'), $gibbonPersonID, 'N'); - - $table = DataTable::createPaginated('studentATLs', $criteria); - - $table->addColumn('course', __('Class')) - ->format(Format::using('courseClassName', ['course', 'class'])); - - $table->addColumn('name', __('ATL')); - - $table->addColumn('completeDate', __('Due Date')) - ->format(Format::using('date', ['completeDate'])); - - $table->addActionColumn() - ->addParam('gibbonRubricID') - ->addParam('gibbonCourseClassID') - ->addParam('gibbonPersonID', $gibbonPersonID) - ->addParam('atlColumnID') - ->addParam('type', 'effort') - ->format(function ($column, $actions) { - $actions->addAction('data', __('Enter Data')) - ->setURL('/modules/ATL/atl_write_rubric.php') - ->setIcon('markbook') - ->modalWindow(1100, 550); - - $actions->addAction('complete', __('Complete')) - ->setURL('/modules/ATL/atl_write_student_complete.php') - ->setIcon('iconTick') - ->modalWindow(); - }); - - echo $table->render($atlColumns); +. +*/ + +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Services\Format; +use Gibbon\Tables\DataTable; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +$page->breadcrumbs->add('Fill ATLs'); +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { + //Acess denied + $page->addError(__('Your request failed because you do not have access to this action.')); +} else { + $page->scripts->add('chart'); + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $criteria = $atlColumnGateway->newQueryCriteria() + ->sortBy('completeDate'); + + $gibbonPersonID = $session->get('gibbonPersonID'); + $atlColumns = $atlColumnGateway->queryATLColumnsByStudent($criteria, $session->get('gibbonSchoolYearID'), $gibbonPersonID, 'N'); + + $table = DataTable::createPaginated('studentATLs', $criteria); + + $table->addColumn('course', __('Class')) + ->format(Format::using('courseClassName', ['course', 'class'])); + + $table->addColumn('name', __('ATL')); + + $table->addColumn('completeDate', __('Due Date')) + ->format(Format::using('date', ['completeDate'])); + + $table->addActionColumn() + ->addParam('gibbonRubricID') + ->addParam('gibbonCourseClassID') + ->addParam('gibbonPersonID', $gibbonPersonID) + ->addParam('atlColumnID') + ->addParam('type', 'effort') + ->format(function ($column, $actions) { + $actions->addAction('data', __('Enter Data')) + ->setURL('/modules/ATL/atl_write_rubric.php') + ->setIcon('markbook') + ->modalWindow(1100, 550); + + $actions->addAction('complete', __('Complete')) + ->setURL('/modules/ATL/atl_write_student_complete.php') + ->setIcon('iconTick') + ->modalWindow(); + }); + + echo $table->render($atlColumns); } \ No newline at end of file diff --git a/ATL/atl_write_student_complete.php b/ATL/atl_write_student_complete.php index 7acb07d..c3bede2 100644 --- a/ATL/atl_write_student_complete.php +++ b/ATL/atl_write_student_complete.php @@ -1,62 +1,62 @@ -. -*/ - -use Gibbon\Forms\Form; -use Gibbon\Module\ATL\Domain\ATLColumnGateway; -use Gibbon\Module\ATL\Domain\ATLEntryGateway; - -//Module includes -require_once __DIR__ . '/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { - //Acess denied - $page->addError(__('Your request failed because you do not have access to this action.')); -} else { - $atlColumnGateway = $container->get(ATLColumnGateway::class); - $atlEntryGateway = $container->get(ATLEntryGateway::class); - - $atlColumnID = $_GET['atlColumnID'] ?? ''; - $gibbonPersonID = $session->get('gibbonPersonID'); - $gibbonSchoolYearID = $session->get('gibbonSchoolYearID'); - - //Check if atl column is for student - if ($atlColumnGateway->isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID)) { - //Check if student has already completed atl - $atlEntry = $atlEntryGateway->selectBy(['gibbonPersonIDStudent' => $gibbonPersonID, 'atlColumnID' => $atlColumnID, 'complete' => 'Y']); - if ($atlEntry->isNotEmpty()) { - $page->addError(__('You have already completed this ATL.')); - } else { - $form = Form::create('ATL', $session->get('absoluteURL').'/modules/ATL/atl_write_student_completeProcess.php'); - $form->addHiddenValue('address', $session->get('address')); - $form->addHiddenValue('atlColumnID', $atlColumnID); - - $row = $form->addRow(); - $col = $row->addColumn(); - $col->addContent(__('Are you sure you want to mark this ATL as complete?'))->wrap('', ''); - $col->addContent(__('Once marked as complete, you will not be able to edit your ATL.')) - ->wrap('', ''); - - $form->addRow()->addConfirmSubmit(); - - echo $form->getOutput(); - } - } else { - $page->addError(__('Your request failed because you do not have access to this action.')); - } +. +*/ + +use Gibbon\Forms\Form; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { + //Acess denied + $page->addError(__('Your request failed because you do not have access to this action.')); +} else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlEntryGateway = $container->get(ATLEntryGateway::class); + + $atlColumnID = $_GET['atlColumnID'] ?? ''; + $gibbonPersonID = $session->get('gibbonPersonID'); + $gibbonSchoolYearID = $session->get('gibbonSchoolYearID'); + + //Check if atl column is for student + if ($atlColumnGateway->isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID)) { + //Check if student has already completed atl + $atlEntry = $atlEntryGateway->selectBy(['gibbonPersonIDStudent' => $gibbonPersonID, 'atlColumnID' => $atlColumnID, 'complete' => 'Y']); + if ($atlEntry->isNotEmpty()) { + $page->addError(__('You have already completed this ATL.')); + } else { + $form = Form::create('ATL', $session->get('absoluteURL').'/modules/ATL/atl_write_student_completeProcess.php'); + $form->addHiddenValue('address', $session->get('address')); + $form->addHiddenValue('atlColumnID', $atlColumnID); + + $row = $form->addRow(); + $col = $row->addColumn(); + $col->addContent(__('Are you sure you want to mark this ATL as complete?'))->wrap('', ''); + $col->addContent(__('Once marked as complete, you will not be able to edit your ATL.')) + ->wrap('', ''); + + $form->addRow()->addConfirmSubmit(); + + echo $form->getOutput(); + } + } else { + $page->addError(__('Your request failed because you do not have access to this action.')); + } } \ No newline at end of file diff --git a/ATL/atl_write_student_completeProcess.php b/ATL/atl_write_student_completeProcess.php index ddfc9f9..e021803 100644 --- a/ATL/atl_write_student_completeProcess.php +++ b/ATL/atl_write_student_completeProcess.php @@ -1,74 +1,74 @@ -. -*/ - -include '../../gibbon.php'; - -use Gibbon\Module\ATL\Domain\ATLColumnGateway; -use Gibbon\Module\ATL\Domain\ATLEntryGateway; - -$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/atl_write_student.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { - //Fail 0 - $URL .= '&return=error0'; - header("Location: {$URL}"); - exit(); -} else { - $atlColumnGateway = $container->get(ATLColumnGateway::class); - $atlEntryGateway = $container->get(ATLEntryGateway::class); - - $atlColumnID = $_POST['atlColumnID'] ?? ''; - $gibbonPersonID = $session->get('gibbonPersonID'); - $gibbonSchoolYearID = $session->get('gibbonSchoolYearID'); - - //Check if atl column is for student - if ($atlColumnGateway->isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID)) { - $data = [ - 'atlColumnID' => $atlColumnID, - 'gibbonPersonIDStudent' => $gibbonPersonID, - 'complete' => 'Y', - 'gibbonPersonIDLastEdit' => $gibbonPersonID - ]; - - $atlEntry = $atlEntryGateway->selectBy(['gibbonPersonIDStudent' => $gibbonPersonID, 'atlColumnID' => $atlColumnID]); - $atlEntry = $atlEntry->isNotEmpty() ? $atlEntry->fetch() : []; - - if (empty($atlEntry)) { - if (!$atlEntryGateway->insert($data)) { - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } - } else { - if (!$atlEntryGateway->update($atlEntry['atlEntryID'], $data)) { - $URL .= '&return=error2'; - header("Location: {$URL}"); - exit(); - } - } - - $URL .= '&return=success0'; - header("Location: {$URL}"); - exit(); - } else { - $URL .= '&return=error0'; - header("Location: {$URL}"); - exit(); - } -} +. +*/ + +include '../../gibbon.php'; + +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; + +$URL = $session->get('absoluteURL').'/index.php?q=/modules/ATL/atl_write_student.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_write_student.php') == false) { + //Fail 0 + $URL .= '&return=error0'; + header("Location: {$URL}"); + exit(); +} else { + $atlColumnGateway = $container->get(ATLColumnGateway::class); + $atlEntryGateway = $container->get(ATLEntryGateway::class); + + $atlColumnID = $_POST['atlColumnID'] ?? ''; + $gibbonPersonID = $session->get('gibbonPersonID'); + $gibbonSchoolYearID = $session->get('gibbonSchoolYearID'); + + //Check if atl column is for student + if ($atlColumnGateway->isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID)) { + $data = [ + 'atlColumnID' => $atlColumnID, + 'gibbonPersonIDStudent' => $gibbonPersonID, + 'complete' => 'Y', + 'gibbonPersonIDLastEdit' => $gibbonPersonID + ]; + + $atlEntry = $atlEntryGateway->selectBy(['gibbonPersonIDStudent' => $gibbonPersonID, 'atlColumnID' => $atlColumnID]); + $atlEntry = $atlEntry->isNotEmpty() ? $atlEntry->fetch() : []; + + if (empty($atlEntry)) { + if (!$atlEntryGateway->insert($data)) { + $URL .= '&return=error2'; + header("Location: {$URL}"); + exit(); + } + } else { + if (!$atlEntryGateway->update($atlEntry['atlEntryID'], $data)) { + $URL .= '&return=error2'; + header("Location: {$URL}"); + exit(); + } + } + + $URL .= '&return=success0'; + header("Location: {$URL}"); + exit(); + } else { + $URL .= '&return=error0'; + header("Location: {$URL}"); + exit(); + } +} diff --git a/ATL/cli/goLiveNotifications.php b/ATL/cli/goLiveNotifications.php index 91ff255..aaf911c 100644 --- a/ATL/cli/goLiveNotifications.php +++ b/ATL/cli/goLiveNotifications.php @@ -1,79 +1,78 @@ -. -*/ - -//USAGE -//Ideally this script should be run shortly after midnight, to alert users to columns that have just gone live - -require getcwd().'/../../../gibbon.php'; - -getSystemSettings($guid, $connection2); - -setCurrentSchoolYear($guid, $connection2); - -//Set up for i18n via gettext -if (isset($_SESSION[$guid]['i18n']['code'])) { if ($_SESSION[$guid]['i18n']['code'] != null) { - putenv('LC_ALL='.$_SESSION[$guid]['i18n']['code']); - setlocale(LC_ALL, $_SESSION[$guid]['i18n']['code']); - bindtextdomain('gibbon', getcwd().'/../i18n'); - textdomain('gibbon'); - } -} - - -//Check for CLI, so this cannot be run through browser -if (php_sapi_name() != 'cli') { - echo __('This script cannot be run from a browser, only via CLI.')."\n\n"; -} else { - //SCAN THROUGH ALL ATLS GOING LIVE TODAY - try { - $data = array('completeDate' => date('Y-m-d')); - $sql = 'SELECT atlColumn.*, gibbonCourseClass.nameShort AS class, gibbonCourse.nameShort AS course FROM atlColumn JOIN gibbonCourseClass ON (atlColumn.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) WHERE completeDate=:completeDate'; - $result = $connection2->prepare($sql); - $result->execute($data); - } catch (PDOException $e) { - } - - while ($row = $result->fetch()) { - try { - $dataPerson = array('gibbonCourseClassID' => $row['gibbonCourseClassID'], 'today' => date('Y-m-d')); - $sqlPerson = "SELECT gibbonCourseClassPerson.* - FROM gibbonCourseClassPerson - JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) - JOIN gibbonCourseClass ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) - WHERE (role='Teacher' OR role='Assistant' OR role='Student') - AND gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID - AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) - AND gibbonCourseClass.reportable='Y' - AND gibbonCourseClassPerson.reportable='Y'"; - $resultPerson = $connection2->prepare($sqlPerson); - $resultPerson->execute($dataPerson); - } catch (PDOException $e) { - } - - while ($rowPerson = $resultPerson->fetch()) { - if ($rowPerson['role'] == 'Teacher' || $rowPerson['role'] == 'Assistant') { - $notificationText = sprintf(__('Your ATL column for class %1$s has gone live today.'), $row['course'].'.'.$row['class']); - setNotification($connection2, $guid, $rowPerson['gibbonPersonID'], $notificationText, 'ATL', '/index.php?q=/modules/ATL/atl_write.php&gibbonCourseClassID='.$row['gibbonCourseClassID']); - } else { - $notificationText = sprintf(__('You have new ATL assessment feedback for class %1$s.'), $row['course'].'.'.$row['class']); - setNotification($connection2, $guid, $rowPerson['gibbonPersonID'], $notificationText, 'ATL', '/index.php?q=/modules/ATL/atl_view.php'); - } - } - } -} +. +*/ + +//USAGE +//Ideally this script should be run shortly after midnight, to alert users to columns that have just gone live + +require getcwd().'/../../../gibbon.php'; + +getSystemSettings($guid, $connection2); + +setCurrentSchoolYear($guid, $connection2); + +//Set up for i18n via gettext +if (!empty($session->get('i18n')['code'])) { + putenv('LC_ALL='.$session->get('i18n')['code']); + setlocale(LC_ALL, $session->get('i18n')['code']); + bindtextdomain('gibbon', getcwd().'/../i18n'); + textdomain('gibbon'); +} + + +//Check for CLI, so this cannot be run through browser +if (php_sapi_name() != 'cli') { + echo __('This script cannot be run from a browser, only via CLI.')."\n\n"; +} else { + //SCAN THROUGH ALL ATLS GOING LIVE TODAY + $data = array('completeDate' => date('Y-m-d')); + $sql = 'SELECT atlColumn.*, gibbonCourseClass.nameShort AS class, gibbonCourse.nameShort AS course FROM atlColumn JOIN gibbonCourseClass ON (atlColumn.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) WHERE completeDate=:completeDate'; + $result = $connection2->prepare($sql); + $result->execute($data); + + while ($row = $result->fetch()) { + $dataPerson = array('gibbonCourseClassID' => $row['gibbonCourseClassID'], 'today' => date('Y-m-d')); + $sqlPerson = "SELECT gibbonCourseClassPerson.* + FROM gibbonCourseClassPerson + JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) + JOIN gibbonCourseClass ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) + WHERE (role='Teacher' OR role='Assistant' OR role='Student') + AND gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID + AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<=:today) AND (dateEnd IS NULL OR dateEnd>=:today) + AND gibbonCourseClass.reportable='Y' + AND gibbonCourseClassPerson.reportable='Y'"; + $resultPerson = $connection2->prepare($sqlPerson); + $resultPerson->execute($dataPerson); + + $notificationGateway = new \Gibbon\Domain\System\NotificationGateway($pdo); + + while ($rowPerson = $resultPerson->fetch()) { + if ($rowPerson['role'] == 'Teacher' || $rowPerson['role'] == 'Assistant') { + $notificationSender = new \Gibbon\Comms\NotificationSender($notificationGateway, $session); + $notificationText = sprintf(__('Your ATL column for class %1$s has gone live today.'), $row['course'].'.'.$row['class']); + $notificationSender->addNotification($rowPerson['gibbonPersonID'], $notificationText, 'ATL', '/index.php?q=/modules/ATL/atl_write.php&gibbonCourseClassID='.$row['gibbonCourseClassID']); + $notificationSender->sendNotifications(); + } else { + $notificationSender = new \Gibbon\Comms\NotificationSender($notificationGateway, $session); + $notificationText = sprintf(__('You have new ATL assessment feedback for class %1$s.'), $row['course'].'.'.$row['class']); + $notificationSender->addNotification($rowPerson['gibbonPersonID'], $notificationText, 'ATL', '/index.php?q=/modules/ATL/atl_view.php'); + $notificationSender->sendNotifications(); + } + } + } +} diff --git a/ATL/hook_parentalDashboard_atlView.php b/ATL/hook_parentalDashboard_atlView.php index b20df6c..c36d86b 100644 --- a/ATL/hook_parentalDashboard_atlView.php +++ b/ATL/hook_parentalDashboard_atlView.php @@ -1,40 +1,42 @@ -. -*/ - -use Gibbon\Services\Format; - -global $page, $container; - -$returnInt = null; - -require_once __DIR__ . '/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { - //Acess denied - $returnInt .= Format::alert(__('You do not have access to this action.')); -} else { - // Register scripts available to the core, but not included by default - $page->scripts->add('chart'); - //TODO: This is a hack to make sure that the ATLEntryGateway is loaded and should be fixed properly somehow. - $container->get('autoloader')->addPsr4('Gibbon\\Module\\ATL\\', $session->get('absolutePath') . '/modules/ATL/src'); - - $returnInt .= getATLRecord($gibbonPersonID); -} - -return $returnInt; +. +*/ + +use Gibbon\Services\Format; + +global $page, $container; + +$returnInt = null; + +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { + //Acess denied + $returnInt .= Format::alert(__('You do not have access to this action.')); +} else { + // Register scripts available to the core, but not included by default + $page->scripts->add('chart'); + //TODO: This is a hack to make sure that the ATLEntryGateway is loaded and should be fixed properly somehow. + $container->get('autoloader')->addPsr4('Gibbon\\Module\\ATL\\', $session->get('absolutePath') . '/modules/ATL/src'); + + $returnInt .= visualiseATL($container, $gibbonPersonID); + + $returnInt .= getATLRecord($gibbonPersonID); +} + +return $returnInt; diff --git a/ATL/hook_studentDashboard_atlView.php b/ATL/hook_studentDashboard_atlView.php index 36693c6..e30f0e4 100644 --- a/ATL/hook_studentDashboard_atlView.php +++ b/ATL/hook_studentDashboard_atlView.php @@ -1,40 +1,42 @@ -. -*/ - -use Gibbon\Services\Format; - -global $page, $container; - -$returnInt = null; - -require_once __DIR__ . '/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { - //Acess denied - $returnInt .= Format::alert(__('You do not have access to this action.')); -} else { - // Register scripts available to the core, but not included by default - $page->scripts->add('chart'); - //TODO: This is a hack to make sure that the ATLEntryGateway is loaded and should be fixed properly somehow. - $container->get('autoloader')->addPsr4('Gibbon\\Module\\ATL\\', $session->get('absolutePath') . '/modules/ATL/src'); - - $returnInt .= getATLRecord($session->get('gibbonPersonID')); -} - -return $returnInt; +. +*/ + +use Gibbon\Services\Format; + +global $page, $container; + +$returnInt = null; + +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { + //Acess denied + $returnInt .= Format::alert(__('You do not have access to this action.')); +} else { + // Register scripts available to the core, but not included by default + $page->scripts->add('chart'); + //TODO: This is a hack to make sure that the ATLEntryGateway is loaded and should be fixed properly somehow. + $container->get('autoloader')->addPsr4('Gibbon\\Module\\ATL\\', $session->get('absolutePath') . '/modules/ATL/src'); + + $returnInt .= visualiseATL($container, $session->get('gibbonPersonID')); + + $returnInt .= getATLRecord($session->get('gibbonPersonID')); +} + +return $returnInt; diff --git a/ATL/hook_studentProfile_atlView.php b/ATL/hook_studentProfile_atlView.php index 45f50f6..c165b85 100644 --- a/ATL/hook_studentProfile_atlView.php +++ b/ATL/hook_studentProfile_atlView.php @@ -1,37 +1,43 @@ -. -*/ - -use Gibbon\Services\Format; - -global $page, $container; - -//Module includes -require_once __DIR__ . '/moduleFunctions.php'; - -if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { - //Acess denied - echo Format::alert(__('You do not have access to this action.')); -} else { - // Register scripts available to the core, but not included by default - $page->scripts->add('chart'); - //TODO: This is a hack to make sure that the ATLEntryGateway is loaded and should be fixed properly somehow. - $container->get('autoloader')->addPsr4('Gibbon\\Module\\ATL\\', $session->get('absolutePath') . '/modules/ATL/src'); - - echo getATLRecord($gibbonPersonID); -} +. +*/ + +use Gibbon\Services\Format; + +global $page, $container; + +use Gibbon\Module\Rubrics\Visualise; +use Gibbon\Domain\Rubrics\RubricGateway; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; + +//Module includes +require_once __DIR__ . '/moduleFunctions.php'; + +if (isActionAccessible($guid, $connection2, '/modules/ATL/atl_view.php') == false) { + //Acess denied + echo Format::alert(__('You do not have access to this action.')); +} else { + // Register scripts available to the core, but not included by default + $page->scripts->add('chart'); + //TODO: This is a hack to make sure that the ATLEntryGateway is loaded and should be fixed properly somehow. + $container->get('autoloader')->addPsr4('Gibbon\\Module\\ATL\\', $session->get('absolutePath') . '/modules/ATL/src'); + + echo visualiseATL($container, $gibbonPersonID); + + echo getATLRecord($gibbonPersonID); +} diff --git a/ATL/manifest.php b/ATL/manifest.php index 1b31934..95f9656 100644 --- a/ATL/manifest.php +++ b/ATL/manifest.php @@ -1,208 +1,208 @@ -. -*/ - -//This file describes the module, including database tables - -//Basic variables -$name = 'ATL'; -$description = 'The ATL module allows schools to run a program of Approaches To Learning assessments, based on a rubric.'; -$entryURL = 'atl_write.php'; -$type = 'Additional'; -$category = 'Assess'; -$version = '1.6.00'; -$author = 'Ross Parker'; -$url = 'http://rossparker.org'; - -//Module tables -$moduleTables[] = "CREATE TABLE `atlColumn` ( - `atlColumnID` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT, - `gibbonCourseClassID` int(8) unsigned zerofill NOT NULL, - `name` varchar(20) NOT NULL, - `description` text NOT NULL, - `gibbonRubricID` int(8) unsigned zerofill DEFAULT NULL, - `complete` enum('N','Y') NOT NULL, - `completeDate` date DEFAULT NULL, - `forStudents` enum('Y','N') NOT NULL DEFAULT 'N', - `gibbonPersonIDCreator` int(10) unsigned zerofill NOT NULL, - `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, - PRIMARY KEY (`atlColumnID`), - KEY `gibbonCourseClassID` (`gibbonCourseClassID`), - KEY `gibbonRubricID` (`gibbonRubricID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - -$moduleTables[] = "CREATE TABLE `atlEntry` ( - `atlEntryID` int(12) unsigned zerofill NOT NULL AUTO_INCREMENT, - `atlColumnID` int(10) unsigned zerofill NOT NULL, - `gibbonPersonIDStudent` int(10) unsigned zerofill NOT NULL, - `complete` enum('Y','N') NOT NULL DEFAULT 'N', - `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, - PRIMARY KEY (`atlEntryID`), - KEY (`atlColumnID`), - KEY (`gibbonPersonIDStudent`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - -//Action rows -$actionRows[] = [ - 'name' => 'Manage ATLs_all', - 'precedence' => '0', - 'category' => 'Manage & Assess', - 'description' => 'Allows privileged users to create and manage ATL columns.', - 'URLList' => 'atl_manage.php, atl_manage_add.php, atl_manage_edit.php, atl_manage_delete.php', - 'entryURL' => 'atl_manage.php', - 'defaultPermissionAdmin' => 'Y', - 'defaultPermissionTeacher' => 'N', - 'defaultPermissionStudent' => 'N', - 'defaultPermissionParent' => 'N', - 'defaultPermissionSupport' => 'N', - 'categoryPermissionStaff' => 'Y', - 'categoryPermissionStudent' => 'N', - 'categoryPermissionParent' => 'N', - 'categoryPermissionOther' => 'N' -]; - -$actionRows[] = [ - 'name' => 'Write ATLs_myClasses', - 'precedence' => '0', - 'category' => 'Manage & Assess', - 'description' => 'Allows teachers to enter ATL assessment data to columns in their classes.', - 'URLList' => 'atl_write.php, atl_write_data.php', - 'entryURL' => 'atl_write.php', - 'defaultPermissionAdmin' => 'N', - 'defaultPermissionTeacher' => 'Y', - 'defaultPermissionStudent' => 'N', - 'defaultPermissionParent' => 'N', - 'defaultPermissionSupport' => 'N', - 'categoryPermissionStaff' => 'Y', - 'categoryPermissionStudent' => 'N', - 'categoryPermissionParent' => 'N', - 'categoryPermissionOther' => 'N' -]; - -$actionRows[] = [ - 'name' => 'Write ATLs_all', - 'precedence' => '1', - 'category' => 'Manage & Assess', - 'description' => 'Allows privileged users to enter ATL assessment data to columns in all classes.', - 'URLList' => 'atl_write.php, atl_write_data.php', - 'entryURL' => 'atl_write.php', - 'defaultPermissionAdmin' => 'Y', - 'defaultPermissionTeacher' => 'N', - 'defaultPermissionStudent' => 'N', - 'defaultPermissionParent' => 'N', - 'defaultPermissionSupport' => 'N', - 'categoryPermissionStaff' => 'Y', - 'categoryPermissionStudent' => 'N', - 'categoryPermissionParent' => 'N', - 'categoryPermissionOther' => 'N' -]; - -$actionRows[] = [ - 'name' => 'View ATLs_mine', - 'precedence' => '0', - 'category' => 'View', - 'description' => 'Allows students to view their own ATL results.', - 'URLList' => 'atl_view.php', - 'entryURL' => 'atl_view.php', - 'defaultPermissionAdmin' => 'N', - 'defaultPermissionTeacher' => 'N', - 'defaultPermissionStudent' => 'Y', - 'defaultPermissionParent' => 'N', - 'defaultPermissionSupport' => 'N', - 'categoryPermissionStaff' => 'N', - 'categoryPermissionStudent' => 'Y', - 'categoryPermissionParent' => 'N', - 'categoryPermissionOther' => 'N' -]; - -$actionRows[] = [ - 'name' => 'View ATLs_myChildrens', - 'precedence' => '1', - 'category' => 'View', - 'description' => "Allows parents to view their childrens' ATL results.", - 'URLList' => 'atl_view.php', - 'entryURL' => 'atl_view.php', - 'defaultPermissionAdmin' => 'N', - 'defaultPermissionTeacher' => 'N', - 'defaultPermissionStudent' => 'N', - 'defaultPermissionParent' => 'Y', - 'defaultPermissionSupport' => 'N', - 'categoryPermissionStaff' => 'N', - 'categoryPermissionStudent' => 'N', - 'categoryPermissionParent' => 'Y', - 'categoryPermissionOther' => 'N' -]; - -$actionRows[] = [ - 'name' => 'View ATLs_all', - 'precedence' => '2', - 'category' => 'View', - 'description' => 'Allows staff to see ATL results for all children.', - 'URLList' => 'atl_view.php', - 'entryURL' => 'atl_view.php', - 'defaultPermissionAdmin' => 'Y', - 'defaultPermissionTeacher' => 'Y', - 'defaultPermissionStudent' => 'N', - 'defaultPermissionParent' => 'N', - 'defaultPermissionSupport' => 'N', - 'categoryPermissionStaff' => 'Y', - 'categoryPermissionStudent' => 'N', - 'categoryPermissionParent' => 'N', - 'categoryPermissionOther' => 'N' -]; - -$actionRows[] = [ - 'name' => 'Fill ATLs', - 'precedence' => '0', - 'category' => 'View', - 'description' => 'Allows students to enter ATL assessment data to columns in their classes.', - 'URLList' => 'atl_write_student.php', - 'entryURL' => 'atl_write_student.php', - 'defaultPermissionAdmin' => 'N', - 'defaultPermissionTeacher' => 'N', - 'defaultPermissionStudent' => 'Y', - 'defaultPermissionParent' => 'N', - 'defaultPermissionSupport' => 'N', - 'categoryPermissionStaff' => 'N', - 'categoryPermissionStudent' => 'Y', - 'categoryPermissionParent' => 'N', - 'categoryPermissionOther' => 'N' -]; - -//Hooks -$array = [ - 'sourceModuleName' => 'ATL', - 'sourceModuleAction' => 'View ATLs_all', - 'sourceModuleInclude' => 'hook_studentProfile_atlView.php' -]; -$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Profile', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; - -$array = [ - 'sourceModuleName' => 'ATL', - 'sourceModuleAction' => 'View ATLs_myChildrens', - 'sourceModuleInclude' => 'hook_parentalDashboard_atlView.php' -]; -$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Parental Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; - -$array = [ - 'sourceModuleName' => 'ATL' - 'sourceModuleAction' => 'View ATLs_mine', - 'sourceModuleInclude' => 'hook_studentDashboard_atlView.php' -]; -$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; - +. +*/ + +//This file describes the module, including database tables + +//Basic variables +$name = 'ATL'; +$description = 'The ATL module allows schools to run a program of Approaches To Learning assessments, based on a rubric.'; +$entryURL = 'atl_write.php'; +$type = 'Additional'; +$category = 'Assess'; +$version = '1.6.00'; +$author = 'Ross Parker'; +$url = 'http://rossparker.org'; + +//Module tables +$moduleTables[] = "CREATE TABLE `atlColumn` ( + `atlColumnID` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT, + `gibbonCourseClassID` int(8) unsigned zerofill NOT NULL, + `name` varchar(20) NOT NULL, + `description` text NOT NULL, + `gibbonRubricID` int(8) unsigned zerofill DEFAULT NULL, + `complete` enum('N','Y') NOT NULL, + `completeDate` date DEFAULT NULL, + `forStudents` enum('Y','N') NOT NULL DEFAULT 'N', + `gibbonPersonIDCreator` int(10) unsigned zerofill NOT NULL, + `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, + PRIMARY KEY (`atlColumnID`), + KEY `gibbonCourseClassID` (`gibbonCourseClassID`), + KEY `gibbonRubricID` (`gibbonRubricID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; + +$moduleTables[] = "CREATE TABLE `atlEntry` ( + `atlEntryID` int(12) unsigned zerofill NOT NULL AUTO_INCREMENT, + `atlColumnID` int(10) unsigned zerofill NOT NULL, + `gibbonPersonIDStudent` int(10) unsigned zerofill NOT NULL, + `complete` enum('Y','N') NOT NULL DEFAULT 'N', + `gibbonPersonIDLastEdit` int(10) unsigned zerofill NOT NULL, + PRIMARY KEY (`atlEntryID`), + KEY (`atlColumnID`), + KEY (`gibbonPersonIDStudent`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; + +//Action rows +$actionRows[] = [ + 'name' => 'Manage ATLs_all', + 'precedence' => '0', + 'category' => 'Manage & Assess', + 'description' => 'Allows privileged users to create and manage ATL columns.', + 'URLList' => 'atl_manage.php, atl_manage_add.php, atl_manage_edit.php, atl_manage_delete.php', + 'entryURL' => 'atl_manage.php', + 'defaultPermissionAdmin' => 'Y', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'Write ATLs_myClasses', + 'precedence' => '0', + 'category' => 'Manage & Assess', + 'description' => 'Allows teachers to enter ATL assessment data to columns in their classes.', + 'URLList' => 'atl_write.php, atl_write_data.php', + 'entryURL' => 'atl_write.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'Y', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'Write ATLs_all', + 'precedence' => '1', + 'category' => 'Manage & Assess', + 'description' => 'Allows privileged users to enter ATL assessment data to columns in all classes.', + 'URLList' => 'atl_write.php, atl_write_data.php', + 'entryURL' => 'atl_write.php', + 'defaultPermissionAdmin' => 'Y', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'View ATLs_mine', + 'precedence' => '0', + 'category' => 'View', + 'description' => 'Allows students to view their own ATL results.', + 'URLList' => 'atl_view.php', + 'entryURL' => 'atl_view.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'Y', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'N', + 'categoryPermissionStudent' => 'Y', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'View ATLs_myChildrens', + 'precedence' => '1', + 'category' => 'View', + 'description' => "Allows parents to view their childrens' ATL results.", + 'URLList' => 'atl_view.php', + 'entryURL' => 'atl_view.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'Y', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'N', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'Y', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'View ATLs_all', + 'precedence' => '2', + 'category' => 'View', + 'description' => 'Allows staff to see ATL results for all children.', + 'URLList' => 'atl_view.php', + 'entryURL' => 'atl_view.php', + 'defaultPermissionAdmin' => 'Y', + 'defaultPermissionTeacher' => 'Y', + 'defaultPermissionStudent' => 'N', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'Y', + 'categoryPermissionStudent' => 'N', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +$actionRows[] = [ + 'name' => 'Fill ATLs', + 'precedence' => '0', + 'category' => 'View', + 'description' => 'Allows students to enter ATL assessment data to columns in their classes.', + 'URLList' => 'atl_write_student.php', + 'entryURL' => 'atl_write_student.php', + 'defaultPermissionAdmin' => 'N', + 'defaultPermissionTeacher' => 'N', + 'defaultPermissionStudent' => 'Y', + 'defaultPermissionParent' => 'N', + 'defaultPermissionSupport' => 'N', + 'categoryPermissionStaff' => 'N', + 'categoryPermissionStudent' => 'Y', + 'categoryPermissionParent' => 'N', + 'categoryPermissionOther' => 'N' +]; + +//Hooks +$array = [ + 'sourceModuleName' => 'ATL', + 'sourceModuleAction' => 'View ATLs_all', + 'sourceModuleInclude' => 'hook_studentProfile_atlView.php' +]; +$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Profile', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; + +$array = [ + 'sourceModuleName' => 'ATL', + 'sourceModuleAction' => 'View ATLs_myChildrens', + 'sourceModuleInclude' => 'hook_parentalDashboard_atlView.php' +]; +$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Parental Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; + +$array = [ + 'sourceModuleName' => 'ATL' + 'sourceModuleAction' => 'View ATLs_mine', + 'sourceModuleInclude' => 'hook_studentDashboard_atlView.php' +]; +$hooks[] = "INSERT INTO `gibbonHook` (`gibbonHookID`, `name`, `type`, `options`, gibbonModuleID) VALUES (NULL, 'ATL', 'Student Dashboard', '".serialize($array)."', (SELECT gibbonModuleID FROM gibbonModule WHERE name='$name'));"; + diff --git a/ATL/moduleFunctions.php b/ATL/moduleFunctions.php index 9d47821..cc448ac 100644 --- a/ATL/moduleFunctions.php +++ b/ATL/moduleFunctions.php @@ -1,118 +1,205 @@ -. -*/ - -use Gibbon\Forms\Form; -use Gibbon\Forms\DatabaseFormFactory; -use Gibbon\Module\ATL\Domain\ATLEntryGateway; -use Gibbon\Services\Format; -use Gibbon\Tables\DataTable; - -function getATLRecord($gibbonPersonID) -{ - global $container, $session; - $output = ''; - - $atlEntryGateway = $container->get(ATLEntryGateway::class); - $criteria = $atlEntryGateway->newQueryCriteria(true) - ->sortBy('gibbonSchoolYear.sequenceNumber', 'DESC') - ->sortBy('completeDate', 'DESC') - ->sortBy(['courseName']) - ->fromPOST(); - - $atls = $atlEntryGateway->queryATLsByStudent($criteria, $gibbonPersonID); - - $gibbonSchoolYearFilter = array_reduce($atls->toArray(), function ($group, $atl) { - $group['gibbonSchoolYearID:' . $atl['gibbonSchoolYearID']] = __('School Year') . ': ' . $atl['yearName']; - return $group; - }, []); - - $table = DataTable::createPaginated('atlView', $criteria); - - $table->addMetaData('filterOptions', $gibbonSchoolYearFilter); - - $table->addColumn('yearName', __('School Year')) - ->sortable('gibbonSchoolYear.sequenceNumber'); - - $table->addColumn('courseName', __('Course')); - - $table->addColumn('assessment', __('Assessment')) - ->sortable('completeDate') - ->description(__('Marked on')) - ->format(function($atl) { - $output = ''; - - $output .= Format::tag($atl['ATLName'], '', $atl['ATLDescription']); - $output .= '
'; - if (empty($atl['completeDate'])) { - $output .= __('N/A'); - } else { - $output .= Format::small(Format::dateReadable($atl['completeDate'])); - } - return $output; - }); - - $table->addActionColumn() - ->addParam('gibbonCourseClassID') - ->addParam('atlColumnID') - ->addParam('gibbonRubricID') - ->addParam('gibbonPersonID', $gibbonPersonID) - ->format(function($atl, $actions) use ($session) { - $actions->addAction('enterData', __('View Rubric')) - ->addParam('type', 'effort') - ->modalWindow(1100, 500) - ->setURL('/modules/' . $session->get('module') . '/atl_view_rubric.php') - ->setIcon('markbook'); - }); - - - $output .= $table->render($atls); - - return $output; -} - -function sidebarExtra($gibbonCourseClassID, $mode = 'manage') -{ - $output = ''; - - $output .= '
'; - $output .= '

'; - $output .= __('View Classes'); - $output .= '

'; - - $selectCount = 0; - - global $pdo, $session; - - $form = Form::create('classSelect', $session->get('absoluteURL').'/index.php', 'get'); - $form->setFactory(DatabaseFormFactory::create($pdo)); - $form->addHiddenValue('q', '/modules/'.$session->get('module').'/'.($mode == 'write'? 'atl_write.php' : 'atl_manage.php')); - $form->setClass('smallIntBorder w-full'); - - $row = $form->addRow(); - $row->addSelectClass('gibbonCourseClassID', $session->get('gibbonSchoolYearID'), $session->get('gibbonPersonID')) - ->selected($gibbonCourseClassID) - ->placeholder() - ->setClass('fullWidth'); - $row->addSubmit(__('Go')); - - $output .= $form->getOutput(); - $output .= '
'; - - return $output; -} +. +*/ + +use Gibbon\Contracts\Database\Connection; +use Gibbon\Contracts\Services\Session; +use Gibbon\Domain\Rubrics\RubricGateway; +use Gibbon\Forms\DatabaseFormFactory; +use Gibbon\Forms\Form; +use Gibbon\Module\ATL\Domain\ATLColumnGateway; +use Gibbon\Module\ATL\Domain\ATLEntryGateway; +use Gibbon\Module\Rubrics\Visualise; +use Gibbon\Services\Format; +use Gibbon\Tables\DataTable; + + +function getATLRecord($gibbonPersonID) +{ + global $container, $session; + + $output = ''; + + $atlEntryGateway = $container->get(ATLEntryGateway::class); + $criteria = $atlEntryGateway->newQueryCriteria(true) + ->sortBy('gibbonSchoolYear.sequenceNumber', 'DESC') + ->sortBy('completeDate', 'DESC') + ->sortBy(['courseName']) + ->fromPOST(); + + $atls = $atlEntryGateway->queryATLsByStudent($criteria, $gibbonPersonID); + + $gibbonSchoolYearFilter = array_reduce($atls->toArray(), function ($group, $atl) { + $group['gibbonSchoolYearID' . $atl['gibbonSchoolYearID']] = __('School Year') . ': ' . $atl['yearName']; + return $group; + }, []); + + $table = DataTable::createPaginated('atlView', $criteria); + + $table->addMetaData('filterOptions', $gibbonSchoolYearFilter); + + $table->addColumn('yearName', __('School Year')) + ->sortable('gibbonSchoolYear.sequenceNumber'); + + $table->addColumn('courseName', __('Course')); + + $table->addColumn('assessment', __('Assessment')) + ->sortable('completeDate') + ->description(__('Marked on')) + ->format(function($atl) { + $output = ''; + + $output .= Format::tag($atl['ATLName'], '', $atl['ATLDescription']); + $output .= '
'; + if (empty($atl['completeDate'])) { + $output .= __('N/A'); + } else { + $output .= Format::small(Format::dateReadable($atl['completeDate'])); + } + return $output; + }); + + $table->addActionColumn() + ->addParam('gibbonCourseClassID') + ->addParam('atlColumnID') + ->addParam('gibbonRubricID') + ->addParam('gibbonPersonID', $gibbonPersonID) + ->format(function($atl, $actions) use ($session) { + $actions->addAction('enterData', __('View Rubric')) + ->addParam('type', 'effort') + ->modalWindow(1100, 500) + ->setURL('/modules/ATL/atl_view_rubric.php') + ->setIcon('markbook'); + }); + + + $output .= $table->render($atls); + + return $output; +} + +function sidebarExtra($gibbonCourseClassID, $mode = 'manage') +{ + global $pdo, $session; + + $output = ''; + + $output .= '
'; + $output .= '

'; + $output .= __('View Classes'); + $output .= '

'; + + $selectCount = 0; + + $form = Form::create('classSelect', $session->get('absoluteURL').'/index.php', 'get'); + $form->setFactory(DatabaseFormFactory::create($pdo)); + $form->addHiddenValue('q', '/modules/'.$session->get('module').'/'.($mode == 'write'? 'atl_write.php' : 'atl_manage.php')); + $form->setClass('smallIntBorder w-full'); + + $row = $form->addRow(); + $row->addSelectClass('gibbonCourseClassID', $session->get('gibbonSchoolYearID'), $session->get('gibbonPersonID')) + ->selected($gibbonCourseClassID) + ->placeholder() + ->setClass('fullWidth'); + $row->addSubmit(__('Go')); + + $output .= $form->getOutput(); + $output .= '
'; + + return $output; +} + +function visualiseATL($container, $gibbonPersonID) { + $session = $container->get(Session::class); + $pdo = $container->get(Connection::class); + + require_once $session->get('absolutePath').'/modules/ATL/src/Domain/ATLColumnGateway.php'; + + // Display the visualization of all ATLs + $contextDBTable = 'atlColumn'; + $contextDBTableID = $gibbonPersonID; + $contextDBTableIDField = 'atlColumnID'; + $contextDBTableGibbonRubricIDField = 'gibbonRubricID'; + $contextDBTableNameField = 'name'; + $contextDBTableDateField = 'completeDate'; + + $rubricGateway = $container->get(RubricGateway::class); + $studentRubricInfo = $container->get(ATLColumnGateway::class)->getATLRubricByStudent($session->get('gibbonSchoolYearID'), $gibbonPersonID); + $gibbonRubricID = $studentRubricInfo['gibbonRubricID'] ?? ''; + $rubric = $rubricGateway->getByID($gibbonRubricID); + + if ($gibbonRubricID && $rubric) { + // Get rows, columns and cells + $rows = $rubricGateway->selectRowsByRubric($gibbonRubricID)->fetchAll(); + $columns = $rubricGateway->selectColumnsByRubric($gibbonRubricID)->fetchAll(); + $gradeScales = $rubricGateway->selectGradeScalesByRubric($gibbonRubricID)->fetchGroupedUnique(); + + if (empty($rows) or empty($columns)) { + $col->addAlert(__('The rubric is missing data and cannot be drawn.')); + } else { + $cells = []; + $resultCells = $rubricGateway->selectCellsByRubric($gibbonRubricID); + while ($rowCells = $resultCells->fetch()) { + $cells[$rowCells['gibbonRubricRowID']][$rowCells['gibbonRubricColumnID']] = $rowCells; + } + + // Get other uses of this rubric in this context, and store for use in visualisation + $contexts = []; + + $dataContext = array('gibbonPersonID' => $gibbonPersonID, 'gibbonSchoolYearID' => $session->get('gibbonSchoolYearID')); + $sqlContext = "SELECT gibbonRubricEntry.*, $contextDBTable.*, gibbonRubricEntry.*, gibbonRubricCell.*, gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class + FROM gibbonRubricEntry + JOIN $contextDBTable ON (gibbonRubricEntry.contextDBTableID=$contextDBTable.$contextDBTableIDField + AND gibbonRubricEntry.gibbonRubricID=$contextDBTable.$contextDBTableGibbonRubricIDField) + JOIN gibbonRubricCell ON (gibbonRubricEntry.gibbonRubricCellID=gibbonRubricCell.gibbonRubricCellID) + JOIN gibbonCourseClass ON ($contextDBTable.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) + JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) + WHERE contextDBTable='$contextDBTable' + AND gibbonRubricEntry.gibbonPersonID=:gibbonPersonID + AND gibbonSchoolYearID=:gibbonSchoolYearID + AND NOT $contextDBTableDateField IS NULL + ORDER BY $contextDBTableDateField DESC"; + $resultContext = $pdo->select($sqlContext, $dataContext); + + if ($resultContext->rowCount() > 0) { + while ($rowContext = $resultContext->fetch()) { + $context = $rowContext['course'].'.'.$rowContext['class'].' - '.$rowContext[$contextDBTableNameField].' ('.Format::date($rowContext[$contextDBTableDateField]).')'; + $cells[$rowContext['gibbonRubricRowID']][$rowContext['gibbonRubricColumnID']]['context'][] = $context; + + $contexts[] = [ + 'gibbonRubricEntry' => $rowContext['gibbonRubricEntry'], + 'gibbonRubricID' => $rowContext['gibbonRubricID'], + 'gibbonPersonID' => $rowContext['gibbonPersonID'], + 'gibbonRubricCellID' => $rowContext['gibbonRubricCellID'], + 'contextDBTable' => $rowContext['contextDBTable'], + 'contextDBTableID' => $rowContext['contextDBTableID'] + ]; + } + } + + } + + if (!empty($contexts) && !empty($columns) && !empty($rows) && !empty($cells)) { + require_once $session->get('absolutePath').'/modules/Rubrics/src/Visualise.php'; + $visualise = new Visualise($session->get('absoluteURL'), $container->get('page'), $gibbonPersonID.'All', $columns, $rows, $cells, $contexts); + return $visualise->renderVisualise(); + } + + return ''; + } +} diff --git a/ATL/src/Domain/ATLColumnGateway.php b/ATL/src/Domain/ATLColumnGateway.php index 2113388..e830758 100644 --- a/ATL/src/Domain/ATLColumnGateway.php +++ b/ATL/src/Domain/ATLColumnGateway.php @@ -1,96 +1,122 @@ -newQuery() - ->from($this->getTableName()) - ->cols([ - 'atlColumnID', 'gibbonCourseClassID', 'name', 'description', 'gibbonRubricID', 'complete', 'completeDate', 'gibbonPersonIDCreator', 'gibbonPersonIDLastEdit' - ]) - ->where('atlColumn.gibbonCourseClassID = :gibbonCourseClassID') - ->bindValue('gibbonCourseClassID', $gibbonCourseClassID); - - return $this->runQuery($query, $criteria); - } - - /** - * @param QueryCriteria $criteria - * @return DataSet - */ - public function queryATLColumnsByStudent(QueryCriteria $criteria, $gibbonSchoolYearID, $gibbonPersonID, $notComplete = false) - { - $query = $this - ->newQuery() - ->from($this->getTableName()) - ->cols([ - 'atlColumn.atlColumnID', 'atlColumn.gibbonRubricID', 'atlColumn.gibbonCourseClassID', 'atlEntry.atlEntryID', 'atlColumn.name', 'atlColumn.description', 'atlColumn.complete', 'atlColumn.completeDate', 'gibbonCourse.nameShort AS course', 'gibbonCourseClass.nameShort AS class', 'atlEntry.complete as entryComplete' - ]) - ->leftJoin('atlEntry', 'atlColumn.atlColumnID=atlEntry.atlColumnID AND atlEntry.gibbonPersonIDStudent = :gibbonPersonID') - ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') - ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID') - ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') - ->where("atlColumn.forStudents = 'Y'") - ->where('atlColumn.completeDate >= :today') - ->where('gibbonCourseClassPerson.gibbonPersonID = :gibbonPersonID') - ->where("gibbonCourseClassPerson.role = 'Student'") - ->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') - ->bindValue('today', date('Y-m-d')) - ->bindValue('gibbonPersonID', $gibbonPersonID) - ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); - - if ($notComplete) { - $query->where("(atlEntry.complete = 'N' OR atlEntry.complete IS NULL)"); - } - - return $this->runQuery($query, $criteria); - } - - public function isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID) { - $select = $this - ->newSelect() - ->from($this->getTableName()) - ->cols([ - 'atlColumn.atlColumnID' - ]) - ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') - ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID') - ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') - ->where('atlColumn.atlColumnID = :atlColumnID') - ->where("atlColumn.forStudents = 'Y'") - ->where('gibbonCourseClassPerson.gibbonPersonID = :gibbonPersonID') - ->where("gibbonCourseClassPerson.role = 'Student'") - ->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') - ->bindValue('atlColumnID', $atlColumnID) - ->bindValue('gibbonPersonID', $gibbonPersonID) - ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); - - $result = $this->runSelect($select); - return $result->isNotEmpty(); - } - -} +newQuery() + ->from($this->getTableName()) + ->cols([ + 'atlColumnID', 'gibbonCourseClassID', 'name', 'description', 'gibbonRubricID', 'complete', 'completeDate', 'gibbonPersonIDCreator', 'gibbonPersonIDLastEdit' + ]) + ->where('atlColumn.gibbonCourseClassID = :gibbonCourseClassID') + ->bindValue('gibbonCourseClassID', $gibbonCourseClassID); + + return $this->runQuery($query, $criteria); + } + + /** + * @param QueryCriteria $criteria + * @return DataSet + */ + public function queryATLColumnsByStudent(QueryCriteria $criteria, $gibbonSchoolYearID, $gibbonPersonID, $notComplete = false) + { + $query = $this + ->newQuery() + ->from($this->getTableName()) + ->cols([ + 'atlColumn.atlColumnID', 'atlColumn.gibbonRubricID', 'atlColumn.gibbonCourseClassID', 'atlEntry.atlEntryID', 'atlColumn.name', 'atlColumn.description', 'atlColumn.complete', 'atlColumn.completeDate', 'gibbonCourse.nameShort AS course', 'gibbonCourseClass.nameShort AS class', 'atlEntry.complete as entryComplete' + ]) + ->leftJoin('atlEntry', 'atlColumn.atlColumnID=atlEntry.atlColumnID AND atlEntry.gibbonPersonIDStudent = :gibbonPersonID') + ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') + ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID') + ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') + ->where("atlColumn.forStudents = 'Y'") + ->where('atlColumn.completeDate >= :today') + ->where('gibbonCourseClassPerson.gibbonPersonID = :gibbonPersonID') + ->where("gibbonCourseClassPerson.role = 'Student'") + ->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') + ->bindValue('today', date('Y-m-d')) + ->bindValue('gibbonPersonID', $gibbonPersonID) + ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); + + if ($notComplete) { + $query->where("(atlEntry.complete = 'N' OR atlEntry.complete IS NULL)"); + } + + return $this->runQuery($query, $criteria); + } + + public function getATLRubricByStudent($gibbonSchoolYearID, $gibbonPersonID) + { + $data = array('gibbonSchoolYearID' => $gibbonSchoolYearID, 'gibbonPersonID' => $gibbonPersonID); + $sql = "SELECT + gibbonPerson.gibbonPersonID, + surname, + preferredName, + gibbonCourseClass.gibbonCourseClassID, + gibbonRubricID + FROM gibbonPerson + JOIN gibbonStudentEnrolment ON (gibbonPerson.gibbonPersonID=gibbonStudentEnrolment.gibbonPersonID) + JOIN gibbonFormGroup ON (gibbonStudentEnrolment.gibbonFormGroupID=gibbonFormGroup.gibbonFormGroupID) + JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID) + JOIN gibbonCourseClass ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) + JOIN gibbonCourse ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourse.gibbonSchoolYearID=gibbonStudentEnrolment.gibbonSchoolYearID) + JOIN atlColumn ON (atlColumn.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) + WHERE status='Full' + AND gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID + AND gibbonPerson.gibbonPersonID=:gibbonPersonID + AND gibbonCourseClassPerson.role='Student' + ORDER BY surname, preferredName + LIMIT 0, 1"; + + return $this->db()->selectOne($sql, $data); + } + + public function isForStudent($atlColumnID, $gibbonPersonID, $gibbonSchoolYearID) { + $select = $this + ->newSelect() + ->from($this->getTableName()) + ->cols([ + 'atlColumn.atlColumnID' + ]) + ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') + ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID') + ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') + ->where('atlColumn.atlColumnID = :atlColumnID') + ->where("atlColumn.forStudents = 'Y'") + ->where('gibbonCourseClassPerson.gibbonPersonID = :gibbonPersonID') + ->where("gibbonCourseClassPerson.role = 'Student'") + ->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') + ->bindValue('atlColumnID', $atlColumnID) + ->bindValue('gibbonPersonID', $gibbonPersonID) + ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); + + $result = $this->runSelect($select); + return $result->isNotEmpty(); + } + +} diff --git a/ATL/src/Domain/ATLEntryGateway.php b/ATL/src/Domain/ATLEntryGateway.php index 687ce49..533440c 100644 --- a/ATL/src/Domain/ATLEntryGateway.php +++ b/ATL/src/Domain/ATLEntryGateway.php @@ -1,73 +1,73 @@ -newQuery() - ->from($this->getTableName()) - ->cols([ - 'gibbonSchoolYear.name as yearName', 'gibbonCourse.gibbonSchoolYearID', 'gibbonCourse.name as courseName', 'atlColumn.name as ATLName', 'atlColumn.description as ATLDescription', 'atlColumn.completeDate', 'atlColumn.gibbonRubricID', 'atlColumn.gibbonCourseClassID', 'atlColumn.atlColumnID' - ]) - ->leftJoin('atlColumn', 'atlEntry.atlColumnID=atlColumn.atlColumnID') - ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') - ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID AND atlEntry.gibbonPersonIDStudent = gibbonCourseClassPerson.gibbonPersonID') - ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') - ->leftJoin('gibbonSchoolYear', 'gibbonCourse.gibbonSchoolYearID = gibbonSchoolYear.gibbonSchoolYearID') - ->where('atlEntry.gibbonPersonIDStudent = :gibbonPersonID') - ->where('completeDate <= :today') - ->where("gibbonCourseClass.reportable = 'Y'") - ->where("gibbonCourseClassPerson.reportable = 'Y'") - ->bindValue('gibbonPersonID', $gibbonPersonID) - ->bindValue('today', date('Y-m-d')); - - $criteria->addFilterRules([ - 'gibbonSchoolYearID' => function($query, $gibbonSchoolYearID) { - return $query->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') - ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); - } - ]); - - return $this->runQuery($query, $criteria); - } - - public function createATLEntries($atlColumnID, $gibbonCourseClassID, $gibbonPersonID) { - $data = ['atlColumnID' => $atlColumnID, 'gibbonCourseClassID' => $gibbonCourseClassID, 'gibbonPersonID' => $gibbonPersonID, 'today' => date('Y-m-d')]; - $sql = "INSERT INTO atlEntry (atlColumnID, gibbonPersonIDStudent, complete, gibbonPersonIDLastEdit) - SELECT :atlColumnID as atlColumnID, gibbonPerson.gibbonPersonID, 'N' as complete, :gibbonPersonID as gibbonPersonIDLastEdit - FROM gibbonCourseClassPerson - INNER JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID = gibbonPerson.gibbonPersonID) - WHERE gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID - AND gibbonPerson.status='Full' - AND (dateStart IS NULL OR dateStart<=:today) - AND (dateEnd IS NULL OR dateEnd>=:today) - AND role = 'Student' - "; - - return $this->db()->insert($sql, $data); - } - -} +newQuery() + ->from($this->getTableName()) + ->cols([ + 'gibbonSchoolYear.name as yearName', 'gibbonCourse.gibbonSchoolYearID', 'gibbonCourse.name as courseName', 'atlColumn.name as ATLName', 'atlColumn.description as ATLDescription', 'atlColumn.completeDate', 'atlColumn.gibbonRubricID', 'atlColumn.gibbonCourseClassID', 'atlColumn.atlColumnID' + ]) + ->leftJoin('atlColumn', 'atlEntry.atlColumnID=atlColumn.atlColumnID') + ->leftJoin('gibbonCourseClass', 'atlColumn.gibbonCourseClassID = gibbonCourseClass.gibbonCourseClassID') + ->leftJoin('gibbonCourseClassPerson', 'gibbonCourseClass.gibbonCourseClassID = gibbonCourseClassPerson.gibbonCourseClassID AND atlEntry.gibbonPersonIDStudent = gibbonCourseClassPerson.gibbonPersonID') + ->leftJoin('gibbonCourse', 'gibbonCourseClass.gibbonCourseID = gibbonCourse.gibbonCourseID') + ->leftJoin('gibbonSchoolYear', 'gibbonCourse.gibbonSchoolYearID = gibbonSchoolYear.gibbonSchoolYearID') + ->where('atlEntry.gibbonPersonIDStudent = :gibbonPersonID') + ->where('completeDate <= :today') + ->where("gibbonCourseClass.reportable = 'Y'") + ->where("gibbonCourseClassPerson.reportable = 'Y'") + ->bindValue('gibbonPersonID', $gibbonPersonID) + ->bindValue('today', date('Y-m-d')); + + $criteria->addFilterRules([ + 'gibbonSchoolYearID' => function($query, $gibbonSchoolYearID) { + return $query->where('gibbonCourse.gibbonSchoolYearID = :gibbonSchoolYearID') + ->bindValue('gibbonSchoolYearID', $gibbonSchoolYearID); + } + ]); + + return $this->runQuery($query, $criteria); + } + + public function createATLEntries($atlColumnID, $gibbonCourseClassID, $gibbonPersonID) { + $data = ['atlColumnID' => $atlColumnID, 'gibbonCourseClassID' => $gibbonCourseClassID, 'gibbonPersonID' => $gibbonPersonID, 'today' => date('Y-m-d')]; + $sql = "INSERT INTO atlEntry (atlColumnID, gibbonPersonIDStudent, complete, gibbonPersonIDLastEdit) + SELECT :atlColumnID as atlColumnID, gibbonPerson.gibbonPersonID, 'N' as complete, :gibbonPersonID as gibbonPersonIDLastEdit + FROM gibbonCourseClassPerson + INNER JOIN gibbonPerson ON (gibbonCourseClassPerson.gibbonPersonID = gibbonPerson.gibbonPersonID) + WHERE gibbonCourseClassPerson.gibbonCourseClassID=:gibbonCourseClassID + AND gibbonPerson.status='Full' + AND (dateStart IS NULL OR dateStart<=:today) + AND (dateEnd IS NULL OR dateEnd>=:today) + AND role = 'Student' + "; + + return $this->db()->insert($sql, $data); + } + +} diff --git a/ATL/version.php b/ATL/version.php index b20c25a..051b09b 100644 --- a/ATL/version.php +++ b/ATL/version.php @@ -1,24 +1,24 @@ -. -*/ - -/** - * Sets version information. - */ -$moduleVersion = '1.6.00'; -$coreVersion = '22.0.00'; +. +*/ + +/** + * Sets version information. + */ +$moduleVersion = '1.6.00'; +$coreVersion = '22.0.00';