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

fix misc errors on feedback element, fixes #4475

Closes #4475

Merge request studip/studip!3269
parent b2635ede
No related branches found
No related tags found
No related merge requests found
......@@ -85,26 +85,24 @@ class Course_FeedbackController extends AuthenticatedController
if (!Feedback::hasRangeAccess($range_id, $range_type)) {
throw new AccessDeniedException();
} elseif ($this->create_perm) {
if (Request::bool('comment_only')) {
$mode = FeedbackElement::MODE_NO_RATING;
$commentable = 1;
} else {
$mode = Request::int('mode', FeedbackElement::MODE_NO_RATING);
$commentable = Request::bool('commentable');
$mode = FeedbackElement::MODE_NO_RATING;
$commentable = true;
if (!Request::bool('comment_only')) {
$mode = Request::int('mode', $mode);
$commentable = Request::bool('commentable', false);
}
$feedback = FeedbackElement::build([
$feedback = FeedbackElement::create([
'range_id' => $range_id,
'range_type' => $range_type,
'user_id' => $GLOBALS['user']->id,
'course_id' => $this->course_id,
'question' => trim(Request::get('question')),
'description' => Studip\Markup::purifyHtml(Request::get('description')),
'results_visible' => intval(Request::get('results_visible')),
'results_visible' => Request::bool('results_visible', false),
'commentable' => $commentable,
'anonymous_entries' => intval(Request::get('anonymous_entries')),
'anonymous_entries' => Request::bool('anonymous_entries', false),
'mode' => $mode
]);
$feedback->store();
PageLayout::postSuccess(_('Feedback-Element erfolgreich angelegt'));
} else {
PageLayout::postError(_('Sie haben keine Berechtigung, an dieser Stelle ein Feedback-Element anzulegen.'));
......
......@@ -17,7 +17,7 @@
<label class="star-rating undecorated <?= (isset($entry) && $i <= $entry->rating) || $i === 1 ? ' checked' : '' ?>">
<input class="star-rating-input" name="rating" value="<?= $i ?>" type="radio"
required
<? if (isset($entry) && $i == $entry->rating) echo 'selected'; ?>>
<? if (isset($entry) && $i == $entry->rating || $i === 1) echo 'checked'; ?>>
<?= Icon::create('star') ?>
</label>
<? endfor; ?>
......@@ -26,16 +26,23 @@
<? if ($feedback->commentable) : ?>
<label>
<?= _('Kommentar') ?>
<textarea name="comment"><?= htmlReady(isset($entry) ? $entry->comment : '') ?></textarea>
<textarea name="comment"><?= htmlReady($entry->comment ?? '') ?></textarea>
</label>
<? endif; ?>
<? if ($feedback->anonymous_entries) : ?>
<label>
<input type="checkbox" name="anonymous" value="1" <?= $entry->anonymous ? 'checked' : '' ?> >
<input type="checkbox" name="anonymous" value="1" <?= !empty($entry->anonymous) ? 'checked' : '' ?> >
<?= _('Kommentar anonym abgeben') ?>
</label>
<? endif; ?>
<? if (Request::isDialog()): ?>
<div data-dialog-button>
<?= Studip\Button::createAccept(_('Absenden'), 'add', ['class' => 'feedback-entry-submit']) ?>
</div>
<? else: ?>
<div>
<?= Studip\Button::createAccept(_('Absenden'), 'add', ['class' => 'feedback-entry-submit']) ?>
<?= Studip\Button::createCancel(_('Abbrechen'), 'cancel', ['class' => 'feedback-entry-cancel']) ?>
</div>
<? endif; ?>
......@@ -125,12 +125,14 @@ STUDIP.Feedback = {
}
);
}
if ($('.feedback-entry-cancel').length) {
if ($('.feedback-entry-cancel').length > 0) {
$('.feedback-entry-cancel').prop("onclick", null).off("click");
$('.feedback-entry-cancel').click(function (event) {
event.preventDefault();
$(this).closest('form')[0].reset();
$(this).closest('form').find('.star-rating').removeClass('checked');
$(this).closest('form').each(function () {
this.reset();
$(this).find('.star-rating').removeClass('checked');
});
});
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment