Skip to content

Commit

Permalink
Noch unsicher, ob offset richtige Reihenfolge auslöst (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrahn authored Jan 6, 2021
1 parent 071529f commit 8a9edc6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
13 changes: 13 additions & 0 deletions controllers/course.php
Original file line number Diff line number Diff line change
Expand Up @@ -1078,4 +1078,17 @@ public function isStudentUploadForStudyGroupActivated()
$linkedCourseId = CourseConfig::get($this->course_id)->OPENCAST_MEDIAUPLOAD_LINKED_COURSE;
return !empty($linkedCourseId);
}

public function sort_order_action()
{
if ($new_order = Request::get('order')) {
if ($GLOBALS['perm']->have_studip_perm('dozent', $this->course_id)) {
CourseConfig::get($this->course_id)->store('COURSE_SORT_ORDER', $new_order);
}
else {
$_SESSION['opencast']['sort_order'] = $new_order;
}
}
$this->redirect('course/index/false');
}
}
20 changes: 16 additions & 4 deletions models/OCCourseModel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,23 @@ public function getEpisodes($force_reload = false, $unset_live = false)
}
}
}


// Get the Sort order title = TITLE, start = DATE_PUBLISHED, mkdata = DATE_CREATED (?)
if ($_SESSION['opencast']['sort_order']) {
$sort_str = $_SESSION['opencast']['sort_order'];
}
else if (CourseConfig::get($this->getCourseID())->COURSE_SORT_ORDER) {
$sort_str = CourseConfig::get($this->getCourseID())->COURSE_SORT_ORDER;
}
else {
$sort_str = 'mkdate1';
}
$sort = substr($sort_str, 0, -1);
$reversed = boolval(substr($sort_str, -1));
return $this->order_episodes_by(
['start', 'title'],
[SORT_NATURAL, SORT_NATURAL],
[true, false],
[$sort],
[SORT_NATURAL],
[$reversed],
$ordered_episodes
);
} else {
Expand Down
25 changes: 25 additions & 0 deletions views/course/_episode.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
<? use
Studip\Button,
Studip\LinkButton
?>

<?
$visibility_text = [
'invisible' => $_('Video ist nur für Sie sichtbar'),
'visible' => $_('Video ist für Teilnehmende sichtbar'),
'free' => $_('Video ist für jeden sichtbar')
];
$sort_orders = [
'mkdate0' => $_('Datum erstellt: Aufsteigend'),
'mkdate1' => $_('Datum erstellt: Absteigend'),
'start0' => $_('Datum publiziert: Aufsteigend'),
'start1' => $_('Datum publiziert: Absteigend'),
'title0' => $_('Title: Aufsteigend'),
'title1' => $_('Title: Absteigend'),
];
?>

<form action="<?= $controller->url_for('course/sort_order') ?>" method=post>
<select name="order">
<option selected disabled><?= $_('- Sortierung auswählen') ?></option>
<? foreach ($sort_orders as $key => $sort_order) : ?>
<option value="<?= $key ?>"><?= $sort_order ?></option>
<? endforeach; ?>
</select>
<div>
<?= Button::createAccept($_('Übernehmen'), ['title' => $_('Änderungen übernehmen')]); ?>
</div>
</form>

<script type="text/javascript">
OC.visibility_text = <?= json_encode($visibility_text) ?>;
</script>
Expand Down

0 comments on commit 8a9edc6

Please sign in to comment.