Select Git revision
courseware.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
courseware.php 11.65 KiB
<?php
use \Courseware\StructuralElement;
class Contents_CoursewareController extends AuthenticatedController
{
/**
* Callback function being called before an action is executed.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
PageLayout::setHelpKeyword('Basis.Courseware'); // set keyword for new help
PageLayout::setTitle(_('Courseware'));
$this->user = $GLOBALS['user'];
}
/**
* Entry point of the controller that displays the courseware projects overview
*
* @param string $action
* @param string $widgetId
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* @SuppressWarnings(PHPMD.Superglobals)
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function index_action($action = false, $widgetId = null)
{
Navigation::activateItem('/contents/courseware/projects');
$this->setProjectsSidebar($action);
$this->elements = $this->getProjects('all');
}
/**
* Show Courseware of current user
*
* @param string $action
* @param string $widgetId
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* @SuppressWarnings(PHPMD.Superglobals)
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function courseware_action($action = false, $widgetId = null)
{
global $perm;
Navigation::activateItem('/contents/courseware/courseware');
$this->user_id = $GLOBALS['user']->id;
$this->setCoursewareSidebar();
$last = UserConfig::get($this->user_id)->getValue('COURSEWARE_LAST_ELEMENT');
if ($last[$this->user_id]) {
$this->entry_element_id = $last['global'];
$struct = \Courseware\StructuralElement::findOneBySQL(
"id = ? AND range_id = ? AND range_type = 'user'",
[$this->entry_element_id, $this->user_id]
);
}
// load courseware for current user
if (!$this->entry_element_id || !$struct || !$struct->canRead($GLOBALS['user'])) {