Skip to content
Snippets Groups Projects
Commit 9157f7c5 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

add appropriate title for course completion icon, fixes #2416

Closes #2416

Merge request studip/studip!1614
parent fd4be9d9
No related branches found
No related tags found
No related merge requests found
......@@ -884,7 +884,10 @@ class Admin_CoursesController extends AuthenticatedController
$course->store();
if (Request::isXhr()) {
$this->render_json((int)$course->completion);
$this->render_json([
'state' => (int)$course->completion,
'label' => $course->getCompetionLabel(),
]);
} else {
$this->redirect('admin/courses/index#course-' . $course_id);
}
......
......@@ -25,10 +25,11 @@ if (!$values['parent_course'] || !in_array($values['parent_course'], array_keys(
<td>
<? if (Config::get()->ADMIN_COURSES_SHOW_COMPLETE): ?>
<? if ($GLOBALS['perm']->have_studip_perm('tutor', $semid)) : ?>
<a href="<?= $controller->url_for('admin/courses/toggle_complete/' . $semid) ?>"
<a href="<?= $controller->toggle_complete($course) ?>"
class="course-completion"
data-course-completion="<?= $values['completion'] ?>"
title="<?= _('Bearbeitungsstatus ändern') ?>">
title="<?= htmlReady($course->getCompetionLabel()) ?>"
aria-label="<?= _('Bearbeitungsstatus ändern') ?>">
<?= _('Bearbeitungsstatus ändern') ?>
</a>
<? else : ?>
......
......@@ -754,6 +754,20 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe
return Icon::create('radiobutton-checked', $role);
}
/**
* Returns the appropriate label for the completion status.
*
* @return string
*/
public function getCompetionLabel(): string
{
return [
0 => _('unvollständig'),
1 => _('in Bearbeitung'),
2 => _('fertig'),
][$this->completion] ?? _('undefiniert');
}
/**
* Generates a general log entry if the course were changed.
* Furthermore, this method emits notifications when the
......
......@@ -334,10 +334,13 @@ jQuery(document).on('click', '.course-admin td .course-completion', function ()
$(this).addClass('ajaxing');
}.bind(this), 300);
$.getJSON(href).done(function (completion) {
$.getJSON(href).done(function (response) {
clearTimeout(timeout);
$(this).removeClass('ajaxing').attr('data-course-completion', completion);
$(this).removeClass('ajaxing').attr({
'data-course-completion': response.state,
title: response.label
});
}.bind(this));
return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment