diff --git a/application/controllers/CourseadminController.php b/application/controllers/CourseadminController.php
index 1a069a8318415d4a6592f8f05905540de9547526..687e0de54db498151572c91f488870fe4af3b2b4 100644
--- a/application/controllers/CourseadminController.php
+++ b/application/controllers/CourseadminController.php
@@ -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]);
diff --git a/application/models/rows/CourseEsDesignation.php b/application/models/rows/CourseEsDesignation.php
new file mode 100644
index 0000000000000000000000000000000000000000..4f96fea941c4e0a6394d74d369b9367c6e9e7ca1
--- /dev/null
+++ b/application/models/rows/CourseEsDesignation.php
@@ -0,0 +1,18 @@
+<?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
diff --git a/application/models/rows/CourseGeneration.php b/application/models/rows/CourseGeneration.php
index 3ccaa99628121bd042a278867b1a96ba79b87f76..740ad469118fa334ee0b40c37219037242209218 100644
--- a/application/models/rows/CourseGeneration.php
+++ b/application/models/rows/CourseGeneration.php
@@ -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();
diff --git a/application/models/tables/Colleges.php b/application/models/tables/Colleges.php
index bc252aa55aaf6d15fa4cd7dbae1911aef3bddab4..695e0347be59052d6a18a3ce31b3e09edd4c036e 100644
--- a/application/models/tables/Colleges.php
+++ b/application/models/tables/Colleges.php
@@ -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
diff --git a/application/models/tables/CourseEsDesignations.php b/application/models/tables/CourseEsDesignations.php
index 0e064c3cda0ca748ea64200ca668f74ecb4ab594..c50bbf4fd18e468740e54333cfc281b2cff68157 100644
--- a/application/models/tables/CourseEsDesignations.php
+++ b/application/models/tables/CourseEsDesignations.php
@@ -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
diff --git a/application/views/edit_course.xhtml b/application/views/edit_course.xhtml
index cc750426532d5247693f9ce803f4aee56cfa7891..11cffbfd36f2aa076bc5c413e04fc45e50e6bf77 100644
--- a/application/views/edit_course.xhtml
+++ b/application/views/edit_course.xhtml
@@ -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> </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>
diff --git a/document_root/css/edit_course.css b/document_root/css/edit_course.css
index b52580c883e2354f0b02244ec4aac602fa23eb09..fdc811e7d8f4d2834de48aacfa89253ea8c00c07 100644
--- a/document_root/css/edit_course.css
+++ b/document_root/css/edit_course.css
@@ -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;
}