Skip to content

Commit

Permalink
v1.5.12
Browse files Browse the repository at this point in the history
  • Loading branch information
SKuipers committed Nov 13, 2023
1 parent ce43550 commit 1025fec
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 31 deletions.
7 changes: 6 additions & 1 deletion ATL/CHANGEDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,9 @@
//v1.5.11
++$count;
$sql[$count][0] = '1.5.11';
$sql[$count][1] = '';
$sql[$count][1] = '';

//v1.5.12
++$count;
$sql[$count][0] = '1.5.12';
$sql[$count][1] = '';
5 changes: 4 additions & 1 deletion ATL/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
CHANGELOG
=========
v1.5.12
-------
Enabled staff to view visualisation and data for unpublished ATLs

v1.5.11
-------
Refactoring null coalesce

=======
v1.5.10
-------
Fixed visualization showing data that has not gone live
Expand Down
14 changes: 8 additions & 6 deletions ATL/atl_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@
echo __('The selected record does not exist, or you do not have access to it.');
echo '</div>';
} else {

$roleCategory = $session->get('gibbonRoleIDCurrentCategory');
if ($roleCategory == 'Staff') {
echo Format::alert(__m('As a staff member, your view of this ATL diagram accounts for all current ATL records, including those before their complete date. Parents and students will only see the ATL diagram based on completed data.'), 'message');
}

echo '<br/>';
echo visualiseATL($container, $gibbonPersonID);

Expand All @@ -105,9 +111,7 @@
}

if ($result->rowCount() < 1) {
echo "<div class='error'>";
echo __('Access denied.');
echo '</div>';
$page->addMessage(__('There are no records to display.'));
} else {
//Get child list
$gibbonPersonID = null;
Expand All @@ -127,9 +131,7 @@
}

if (count($options) == 0) {
echo "<div class='error'>";
echo __('Access denied.');
echo '</div>';
$page->addMessage(__('There are no records to display.'));
} elseif (count($options) == 1) {
$gibbonPersonID = key($options);
} else {
Expand Down
2 changes: 1 addition & 1 deletion ATL/atl_write.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
if ($gibbonCourseClassID == '') {
try {
$data = array('gibbonSchoolYearID' => $session->get('gibbonSchoolYearID'), 'gibbonPersonID' => $session->get('gibbonPersonID'));
$sql = 'SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID ORDER BY course, class';
$sql = 'SELECT gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse, gibbonCourseClass, gibbonCourseClassPerson WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID AND gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND gibbonCourseClassPerson.role NOT LIKE "%Left" ORDER BY course, class';
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
Expand Down
6 changes: 5 additions & 1 deletion ATL/atl_write_rubric.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@
echo "<span style='font-size: 65%; font-style: italic'>".Format::name('', $row4['preferredName'], $row4['surname'], 'Student', true).' - '.$row3['name'].'</span>';
echo '</h2>';

$mark = isset($_GET['mark']) && $_GET['mark'] == 'FALSE' ? false : true;
$mark = $session->get('gibbonRoleIDCurrentCategory') == 'Staff';
if (isset($_GET['mark']) && $_GET['mark'] == 'FALSE') {
$mark = false;
}

echo rubricView($guid, $connection2, $gibbonRubricID, $mark, $row4['gibbonPersonID'], 'atlColumn', 'atlColumnID', $atlColumnID, $contextDBTableGibbonRubricIDField, 'name', 'completeDate');
}
}
Expand Down
5 changes: 5 additions & 0 deletions ATL/hook_studentProfile_atlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
// Register scripts available to the core, but not included by default
$page->scripts->add('chart');

$roleCategory = $session->get('gibbonRoleIDCurrentCategory');
if ($roleCategory == 'Staff') {
echo Format::alert(__m('As a staff member, your view of this ATL diagram accounts for all current ATL records, including those before their complete date. Parents and students will only see the ATL diagram based on completed data.'), 'message');
}

echo visualiseATL($container, $gibbonPersonID);

echo getATLRecord($guid, $connection2, $gibbonPersonID);
Expand Down
2 changes: 1 addition & 1 deletion ATL/manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
$entryURL = 'atl_write.php';
$type = 'Additional';
$category = 'Assess';
$version = '1.5.11';
$version = '1.5.12';
$author = 'Ross Parker';
$url = 'http://rossparker.org';

Expand Down
48 changes: 40 additions & 8 deletions ATL/moduleFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Gibbon\Forms\Form;
use Gibbon\Services\Format;
use Gibbon\Forms\DatabaseFormFactory;
use Gibbon\Module\ATL\VisualiseATL;
use Gibbon\Module\Rubrics\Visualise;
use Gibbon\Domain\Rubrics\RubricGateway;
use Gibbon\Module\ATL\Domain\ATLColumnGateway;
Expand All @@ -29,6 +30,8 @@
function getATLRecord($guid, $connection2, $gibbonPersonID) {
global $session, $container;

$roleCategory = $session->get('gibbonRoleIDCurrentCategory');

require_once $session->get('absolutePath').'/modules/ATL/src/Domain/ATLColumnGateway.php';

$atlColumnGateway = $container->get(ATLColumnGateway::class);
Expand All @@ -53,7 +56,8 @@ function getATLRecord($guid, $connection2, $gibbonPersonID) {
$results = false;
while ($rowYears = $resultYears->fetch()) {
//Get and output ATLs
$entries = $atlColumnGateway->selectATLEntriesByStudent($rowYears['gibbonSchoolYearID'], $gibbonPersonID)->fetchAll();
$entries = $atlColumnGateway->selectATLEntriesByStudent($rowYears['gibbonSchoolYearID'], $gibbonPersonID, $roleCategory)->fetchAll();
$currentDate = date('Y-m-d');

if (!empty($entries)) {
$results = true;
Expand All @@ -80,15 +84,28 @@ function getATLRecord($guid, $connection2, $gibbonPersonID) {
}
++$count;

$output .= "<tr class=$rowNum>";
if (!empty($rowATL['completeDate']) && $currentDate < $rowATL['completeDate']) {
$rowNum .= ' dull';
if ($roleCategory != 'Staff') {
continue;
}
}

$output .= "<tr class='$rowNum'>";
$output .= '<td>';
$output .= "<span title='".htmlPrep($rowATL['description'])."'><b><u>".$rowATL['course'].'<br/>'.$rowATL['name'].'</u></b></span><br/>';
$output .= "<span style='font-size: 90%; font-style: italic; font-weight: normal'>";

if ($rowATL['completeDate'] != '') {
$output .= 'Marked on '.Format::date($rowATL['completeDate']).'<br/>';
$output .= 'Marked on '.Format::date($rowATL['completeDate']);
} else {
$output .= 'Unmarked<br/>';
$output .= 'Unmarked';
}

if (!empty($rowATL['completeDate']) && $currentDate < $rowATL['completeDate']) {
$output .= Format::tag(__m('Unpublished'), 'text-xxs bg-gray-400 ml-2');
}

$output .= '</span><br/>';
$output .= '</td>';
if ($rowATL['gibbonRubricID'] == '') {
Expand Down Expand Up @@ -151,6 +168,8 @@ function visualiseATL($container, $gibbonPersonID) {
$session = $container->get(Session::class);
$pdo = $container->get(Connection::class);

$roleCategory = $session->get('gibbonRoleIDCurrentCategory');

require_once $session->get('absolutePath').'/modules/ATL/src/Domain/ATLColumnGateway.php';

// Display the visualization of all ATLs
Expand All @@ -162,7 +181,7 @@ function visualiseATL($container, $gibbonPersonID) {
$contextDBTableDateField = 'completeDate';

$rubricGateway = $container->get(RubricGateway::class);
$studentRubricInfo = $container->get(ATLColumnGateway::class)->getATLRubricByStudent($session->get('gibbonSchoolYearID'), $gibbonPersonID);
$studentRubricInfo = $container->get(ATLColumnGateway::class)->getATLRubricByStudent($session->get('gibbonSchoolYearID'), $gibbonPersonID, $roleCategory);
$gibbonRubricID = $studentRubricInfo['gibbonRubricID'] ?? '';
$rubric = $rubricGateway->getByID($gibbonRubricID);

Expand Down Expand Up @@ -195,8 +214,14 @@ function visualiseATL($container, $gibbonPersonID) {
WHERE contextDBTable='$contextDBTable'
AND gibbonRubricEntry.gibbonPersonID=:gibbonPersonID
AND gibbonSchoolYearID=:gibbonSchoolYearID
AND NOT $contextDBTableDateField IS NULL
ORDER BY $contextDBTableDateField DESC";
AND NOT $contextDBTableDateField IS NULL ";

if ($roleCategory != 'Staff') {
$sqlContext .= " AND CURRENT_DATE >= $contextDBTable.$contextDBTableDateField ";
}

$sqlContext .= " ORDER BY $contextDBTableDateField DESC";

$resultContext = $pdo->select($sqlContext, $dataContext);

if ($resultContext->rowCount() > 0) {
Expand All @@ -219,7 +244,14 @@ function visualiseATL($container, $gibbonPersonID) {

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);
require_once $session->get('absolutePath').'/modules/ATL/src/VisualiseATL.php';

if (intval($gibbonRubricID) >= 318) {
$visualise = new VisualiseATL($session->get('absoluteURL'), $container->get('page'), $gibbonPersonID.'All', $columns, $rows, $cells, $contexts);
} else {
$visualise = new Visualise($session->get('absoluteURL'), $container->get('page'), $gibbonPersonID.'All', $columns, $rows, $cells, $contexts);
}

return $visualise->renderVisualise();
}

Expand Down
35 changes: 24 additions & 11 deletions ATL/src/Domain/ATLColumnGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,46 @@ class ATLColumnGateway extends QueryableGateway
private static $primaryKey = 'atlColumnID';
private static $searchableColumns = ['atlColumnID', 'issueName', 'description'];

public function getATLRubricByStudent($gibbonSchoolYearID, $gibbonPersonID)
public function getATLRubricByStudent($gibbonSchoolYearID, $gibbonPersonID, $roleCategory = 'Other')
{
$data = array('gibbonSchoolYearID' => $gibbonSchoolYearID, 'gibbonPersonID' => $gibbonPersonID, 'today' => date('Y-m-d'));
$data = array('gibbonSchoolYearID' => $gibbonSchoolYearID, 'gibbonPersonID' => $gibbonPersonID);
$sql = "SELECT
gibbonPerson.gibbonPersonID,
surname,
preferredName,
gibbonCourseClass.gibbonCourseClassID,
gibbonRubricID
atlColumn.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)
JOIN gibbonRubric ON (gibbonRubric.gibbonRubricID=atlColumn.gibbonRubricID)
WHERE status='Full'
AND gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID
AND gibbonPerson.gibbonPersonID=:gibbonPersonID
AND atlColumn.completeDate<=:today
AND gibbonPerson.gibbonPersonID=:gibbonPersonID
AND gibbonRubric.active='Y'";

if ($roleCategory != 'Staff') {
$data['today'] = date('Y-m-d');
$sql .= " AND atlColumn.completeDate<=:today ";
}

$sql .= "
AND gibbonCourseClassPerson.role='Student'
AND gibbonCourseClass.reportable='Y'
AND gibbonCourseClassPerson.reportable='Y'
ORDER BY surname, preferredName
ORDER BY atlColumn.completeDate DESC
LIMIT 0, 1";

return $this->db()->selectOne($sql, $data);
}

public function selectATLEntriesByStudent($gibbonSchoolYearID, $gibbonPersonID)
public function selectATLEntriesByStudent($gibbonSchoolYearID, $gibbonPersonID, $roleCategory = 'Other')
{
$data = ['gibbonPersonID' => $gibbonPersonID, 'gibbonSchoolYearID' => $gibbonSchoolYearID, 'today' => date('Y-m-d')];
$data = ['gibbonPersonID' => $gibbonPersonID, 'gibbonSchoolYearID' => $gibbonSchoolYearID];
$sql = "SELECT DISTINCT
atlColumn.*,
atlEntry.*,
Expand All @@ -64,9 +72,14 @@ public function selectATLEntriesByStudent($gibbonSchoolYearID, $gibbonPersonID)
JOIN gibbonPerson ON (atlEntry.gibbonPersonIDStudent=gibbonPerson.gibbonPersonID)
WHERE gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID
AND atlEntry.gibbonPersonIDStudent=:gibbonPersonID
AND gibbonSchoolYearID=:gibbonSchoolYearID
AND atlColumn.completeDate<=:today
AND gibbonCourseClassPerson.role='Student'
AND gibbonSchoolYearID=:gibbonSchoolYearID ";

if ($roleCategory != 'Staff') {
$data['today'] = date('Y-m-d');
$sql .= " AND atlColumn.completeDate<=:today ";
}

$sql .= " AND gibbonCourseClassPerson.role='Student'
AND gibbonCourseClass.reportable='Y'
AND gibbonCourseClassPerson.reportable='Y'
ORDER BY atlColumn.completeDate DESC, gibbonCourse.nameShort, gibbonCourseClass.nameShort";
Expand Down
Loading

0 comments on commit 1025fec

Please sign in to comment.