Skip to content

Commit

Permalink
Planner: improved default selected course in Unit Planner sidebar menu
Browse files Browse the repository at this point in the history
  • Loading branch information
SKuipers committed Sep 4, 2024
1 parent 1ee491a commit a129bb1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ v28.0.00
Markbook: updated markbook columns to grey out students who joined after the Go Live date
Messenger: limited the individual message target to a maximum of 50 people
Messenger: updated preferences to ensure signatures are displayed on a white background
Planner: improved default selected course in Unit Planner sidebar menu
Reports: added a Progress by Department report for viewing class criteria progress
Staff: updated Manage Staff to override required custom fields when manually editing a staff member
Staff: updated family page on Staff Profile to exclude personal details and addresses
Expand Down
9 changes: 8 additions & 1 deletion modules/Planner/moduleFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,15 @@ function sidebarExtraUnits($guid, $connection2, $gibbonCourseID, $gibbonSchoolYe
// Show class picker in sidebar
$courseGateway = $container->get(CourseGateway::class);

if (!empty($_GET['gibbonCourseID'])) {
$session->set('gibbonCourseIDUnitPlanner', $_GET['gibbonCourseID']);
}

if ($highestAction == 'Unit Planner_all') {
$courses = $courseGateway->selectCoursesBySchoolYear($gibbonSchoolYearID)->fetchKeyPair();
$courses = [
'--'.__('My Courses').'--' => $courseGateway->selectCoursesByPerson($gibbonSchoolYearID, $session->get('gibbonPersonID'))->fetchKeyPair(),
'--'.__('All Courses').'--' => $courseGateway->selectCoursesBySchoolYear($gibbonSchoolYearID)->fetchKeyPair(),
];
} elseif ($highestAction == 'Unit Planner_learningAreas') {
$courses = $courseGateway->selectCoursesByPerson($gibbonSchoolYearID, $session->get('gibbonPersonID'))->fetchKeyPair();
}
Expand Down
30 changes: 5 additions & 25 deletions modules/Planner/units.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

// School Year Info
$gibbonSchoolYearID = $_GET['gibbonSchoolYearID'] ?? $session->get('gibbonSchoolYearID');
$gibbonCourseID = $_GET['gibbonCourseID'] ?? null;
$gibbonCourseID = $_GET['gibbonCourseID'] ?? $session->get('gibbonCourseIDUnitPlanner') ?? null;

if (empty($gibbonSchoolYearID)) {
$page->addError(__('Your request failed because your inputs were invalid.'));
Expand All @@ -63,32 +63,12 @@
}

if (empty($gibbonCourseID)) {
try {
if ($highestAction == 'Unit Planner_all') {
$data = array('gibbonSchoolYearID' => $gibbonSchoolYearID);
$sql = 'SELECT * FROM gibbonCourse WHERE gibbonSchoolYearID=:gibbonSchoolYearID ORDER BY nameShort';
} elseif ($highestAction == 'Unit Planner_learningAreas') {
$data = array('gibbonPersonID' => $session->get('gibbonPersonID'), 'gibbonSchoolYearID' => $gibbonSchoolYearID, 'gibbonSchoolYearID' => $gibbonSchoolYearID);
$sql = "SELECT gibbonCourseID, gibbonCourse.name, gibbonCourse.nameShort FROM gibbonCourse JOIN gibbonDepartment ON (gibbonCourse.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) JOIN gibbonDepartmentStaff ON (gibbonDepartmentStaff.gibbonDepartmentID=gibbonDepartment.gibbonDepartmentID) WHERE gibbonDepartmentStaff.gibbonPersonID=:gibbonPersonID AND (role='Coordinator' OR role='Assistant Coordinator' OR role='Teacher (Curriculum)') AND gibbonSchoolYearID=:gibbonSchoolYearID ORDER BY gibbonCourse.nameShort";
}
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
}
if ($result->rowCount() > 0) {
$row = $result->fetch();
$gibbonCourseID = $row['gibbonCourseID'];
}
$courseList = $courseGateway->selectCoursesByPerson($gibbonSchoolYearID, $session->get('gibbonPersonID'))->fetchKeyPair();
$gibbonCourseID = key($courseList);
}

if ($gibbonCourseID != '') {

$data = array('gibbonCourseID' => $gibbonCourseID);
$sql = 'SELECT * FROM gibbonCourse WHERE gibbonCourseID=:gibbonCourseID';
$result = $connection2->prepare($sql);
$result->execute($data);
if ($result->rowCount() == 1) {
$row = $result->fetch();
}
$row = $container->get(CourseGateway::class)->getByID($gibbonCourseID);
}

$page->navigator->addSchoolYearNavigation($gibbonSchoolYearID, ['courseName' => $row['nameShort'] ?? '']);
Expand Down

0 comments on commit a129bb1

Please sign in to comment.