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 ...@@ -85,26 +85,24 @@ class Course_FeedbackController extends AuthenticatedController
if (!Feedback::hasRangeAccess($range_id, $range_type)) { if (!Feedback::hasRangeAccess($range_id, $range_type)) {
throw new AccessDeniedException(); throw new AccessDeniedException();
} elseif ($this->create_perm) { } elseif ($this->create_perm) {
if (Request::bool('comment_only')) { $mode = FeedbackElement::MODE_NO_RATING;
$mode = FeedbackElement::MODE_NO_RATING; $commentable = true;
$commentable = 1; if (!Request::bool('comment_only')) {
} else { $mode = Request::int('mode', $mode);
$mode = Request::int('mode', FeedbackElement::MODE_NO_RATING); $commentable = Request::bool('commentable', false);
$commentable = Request::bool('commentable');
} }
$feedback = FeedbackElement::build([ $feedback = FeedbackElement::create([
'range_id' => $range_id, 'range_id' => $range_id,
'range_type' => $range_type, 'range_type' => $range_type,
'user_id' => $GLOBALS['user']->id, 'user_id' => $GLOBALS['user']->id,
'course_id' => $this->course_id, 'course_id' => $this->course_id,
'question' => trim(Request::get('question')), 'question' => trim(Request::get('question')),
'description' => Studip\Markup::purifyHtml(Request::get('description')), 'description' => Studip\Markup::purifyHtml(Request::get('description')),
'results_visible' => intval(Request::get('results_visible')), 'results_visible' => Request::bool('results_visible', false),
'commentable' => $commentable, 'commentable' => $commentable,
'anonymous_entries' => intval(Request::get('anonymous_entries')), 'anonymous_entries' => Request::bool('anonymous_entries', false),
'mode' => $mode 'mode' => $mode
]); ]);
$feedback->store();
PageLayout::postSuccess(_('Feedback-Element erfolgreich angelegt')); PageLayout::postSuccess(_('Feedback-Element erfolgreich angelegt'));
} else { } else {
PageLayout::postError(_('Sie haben keine Berechtigung, an dieser Stelle ein Feedback-Element anzulegen.')); PageLayout::postError(_('Sie haben keine Berechtigung, an dieser Stelle ein Feedback-Element anzulegen.'));
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<label class="star-rating undecorated <?= (isset($entry) && $i <= $entry->rating) || $i === 1 ? ' checked' : '' ?>"> <label class="star-rating undecorated <?= (isset($entry) && $i <= $entry->rating) || $i === 1 ? ' checked' : '' ?>">
<input class="star-rating-input" name="rating" value="<?= $i ?>" type="radio" <input class="star-rating-input" name="rating" value="<?= $i ?>" type="radio"
required required
<? if (isset($entry) && $i == $entry->rating) echo 'selected'; ?>> <? if (isset($entry) && $i == $entry->rating || $i === 1) echo 'checked'; ?>>
<?= Icon::create('star') ?> <?= Icon::create('star') ?>
</label> </label>
<? endfor; ?> <? endfor; ?>
...@@ -26,16 +26,23 @@ ...@@ -26,16 +26,23 @@
<? if ($feedback->commentable) : ?> <? if ($feedback->commentable) : ?>
<label> <label>
<?= _('Kommentar') ?> <?= _('Kommentar') ?>
<textarea name="comment"><?= htmlReady(isset($entry) ? $entry->comment : '') ?></textarea> <textarea name="comment"><?= htmlReady($entry->comment ?? '') ?></textarea>
</label> </label>
<? endif; ?> <? endif; ?>
<? if ($feedback->anonymous_entries) : ?> <? if ($feedback->anonymous_entries) : ?>
<label> <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') ?> <?= _('Kommentar anonym abgeben') ?>
</label> </label>
<? endif; ?> <? endif; ?>
<? if (Request::isDialog()): ?>
<div data-dialog-button>
<?= Studip\Button::createAccept(_('Absenden'), 'add', ['class' => 'feedback-entry-submit']) ?>
</div>
<? else: ?>
<div> <div>
<?= Studip\Button::createAccept(_('Absenden'), 'add', ['class' => 'feedback-entry-submit']) ?> <?= Studip\Button::createAccept(_('Absenden'), 'add', ['class' => 'feedback-entry-submit']) ?>
<?= Studip\Button::createCancel(_('Abbrechen'), 'cancel', ['class' => 'feedback-entry-cancel']) ?> <?= Studip\Button::createCancel(_('Abbrechen'), 'cancel', ['class' => 'feedback-entry-cancel']) ?>
</div> </div>
<? endif; ?>
...@@ -125,12 +125,14 @@ STUDIP.Feedback = { ...@@ -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').prop("onclick", null).off("click");
$('.feedback-entry-cancel').click(function (event) { $('.feedback-entry-cancel').click(function (event) {
event.preventDefault(); event.preventDefault();
$(this).closest('form')[0].reset(); $(this).closest('form').each(function () {
$(this).closest('form').find('.star-rating').removeClass('checked'); 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