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
......@@ -2,9 +2,9 @@
/**
* PublicViewController
*
*
* @author
* @version
* @version
*/
......@@ -21,12 +21,12 @@ class Courses_PublicViewController extends App_Controller_Action {
$dom->formatOutput = true;
$root = $dom->createElement('courses');
$dom->appendChild($root);
foreach ($courses as $course) {
$courseNode = $dom->createElement('course');
$courseNode->appendChild($dom->createElement('title', htmlspecialchars($course->getTitle())));
$crosslistings = $course->getCrosslistings();
if (count($crosslistings) > 0) {
$courseCodesNode = $dom->createElement('courseCodes');
......@@ -44,11 +44,11 @@ class Courses_PublicViewController extends App_Controller_Action {
} else {
continue;
}
$courseNode->appendChild($dom->createElement('gradingType', htmlspecialchars($course->getGradingType(), null, 'UTF-8')));
$courseNode->appendChild($dom->createElement('dfRemoval', htmlspecialchars($course->getDfRemoval(), null, 'UTF-8')));
$courseNode->appendChild($dom->createElement('effectiveSemester', htmlspecialchars($course->getEffectiveSemester(), null, 'UTF-8')));
if ($node = $this->_getNodeFromHtmlFragment($dom, 'prerequisite', $course->getPrerequisite())) {
$courseNode->appendChild($node);
}
......@@ -58,7 +58,7 @@ class Courses_PublicViewController extends App_Controller_Action {
if ($node = $this->_getNodeFromHtmlFragment($dom, 'description', $course->getDescription())) {
$courseNode->appendChild($node);
}
if (count($course->getCampuses()) > 0) {
$campusesNode = $dom->createElement('campuses');
$courseNode->appendChild($campusesNode);
......@@ -66,7 +66,7 @@ class Courses_PublicViewController extends App_Controller_Action {
$campusesNode->appendChild($dom->createElement('campus', $campus));
}
}
if (count($course->getDeliveryMethods()) > 0) {
$deliveryMethodsNode = $dom->createElement('deliveryMethods');
$courseNode->appendChild($deliveryMethodsNode);
......@@ -74,7 +74,7 @@ class Courses_PublicViewController extends App_Controller_Action {
$deliveryMethodsNode->appendChild($dom->createElement('deliveryMethod', $deliveryMethod));
}
}
if (count($course->getTermsOffered()) > 0) {
$termsOfferedNode = $dom->createElement('termsOffered');
$courseNode->appendChild($termsOfferedNode);
......@@ -82,7 +82,7 @@ class Courses_PublicViewController extends App_Controller_Action {
$termsOfferedNode->appendChild($dom->createElement('term', $term));
}
}
$activities = $course->getActivities();
if (count($crosslistings) > 0) {
$activitiesNode = $dom->createElement('activities');
......@@ -96,7 +96,7 @@ class Courses_PublicViewController extends App_Controller_Action {
}
}
}
$credits = $course->getCredits();
if (count($credits) > 0) {
$creditsNode = $dom->createElement('credits');
......@@ -107,7 +107,7 @@ class Courses_PublicViewController extends App_Controller_Action {
$creditNode->setAttribute('type', $credit['description']);
}
}
$gradTieIn = $course->getGradTieIn();
if ($gradTieIn['credits']) {
$courseNode->appendChild($dom->createElement('gradCredits', htmlspecialchars($gradTieIn['credits'], null, 'UTF-8')));
......@@ -118,45 +118,45 @@ class Courses_PublicViewController extends App_Controller_Action {
if ($node = $this->_getNodeFromHtmlFragment($dom, 'gradPrerequisites', $gradTieIn['prerequisites'])) {
$courseNode->appendChild($node);
}
$root->appendChild($courseNode);
}
header('Content-type: text/xml');
$dom->normalize();
echo $dom->saveXML();
}
protected function _getNodeFromHtmlFragment($dom, $nodeName, $fragment)
{
$fragment = trim($fragment);
if (!$fragment) {
return null;
}
$node = new DOMDocument('1.0', 'UTF-8');
$fragment = '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body>' . $fragment . '</body>';
$node = DOMDocument::loadHTML(strtr($fragment, array('&' => '&amp;')));
if (!$node->documentElement) {
return null;
}
$node = $dom->importNode($node->documentElement, true);
if (count($node->childNodes->item(1)->childNodes) == 1 && $node->childNodes->item(1)->childNodes->item(0)->nodeName == 'p') {
$realNode = $node->childNodes->item(1)->childNodes->item(0);
} else {
$realNode = $node->childNodes->item(1);
}
$newNode = $dom->createElement($nodeName);
while ($realNode->hasChildNodes()) {
$newNode->appendChild($realNode->childNodes->item(0));
}
return $newNode;
}
/**
* This action syncronizes the qreqCourses.currentGeneration field with data from creqCourseGenerations
*
......@@ -166,19 +166,19 @@ class Courses_PublicViewController extends App_Controller_Action {
$this->_disableLayoutAndView();
//header('Content-type: text/plain');
$db = Zend_Registry::get('db');
$sql = 'SELECT * FROM creqCourseGenerations';
$data = $db->query($sql)->fetchAll();
$courses = array();
foreach ($data as $row) {
$courseId = $row['course'];
$generationId = $row['courseGenerationId'];
$courses[$courseId][$generationId] = $row;
}
$multipleLatestCount = 0;
$courseLatest = array();
foreach ($courses as $courseId => $course) {
......@@ -216,13 +216,75 @@ class Courses_PublicViewController extends App_Controller_Action {
$courseLatest[$courseId] = $latestId;
}
echo 'Multiple Latest Count: ' . $multipleLatestCount . PHP_EOL;
foreach ($courseLatest as $courseId => $latestId) {
$data = array('currentGeneration' => $latestId);
$where = 'courseId = ' . $courseId;
$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;
}
}
This diff is collapsed.
<?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