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

Updates to view parent and child course generations

parent 4382f41b
No related branches found
Tags
No related merge requests found
......@@ -63,6 +63,7 @@ class CourseAdminController extends Nmc_Controller_Action
$out->assign('nextCourseLink', $nextCourseLink);
}
$creditsSingleValues = array();
foreach($course->credits as $credit) {
if($credit->type == 1) {
......@@ -81,6 +82,8 @@ class CourseAdminController extends Nmc_Controller_Action
$out->assign('page', 'edit_course');
$out->assign('course', $course);
$out->assign('parentGeneration', $course->getParentGeneration());
$out->assign('childGenerations', $course->getChildGenerations());
$out->assign('uriParams', $uriParams);
echo $out->render();
}
......
......@@ -138,6 +138,21 @@ class CourseGeneration extends Asset
return $this->assetId;
}
public function getParentGeneration()
{
if(!$this->parent) {
return null;
}
$parentGeneration = CourseGenerations::getInstance()->find($this->parent);
return $parentGeneration;
}
public function getChildGenerations()
{
return CourseGenerations::getInstance()->fetchWithParentGeneration($this);
}
/**
* Returns a reference to the home crosslist
*
......
......@@ -18,8 +18,6 @@ class Request extends Nmc_Db_Table_Row
public function getCourseGeneration()
{
$returnValue = null;
$primaryKey = $this->_table->getPrimaryKeyName();
$primaryKey = Nmc_Db_Inflector::getInstance()->camelize($primaryKey);
$select = $this->_db->select();
$select->from(CourseGenerations::getInstance()->getTableName(),
......@@ -29,8 +27,9 @@ class Request extends Nmc_Db_Table_Row
. '.asset_id = '
. Assets::getInstance()->getTableName() . '.'
. Assets::getInstance()->getPrimaryKeyName());
$select->where($this->_db->quoteInto('request = ?', $this->$primaryKey));
$select->where($this->_db->quoteInto('request = ?', $this->getPrimaryKey()));
$select->order('creation_time');
$generations = $this->_db->fetchCol($select);
if(count($generations) > 0) {
$returnValue = CourseGenerations::getInstance()->find($generations[0]);
......
......@@ -137,6 +137,13 @@ class CourseGenerations extends Nmc_Db_Table
//print_r($newRecord->credits);
return $newRecord;
}
public function fetchWithParentGeneration(CourseGeneration $parentGeneration)
{
$where = $this->_db->quoteInto('parent=?', $parentGeneration->getPrimaryKey());
$childGenerations = $this->fetchAll($where);
return $childGenerations;
}
}
?>
\ No newline at end of file
<a href="/courseadmin/index<?php echo $this->prevCourseLink; ?>">Previous</a>
<a href="/courseadmin/index<?php echo $this->nextCourseLink; ?>">Next</a>
<h1>Navigation</h1>
<div>
<b>Alphabetical: </b>
<a href="/courseadmin/index<?php echo $this->prevCourseLink; ?>">Previous</a>
<a href="/courseadmin/index<?php echo $this->nextCourseLink; ?>">Next</a>
</div>
<?php if ($this->parentGeneration || $this->childGenerations->count() > 0) { ?>
<div>
<b>Generational:</b>
<?php if ($this->parentGeneration) { ?>
<a href="/CourseAdmin/index/<?php echo $this->parentGeneration->getPrimaryKey();?>">Parent</a>
<?php } ?>
<?php if ($this->childGenerations->count() > 0) { ?>
Children:
<?php $i = 0; foreach ($this->childGenerations as $childGeneration) { $i++; ?>
<a href="/CourseAdmin/index/<?php echo $childGeneration->getPrimaryKey();?>"><?php echo $i; ?></a>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
<h1>Edit Course</h1>
<form action="/courseadmin/updatecourse/<?php echo implode('/', $this->uriParams); ?>" method="post">
<input type="hidden" name="courseId" value="<?php echo $this->course->getPrimaryKey(); ?>" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment