Skip to content

Commit

Permalink
#47: Add course list action.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfranco committed Oct 9, 2024
1 parent d1c7415 commit c4da8cf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
10 changes: 0 additions & 10 deletions application/views/scripts/courses/list.phtml

This file was deleted.

34 changes: 17 additions & 17 deletions src/Controller/Courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,31 @@ public function __construct(Runtime $osidRuntime, IdMap $osidIdMap, TermHelper $
$this->namesType = new \phpkit_type_URNInetType('urn:inet:middlebury.edu:record:person_names');
}

/**
* Print out a list of all courses.
*
* @return void
*
* @since 4/21/09
*/
public function listAction()
#[Route('/courses/list/{catalog}', name: 'list_courses')]
public function listAction($catalog = NULL)
{
if ($this->_getParam('catalog')) {
$catalogId = $this->osidIdMap->fromString($this->_getParam('catalog'));
$data = [
'courses' => [],
];
if ($catalog) {
$catalogId = $this->osidIdMap->fromString($catalog);
$lookupSession = $this->osidRuntime->getCourseManager()->getCourseLookupSessionForCatalog($catalogId);
$this->view->title = 'Courses in '.$lookupSession->getCourseCatalog()->getDisplayName();
$data['title'] = 'Courses in '.$lookupSession->getCourseCatalog()->getDisplayName();
} else {
$lookupSession = $this->osidRuntime->getCourseManager()->getCourseLookupSession();
$this->view->title = 'Courses in All Catalogs';
$data['title'] = 'Courses in All Catalogs';
}
$lookupSession->useFederatedCourseCatalogView();

$this->view->courses = $lookupSession->getCourses();

$this->setSelectedCatalogId($lookupSession->getCourseCatalogId());
$this->view->headTitle($this->view->title);
$courses = $lookupSession->getCourses();
while ($courses->hasNext()) {
$data['courses'][] = $courses->getNextCourse();
}
// $this->setSelectedCatalogId($lookupSession->getCourseCatalogId());
// $this->view->headTitle($this->view->title);
// $this->view->menuIsCourses = true;

$this->view->menuIsCourses = true;
return $this->render('courses/list.html.twig', $data);
}

#[Route('/courses/view/{course}/{term}', name: 'view_course')]
Expand Down
4 changes: 4 additions & 0 deletions templates/courses/list.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% for course in courses %}
<h2><a href="{{ url('view_course', {course: osidIdToString(course.id)}) }}">{{ course.displayname }}</a> - {{ course.title }}</h2>
<div>{{ course.description | raw }}</div>
{% endfor %}

0 comments on commit c4da8cf

Please sign in to comment.