From 9157f7c55d75c7e55aac425948abc132981ecfd7 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Wed, 22 Mar 2023 14:59:57 +0000 Subject: add appropriate title for course completion icon, fixes #2416 Closes #2416 Merge request studip/studip!1614 --- app/controllers/admin/courses.php | 5 ++++- app/views/admin/courses/_course.php | 5 +++-- lib/models/Course.class.php | 14 ++++++++++++++ resources/assets/javascripts/bootstrap/application.js | 7 +++++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php index 99b2943..7bdeaae 100644 --- a/app/controllers/admin/courses.php +++ b/app/controllers/admin/courses.php @@ -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); } diff --git a/app/views/admin/courses/_course.php b/app/views/admin/courses/_course.php index 87491fd..645b06e 100644 --- a/app/views/admin/courses/_course.php +++ b/app/views/admin/courses/_course.php @@ -25,10 +25,11 @@ if (!$values['parent_course'] || !in_array($values['parent_course'], array_keys( ADMIN_COURSES_SHOW_COMPLETE): ?> have_studip_perm('tutor', $semid)) : ?> - + title="getCompetionLabel()) ?>" + aria-label=""> diff --git a/lib/models/Course.class.php b/lib/models/Course.class.php index 5df3e3e..429bb1b 100644 --- a/lib/models/Course.class.php +++ b/lib/models/Course.class.php @@ -755,6 +755,20 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe } /** + * 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 * start and/or the end semester has/have changed. diff --git a/resources/assets/javascripts/bootstrap/application.js b/resources/assets/javascripts/bootstrap/application.js index 4802091..f97dd90 100644 --- a/resources/assets/javascripts/bootstrap/application.js +++ b/resources/assets/javascripts/bootstrap/application.js @@ -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; -- cgit v1.0