Skip to content
Snippets Groups Projects
Commit d6eb36ec authored by Tim Steiner's avatar Tim Steiner
Browse files

Course searching at /courses/public-view/search

parent 9bdd1f31
Branches
Tags
No related merge requests found
...@@ -222,7 +222,69 @@ class Courses_PublicViewController extends App_Controller_Action { ...@@ -222,7 +222,69 @@ class Courses_PublicViewController extends App_Controller_Action {
$where = 'courseId = ' . $courseId; $where = 'courseId = ' . $courseId;
$db->update('creqCourses', $data, $where); $db->update('creqCourses', $data, $where);
} }
}
public function searchAction()
{
$this->view->colleges = Courses_CourseModel::getCollegeNames();
$this->view->departments = Courses_CourseModel::getDepartments();
$this->view->subjects = Courses_CourseModel::getSubjectsFull();
}
public function resultsAction()
{
$criteria = $this->_getAllParams();
$in = $criteria;
$criteria['title'] = $criteria['courseTitle'];
$courses = Courses_CourseModel::findWithCriteria($criteria);
$data = new Unl_Model_Collection('Unl_Model_Array');
foreach ($courses as $requestId => $course) {
$aceOutcomes = $course->getAceOutcomes();
if (!$aceOutcomes) {
$aceOutcomes = array('-');
}
foreach ($aceOutcomes as $aceOutcome) {
$data[] = new Unl_Model_Array(array(
'slo' => substr($aceOutcome['slo'], 3),
'courseCode' => $course->getCourseCode(),
'college' => $course->getCollege(),
'title' => $course->getTitle(),
'courseId' => $course->getCourseId(),
));
}
}
$session = new Zend_Session_Namespace(__CLASS__);
$sortBy = $session->sortBy;
if (!Unl_Util::isArray($sortBy)) {
$sortBy = array();
}
if ($in['sort']) {
if (($key = array_search($in['sort'], $sortBy)) !== FALSE) {
unset($sortBy[$key]);
}
$sortBy[] = $in['sort'];
}
$session->sortBy = $sortBy;
foreach ($sortBy as $sortKey) {
$data->orderBy('get' . $sortKey);
}
$this->view->data = $data;
$this->view->criteria = $criteria;
}
public function viewAction()
{
$in = $this->_getAllParams();
$id = $in['id'];
if ($id) {
$course = Courses_CourseModel::findByCourseId($id);
}
$this->view->course = $course;
} }
} }
...@@ -5,6 +5,9 @@ require_once ('Unl/Model.php'); ...@@ -5,6 +5,9 @@ require_once ('Unl/Model.php');
class Courses_CourseModel extends Unl_Model class Courses_CourseModel extends Unl_Model
{ {
static protected $_colleges = array(); static protected $_colleges = array();
static protected $_collegeNames = array();
static protected $_departments = array();
static protected $_hierarchy = array();
static protected $_outcomeShortNames = array( static protected $_outcomeShortNames = array(
'SLO1' => 'writing', 'SLO1' => 'writing',
...@@ -389,6 +392,27 @@ class Courses_CourseModel extends Unl_Model ...@@ -389,6 +392,27 @@ class Courses_CourseModel extends Unl_Model
return self::find($generationId); return self::find($generationId);
} }
static public function findByCourseId($courseId)
{
if (!$courseLetter) {
$courseLetter = '';
}
$db = Zend_Registry::get('db');
$select = new Zend_Db_Select($db);
$select->from(array('g' => 'creqCourseGenerations'), array('courseGenerationId'));
$select->join(array('c' => 'creqCourses'), 'g.courseGenerationId = c.currentGeneration', array());
$select->where('c.courseId = ?', $courseId);
$records = $select->query()->fetchAll();
if (count($records) == 0) {
return null;
}
$generationId = $records[0]['courseGenerationId'];
return self::find($generationId);
}
static public function findActiveRequestByCourseCode($subject, $courseNumber, $courseLetter = '') static public function findActiveRequestByCourseCode($subject, $courseNumber, $courseLetter = '')
{ {
$db = Zend_Registry::get('db'); $db = Zend_Registry::get('db');
...@@ -450,6 +474,75 @@ class Courses_CourseModel extends Unl_Model ...@@ -450,6 +474,75 @@ class Courses_CourseModel extends Unl_Model
return self::find($generationIds); return self::find($generationIds);
} }
static public function findWithCriteria($criteria = array())
{
$validKeys = array('college', 'department', 'subject', 'courseNumber', 'courseLetter', 'title', 'campus', 'ace', 'essentialStudies', 'integratedStudies');
$criteria = array_intersect_key($criteria, array_flip($validKeys));
$emptySearch = true;
foreach ($criteria as $value) {
if ($value) {
$emptySearch = false;
}
}
if ($emptySearch) {
return new Unl_Model_Collection(__CLASS__);
}
$db = Zend_Registry::get('db');
$select = new Zend_Db_Select($db);
$select->from(array('l' => 'creqColleges'), array());
$select->join(array('d' => 'creqDepartments'), 'l.collegeId = d.college', array());
$select->join(array('s' => 'creqSubjects'), 'd.departmentId = s.department', array());
$select->join(array('c' => 'creqCourseCodes'), 's.name = c.subject', array());
$select->join(array('x' => 'creqCourseCrosslistings'), 'c.courseCodeId = x.courseCode', array());
$select->join(array('g' => 'creqCourseGenerations'), 'x.generation = g.courseGenerationId', array('courseGenerationId'));
$select->join(array('p' => 'creqCourses'), 'g.courseGenerationId = p.currentGeneration', array());
$select->join(array('e' => 'creqCourseDetails'), 'g.courseGenerationId = e.generation', array());
$select->where('g.removed = "no"');
$select->where('g.type = "official"');
if ($criteria['college']) {
$select->where('l.collegeId = ?', $criteria['college']);
}
if ($criteria['department']) {
$select->where('d.departmentId = ?', $criteria['department']);
}
if ($criteria['subject']) {
$select->where('c.subject = ?', $criteria['subject']);
}
if ($criteria['courseNumber']) {
$select->where('c.courseNumber LIKE ?', $criteria['courseNumber'] . '%');
}
if ($criteria['courseLetter']) {
$select->where('c.courseLetter = ?', $criteria['courseLetter']);
}
if ($criteria['title']) {
$select->where('e.title LIKE ?', '%' . $criteria['title'] . '%');
}
if ($criteria['campus']) {
$select->where('e.campuses LIKE ?', '%' . $criteria['title'] . '%');
}
if ($criteria['ace']) {
$select->join(array('a' => 'creqCourseAceOutcomes'), 'g.courseGenerationId = a.generation', array());
}
if ($criteria['essentialStudies']) {
$select->join(array('es' => 'creqCourseEsDesignations'), 'c.courseCodeId = es.courseCode', array());
}
if ($criteria['integratedStudies']) {
$select->where('c.integratedStudies = ?', 'yes');
}
$records = $select->query()->fetchAll();
if (count($records) == 0) {
return null;
}
$generationIds = array();
foreach ($records as $record) {
$generationIds[] = $record['courseGenerationId'];
}
return self::find($generationIds);
}
static public function save($models) static public function save($models)
{ {
...@@ -1459,6 +1552,48 @@ class Courses_CourseModel extends Unl_Model ...@@ -1459,6 +1552,48 @@ class Courses_CourseModel extends Unl_Model
return $homeSubject; return $homeSubject;
} }
static public function getSubjects()
{
self::_loadSubjectList();
return self::$_subjectList;
}
static public function getSubjectNames()
{
self::_loadSubjectList();
return self::$_subjectNames;
}
static public function getSubjectsFull()
{
self::_loadSubjectList();
$subjects = array();
foreach (self::$_subjectList as $id => $code) {
$subjects[$code] = $code . ' - ' . self::$_subjectNames[$id];
}
return $subjects;
}
static public function getSubjectDepartmentCollegeHierarchy()
{
if (count(self::$_hierarchy) == 0) {
$db = Zend_Registry::get('db');
$select = new Zend_Db_Select($db);
$select->from(array('c' => 'creqColleges'), array('college' => 'description'));
$select->join(array('d' => 'creqDepartments'), 'c.collegeId = d.college', array('department' => 'name'));
$select->join(array('s' => 'creqSubjects'), 'd.departmentId = s.department', array('code' => 'name', 'subject' => 'description'));
$select->order(array('college', 'department', 'subject'));
$records = $select->query()->fetchAll();
$hierarchy = array();
foreach ($records as $record) {
$hierarchy[$record['college']][$record['department']][$record['code']] = $record['subject'];
}
self::$_hierarchy = $hierarchy;
}
return self::$_hierarchy;
}
public function getCourseNumber() public function getCourseNumber()
{ {
$homeNumber = ''; $homeNumber = '';
...@@ -1590,6 +1725,24 @@ class Courses_CourseModel extends Unl_Model ...@@ -1590,6 +1725,24 @@ class Courses_CourseModel extends Unl_Model
return $homeDepartment; return $homeDepartment;
} }
static public function getDepartments()
{
if (count(self::$_departments) == 0) {
$db = Zend_Registry::get('db');
$select = new Zend_Db_Select($db);
$select->from(array('d' => 'creqDepartments'));
$select->order('name');
$records = $select->query()->fetchAll();
$departments = array();
foreach ($records as $record) {
$departments[$record['departmentId']] = $record['name'];
}
self::$_departments = $departments;
}
return self::$_departments;
}
public function getCollege() public function getCollege()
{ {
$homeCollege = ''; $homeCollege = '';
...@@ -1608,6 +1761,7 @@ class Courses_CourseModel extends Unl_Model ...@@ -1608,6 +1761,7 @@ class Courses_CourseModel extends Unl_Model
$db = Zend_Registry::get('db'); $db = Zend_Registry::get('db');
$select = new Zend_Db_Select($db); $select = new Zend_Db_Select($db);
$select->from(array('c' => 'creqColleges')); $select->from(array('c' => 'creqColleges'));
$select->order('name');
$records = $select->query()->fetchAll(); $records = $select->query()->fetchAll();
$colleges = array(); $colleges = array();
foreach ($records as $record) { foreach ($records as $record) {
...@@ -1618,6 +1772,23 @@ class Courses_CourseModel extends Unl_Model ...@@ -1618,6 +1772,23 @@ class Courses_CourseModel extends Unl_Model
return self::$_colleges; return self::$_colleges;
} }
static public function getCollegeNames()
{
if (count(self::$_collegeNames) == 0) {
$db = Zend_Registry::get('db');
$select = new Zend_Db_Select($db);
$select->from(array('c' => 'creqColleges'));
$select->order('description');
$records = $select->query()->fetchAll();
$colleges = array();
foreach ($records as $record) {
$colleges[$record['collegeId']] = $record['description'];
}
self::$_collegeNames = $colleges;
}
return self::$_collegeNames;
}
public function isIntegratedStudies() public function isIntegratedStudies()
{ {
$integratedStudies = false; $integratedStudies = false;
...@@ -2248,6 +2419,11 @@ class Courses_CourseModel extends Unl_Model ...@@ -2248,6 +2419,11 @@ class Courses_CourseModel extends Unl_Model
} }
} }
public function getCourseId()
{
return $this->_data['course'];
}
public function isValid() public function isValid()
{ {
//TODO: add criteria for this being valid //TODO: add criteria for this being valid
...@@ -2258,6 +2434,7 @@ class Courses_CourseModel extends Unl_Model ...@@ -2258,6 +2434,7 @@ class Courses_CourseModel extends Unl_Model
} }
static $_subjectList; static $_subjectList;
static $_subjectNames;
static protected function _loadSubjectList() static protected function _loadSubjectList()
{ {
...@@ -2268,11 +2445,13 @@ class Courses_CourseModel extends Unl_Model ...@@ -2268,11 +2445,13 @@ class Courses_CourseModel extends Unl_Model
$db = Zend_Registry::get('db'); $db = Zend_Registry::get('db');
$select = new Zend_Db_Select($db); $select = new Zend_Db_Select($db);
$select->from('creqSubjects', array('name')); $select->from('creqSubjects', array('subjectId', 'name', 'description'));
$select->order('name');
$records = $select->query()->fetchAll(); $records = $select->query()->fetchAll();
self::$_subjectList = array(); self::$_subjectList = array();
foreach ($records as $record) { foreach ($records as $record) {
self::$_subjectList[] = $record['name']; self::$_subjectList[$record['subjectId']] = $record['name'];
self::$_subjectNames[$record['subjectId']] = $record['description'];
} }
return self::$_subjectList; return self::$_subjectList;
......
<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/iace/reports/weekly.css', 'all'); ?>
<?php $this->layout()->tagline = ''; ?>
<?php $this->layout()->hideMenu = true; ?>
<h2>
ACE Certified Courses<br />
Interim ACE Committee<br />
</h2>
<table>
<tr>
<th><a href="<?php echo $this->url(array_merge($this->criteria, array('sort' => 'slo'))); ?>">SLO</a></th>
<th><a href="<?php echo $this->url(array_merge($this->criteria, array('sort' => 'college'))); ?>">College</a></th>
<th><a href="<?php echo $this->url(array_merge($this->criteria, array('sort' => 'courseCode'))); ?>">Course</a></th>
<th><a href="<?php echo $this->url(array_merge($this->criteria, array('sort' => 'title'))); ?>">Title</a></th>
</tr>
<?php foreach ($this->data as $record) { ?>
<tr <?php if ($rowCount++ % 2) { ?>class="even"<?php } ?>>
<td>
<a href="<?php echo $this->baseUrl(); ?>/courses/public-view/view/id/<?php echo $record->getCourseId(); ?>">
<?php echo $record->getSlo(); ?>
</a>
</td>
<td>
<a href="<?php echo $this->baseUrl(); ?>/courses/public-view/view/id/<?php echo $record->getCourseId(); ?>">
<?php echo $record->getCollege(); ?>
</a>
</td>
<td>
<a href="<?php echo $this->baseUrl(); ?>/courses/public-view/view/id/<?php echo $record->getCourseId(); ?>">
<?php echo $record->getCourseCode(); ?>
</a>
</td>
<td>
<a href="<?php echo $this->baseUrl(); ?>/courses/public-view/view/id/<?php echo $record->getCourseId(); ?>">
<?php echo $record->getTitle(); ?>
</a>
</td>
</tr>
<? } ?>
</table>
\ No newline at end of file
<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/courses/public-view/search.css', 'all'); ?>
<form method="get" action="<?php echo $this->baseUrl(); ?>/courses/public-view/results">
<label class="row">
<span class="label">College</span>
<?php echo $this->formSelect('college', null, null, array(0 => '--Select a College--') + $this->colleges); ?>
</label>
<label class="row">
<span class="label">Department</span>
<?php echo $this->formSelect('department', null, null, array(0 => '--Select a Department--') + $this->departments); ?>
</label>
<label class="row">
<span class="label">Subject Area</span>
<?php echo $this->formSelect('subject', null, null, array('' => '--Select a Subject--') + $this->subjects); ?>
</label>
<label class="row">
<span class="label">Course #</span>
<?php echo $this->formText('courseNumber'); ?>
</label>
<label class="row">
<span class="label">&nbsp;</span>
Specific number (i.e. 101) or Partial number (i.e. 1 for 100 level courses)
</label>
<label class="row">
<span class="label">Course Letter</span>
<?php echo $this->formText('courseLetter'); ?>
</label>
<label class="row">
<span class="label">Course Title Keyword</span>
<?php echo $this->formText('courseTitle'); ?>
</label>
<label class="row">
<span class="label">Activity Type</span>
<?php echo $this->formSelect('activity', null, null, array(-1 => '--Select Activity--',
1 => 'Lec - Lecture',
2 => 'Lab - Lab',
3 => 'Quz - Quiz',
4 => 'Rct - Recitation',
5 => 'Stu - Studio',
6 => 'Fld - Field',
7 => 'Ind - Independent Study',
8 => 'Psi - Personalized System of Instruction')); ?>
</label>
<div class="row">
<span class="label">Display Only</span>
<label><?php echo $this->formCheckbox('ace'); ?>ACE</label>
<label><?php echo $this->formCheckbox('essentialStudies'); ?>ES</label>
<label><?php echo $this->formCheckbox('integratedStudies'); ?>IS</label>
<label><?php echo $this->formCheckbox('specialFee', null, array('disabled' => 'disabled')); ?>Special Fee</label>
</div>
<label class="row">
<span class="label">Campus</span>
<?php echo $this->formSelect('campus', null, null, array('' => '--Select a Campus--', 'UNL' => 'UNL', 'UNO' => 'UNO', 'UNK' => 'UNK')); ?>
</label>
<?php echo $this->formSubmit('submit', 'Search'); ?>
</form>
\ No newline at end of file
<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/courses/view.css', 'all'); ?>
<?php $this->layout()->hideMenu = true; ?>
<div class="bulletinEntry">
<?php echo $this->bulletinEntry($this->course); ?>
</div>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment