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

Allow for editing of Essential Studies in course admin

parent 7449ed38
No related branches found
Tags
No related merge requests found
......@@ -85,6 +85,7 @@ class CourseAdminController extends Nmc_Controller_Action
$out->assign('parentGeneration', $course->getParentGeneration());
$out->assign('childGenerations', $course->getChildGenerations());
$out->assign('uriParams', $in->getParams());
$out->assign('essentialStudiesAreas', $course->getEssentialStudiesAreas());
$out->tagline = 'Edit Course';
echo $out->render('unlModernWrapper.xhtml');
}
......@@ -141,7 +142,22 @@ class CourseAdminController extends Nmc_Controller_Action
$course->gradTieIn->$key2 = $val2;
//echo '$course->gradTieIn->' . $key2 . ' = ' . $val2 . "\n";
}
} else if(is_array($val)) {
} else if ($key == 'essentialStudies') {
//
foreach ($val as $collegeName => $areas) {
$college = Colleges::getInstance()->fetchWithName($collegeName);
foreach ($course->crosslistings as $crosslisting) {
$courseCodeId = $crosslisting->courseCode;
$courseCode = CourseCodes::getInstance()->findOne($courseCodeId);
CourseEsDesignations::getInstance()->setEssentialStudiesAreas(
$courseCode,
$college,
$areas
);
}
}
//
} else if (is_array($val)) {
$array = $course->$key;
foreach($array as $key2 => $row) {
unset($array[$key2]);
......
<?php
class CourseEsDesignation extends Nmc_Db_Table_Row
{
public function _init()
{
parent::_init();
$collegeRelation = new Nmc_Db_Table_Relation_HasOne(
Colleges::getInstance(),
$this,
'college',
'college',
true
);
$this->_registerRelation($collegeRelation);
}
}
\ No newline at end of file
......@@ -174,6 +174,22 @@ class CourseGeneration extends Asset
return CourseEsDesignations::getInstance()->isCourseCodeEssentialStudies($courseCode, $college);
}
public function getEssentialStudiesAreas(College $college = null)
{
$courseCode = CourseCodes::getInstance()->findBySubjectNumberAndLetter($this->subject,
$this->courseNumber,
$this->courseLetter);
if (is_null($courseCode)) {
if (is_null($college)) {
return array(array());
} else {
return array();
}
}
return CourseEsDesignations::getInstance()->getEssentialStudiesAreas($courseCode, $college);
}
public function getHomeCollege()
{
$department = $this->getHomeDepartment();
......
......@@ -24,4 +24,10 @@ class Colleges extends Nmc_Db_Table
}
return self::$_instance;
}
public function fetchWithName($name) {
$db = $this->getAdapter();
$where = $db->quoteInto('name = ?', $name);
return $this->fetchRow($where);
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
class CourseEsDesignations extends Nmc_Db_Table
{
protected $_primary = 'courseEsDesignationId';
protected $_rowClass = 'CourseEsDesignation';
/**
* The one true instance
......@@ -50,4 +51,66 @@ class CourseEsDesignations extends Nmc_Db_Table
return false;
}
}
public function getEssentialStudiesAreas(CourseCode $course, College $college = null)
{
$db = $this->getAdapter();
$where = array();
$where[] = $db->quoteInto('courseCode = ?', $course->getPrimaryKey());
if ($college) {
$where[] = $db->quoteInto('college = ?', $college->getPrimaryKey());
}
$where = implode(' AND ', $where);
$results = $this->fetchAll($where);
$areaCodes = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H');
$colleges = Colleges::getInstance()->fetchAll();
$areas = array();
if ($college) {
foreach ($areaCodes as $areaCode) {
$areas[$areaCode] = false;
}
} else {
foreach ($colleges as $collegeRow) {
$areas[$collegeRow->name] = array();
foreach ($areaCodes as $areaCode) {
$areas[$collegeRow->name][$areaCode] = false;
}
}
}
foreach ($results as $row) {
if ($college) {
$areas[$row->area] = true;
} else {
$areas[$row->college->name][$row->area] = true;
}
}
return $areas;
}
public function setEssentialStudiesAreas(CourseCode $course, College $college, $areas)
{
$db = $this->getAdapter();
foreach ($areas as $areaName => $areaValue) {
$where = array();
$where[] = $db->quoteInto('courseCode = ?', $course->getPrimaryKey());
$where[] = $db->quoteInto('college = ?', $college->getPrimaryKey());
$where[] = $db->quoteInto('area = ?', $areaName);
$where = implode(' AND ', $where);
$row = $this->fetchRow($where);
if ($row && $areaValue == 'no') {
$row->delete();
} else if (!$row && $areaValue == 'yes') {
$row = $this->fetchNew();
$row->courseCode = $course->getPrimaryKey();
$row->college = $college;
$row->area = $areaName;
$row->save();
}
}
}
}
\ No newline at end of file
......@@ -162,7 +162,8 @@
<div class="clear"></div>
</fieldset>
<fieldset>
<fieldset class="three_column">
<div class="column">
<label>
Integrated Studies
<input type="hidden" name="integratedStudies" value="no" />
......@@ -174,6 +175,40 @@
<?php } ?>
/>
</label>
</div>
<div class="column">
<label>
Essential Studies<br />
<table>
<tr>
<th>&nbsp;</th>
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
<th>E</th>
<th>F</th>
<th>G</th>
<th>H</th>
</tr>
<?php foreach ($this->essentialStudiesAreas as $college => $areas) { ?>
<tr>
<th><?php echo $college; ?></th>
<?php foreach ($areas as $areaName => $areaValue) { ?>
<td><?php echo $this->formCheckbox(
'essentialStudies[' . $college . '][' . $areaName . ']',
($areaValue ? 'yes' : 'no'),
null,
array('yes', 'no')
); ?></td>
<?php } ?>
</tr>
<?php } ?>
</table>
</label>
</div>
<div class="clear"></div>
</fieldset>
......@@ -189,7 +224,7 @@
<h2>Crosslistings</h2>
<fieldset class="three_column">
<table>
<table class="multirow">
<?php $hasTieIn = false;
foreach($this->course->crosslistings as $key => $crosslist) {
if($crosslist->type == 'grad tie-in') { $hasTieIn = true; }
......@@ -390,7 +425,7 @@
<fieldset class="two_of_three_column" id="activities">
<h3>Activity</h3>
<table>
<table class="multirow">
<?php foreach($this->course->activities as $key => $activity) { ?>
<tr>
<th> Type </th>
......
......@@ -118,7 +118,7 @@ fieldset#activities {
clear: none;
}
div.main_section tr:first-child th {
div.main_section table.multirow tr:first-child th {
color: #a00;
font-weight: normal;
padding-right: 10px;
......@@ -126,14 +126,14 @@ div.main_section tr:first-child th {
font-size: 100%;
text-indent: 0px;
}
div.main_section tr th {
div.main_section table.multirow tr th {
overflow: hidden;
text-indent: -1000px;
}
div.main_section td {
div.main_section table.multirow td {
padding-right: 15px;
}
div.main_section td input[type=text] {
div.main_section table.multirow td input[type=text] {
width: 75px;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment