Skip to content
Snippets Groups Projects

Resolve "Average processing time per TA"

Files

@@ -28,30 +28,38 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import nl.tudelft.labracore.lib.security.user.AuthenticatedPerson;
import nl.tudelft.labracore.lib.security.user.Person;
import nl.tudelft.librador.dto.view.View;
import nl.tudelft.queue.PageUtil;
import nl.tudelft.queue.cache.PersonCacheManager;
import nl.tudelft.queue.dto.view.FeedbackViewDTO;
import nl.tudelft.queue.dto.view.statistics.AssistantRatingViewDto;
import nl.tudelft.queue.model.Feedback;
import nl.tudelft.queue.model.LabRequest;
import nl.tudelft.queue.repository.FeedbackRepository;
import nl.tudelft.queue.repository.LabRequestRepository;
import nl.tudelft.queue.service.EditionStatusService;
import nl.tudelft.queue.service.FeedbackService;
import nl.tudelft.queue.service.PermissionService;
@Controller
@RequestMapping("/feedback")
@AllArgsConstructor
@RequiredArgsConstructor
public class FeedbackController {
private FeedbackService fs;
private final LabRequestRepository labRequestRepository;
private PersonCacheManager pCache;
private final FeedbackService fs;
private FeedbackRepository fr;
private final PersonCacheManager pCache;
private PermissionService ps;
private final FeedbackRepository fr;
private final PermissionService ps;
private final EditionStatusService ess;
/**
* Maps the own feedback url to a page. The Feedback page displays feedback for the currently
@@ -126,8 +134,12 @@ public class FeedbackController {
Boolean restrictToCourseManager) {
var assistant = pCache.getRequired(assistantId);
// Use this check instead of permissionService methods
// If someone else is viewing, it's guaranteed to be staff because of previous checks.
boolean viewingOwnFeedback = assistantId.equals(person.getId());
// Anonymise feedback if viewing own feedback
List<Feedback> feedback = assistantId.equals(person.getId())
List<Feedback> feedback = viewingOwnFeedback
? fr.findByAssistantAnonymised(assistantId)
: fr.findByAssistant(assistantId);
@@ -139,7 +151,7 @@ public class FeedbackController {
textualFeedback = fs.filterFeedbackForManagerCourses(textualFeedback);
}
// admin check needs to be after restrict to course manager, otherwise might crash.
// admin check needs to be after restrict to course manager, otherwise might raise exception due to deleted feedback.
if (ps.isAdmin()) {
List<Feedback> deletedFeedback = fr.findByAssistantDeleted(assistantId);
feedback = Stream.concat(feedback.stream(), deletedFeedback.stream()).toList();
@@ -156,5 +168,13 @@ public class FeedbackController {
model.addAttribute("stars",
fs.countRatings(feedback));
if (!viewingOwnFeedback) {
List<LabRequest> requestsAssignedToPerson = labRequestRepository.findAllByAssistant(assistantId);
model.addAttribute("assistantRating", new AssistantRatingViewDto(
assistant,
(long) requestsAssignedToPerson.size(),
fs.getAvgStarRating(assistantId, requestsAssignedToPerson)));
}
}
}
Loading