Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@
$opencast = apibridge::get_instance($ocinstanceid);
$table = $renderer->create_videos_tables('ignore', $headers, $columns, $baseurl);
$sortcolumns = $table->get_sort_columns();

// If we don't have a sortcolumn we sort by date desc.
if (empty($sortcolumns)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach is not ideal. We are requesting the video list from Opencast sorted by start date, but the Moodle table is not being sorted accordingly. This logic should be removed to avoid inconsistent behavior.
Additionally, instead of using the hardcoded value 3, please use the SORT_DESC constant for better readability and maintainability.

$sortcolumns = ['start_date' => 3];
}

echo $OUTPUT->header();

Expand Down
4 changes: 3 additions & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ public function create_videos_tables($id, $headers, $columns, $baseurl) {
$table->no_sorting('published');
$table->no_sorting('visibility'); // This column cannot be sortable because it does not mean anything to Opencast!
$table->no_sorting('select');
$table->sortable(true, 'start_date', SORT_DESC);
$table->text_sorting('title');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we initiating the sort with title instead of start_date?

$table->sortable(true, null, SORT_DESC);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to restore start_date as the initial sorting column. Without it, the table does not follow the expected initial sort order.

$table->maxsortkeys = 1;

$table->column_style('selectall', 'max-width', '40px');
$table->column_style('start_date', 'min-width', '125px');
Expand Down