Fix grade calculator being serialized #59
@ -1,8 +1,6 @@
|
|||||||
package se.su.dsv.scipro.report;
|
package se.su.dsv.scipro.report;
|
||||||
|
|
||||||
import java.io.Serializable;
|
public interface GradeCalculator {
|
||||||
|
|
||||||
public interface GradeCalculator extends Serializable {
|
|
||||||
GradingReport.Grade getGrade(GradingReport gradingReport);
|
GradingReport.Grade getGrade(GradingReport gradingReport);
|
||||||
|
|
||||||
long getPoints(GradingReport gradingReport);
|
long getPoints(GradingReport gradingReport);
|
||||||
|
@ -4,7 +4,6 @@ import org.apache.wicket.markup.html.WebMarkupContainer;
|
|||||||
import org.apache.wicket.markup.html.basic.Label;
|
import org.apache.wicket.markup.html.basic.Label;
|
||||||
import org.apache.wicket.markup.html.panel.Panel;
|
import org.apache.wicket.markup.html.panel.Panel;
|
||||||
import org.apache.wicket.model.IModel;
|
import org.apache.wicket.model.IModel;
|
||||||
import org.apache.wicket.model.LoadableDetachableModel;
|
|
||||||
import se.su.dsv.scipro.components.OppositeVisibility;
|
import se.su.dsv.scipro.components.OppositeVisibility;
|
||||||
import se.su.dsv.scipro.report.GradeCalculator;
|
import se.su.dsv.scipro.report.GradeCalculator;
|
||||||
import se.su.dsv.scipro.report.GradingReport;
|
import se.su.dsv.scipro.report.GradingReport;
|
||||||
@ -18,15 +17,13 @@ public class GradingReportPointsPanel extends Panel {
|
|||||||
public GradingReportPointsPanel(
|
public GradingReportPointsPanel(
|
||||||
String id,
|
String id,
|
||||||
final IModel<? extends GradingReport> gradingReportIModel,
|
final IModel<? extends GradingReport> gradingReportIModel,
|
||||||
final GradeCalculator gradeCalculator
|
final IModel<GradeCalculator> gradeCalculator
|
||||||
) {
|
) {
|
||||||
super(id, gradingReportIModel);
|
super(id, gradingReportIModel);
|
||||||
final IModel<GradingReport.Grade> gradeModel = new LoadableDetachableModel<>() {
|
final IModel<GradingReport.Grade> gradeModel = gradingReportIModel.combineWith(
|
||||||
@Override
|
gradeCalculator,
|
||||||
protected GradingReport.Grade load() {
|
GradingReport::getGrade
|
||||||
return gradingReportIModel.getObject().getGrade(gradeCalculator);
|
);
|
||||||
}
|
|
||||||
};
|
|
||||||
final Label grade = new Label(GRADE, gradeModel.map(GradingReport.Grade::name)) {
|
final Label grade = new Label(GRADE, gradeModel.map(GradingReport.Grade::name)) {
|
||||||
@Override
|
@Override
|
||||||
protected void onConfigure() {
|
protected void onConfigure() {
|
||||||
@ -36,12 +33,7 @@ public class GradingReportPointsPanel extends Panel {
|
|||||||
};
|
};
|
||||||
add(grade);
|
add(grade);
|
||||||
|
|
||||||
final IModel<Long> points = new LoadableDetachableModel<>() {
|
final IModel<Long> points = gradingReportIModel.combineWith(gradeCalculator, GradingReport::getPoints);
|
||||||
@Override
|
|
||||||
protected Long load() {
|
|
||||||
return gradingReportIModel.getObject().getPoints(gradeCalculator);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
add(new Label(POINTS_LABEL, points));
|
add(new Label(POINTS_LABEL, points));
|
||||||
|
|
||||||
add(new WebMarkupContainer(NO_GRADE_EXPLANATION).add(new OppositeVisibility(grade)));
|
add(new WebMarkupContainer(NO_GRADE_EXPLANATION).add(new OppositeVisibility(grade)));
|
||||||
|
@ -271,8 +271,8 @@ public class IndividualAuthorAssessmentPanel extends GenericPanel<User> {
|
|||||||
new TemplatePanel("points_to_grade_conversion", gradingReport.map(SupervisorGradingReport::getProject))
|
new TemplatePanel("points_to_grade_conversion", gradingReport.map(SupervisorGradingReport::getProject))
|
||||||
);
|
);
|
||||||
|
|
||||||
GradeCalculator supervisorCalculator = gradeCalculatorService.getSupervisorCalculator(
|
IModel<GradeCalculator> supervisorCalculator = LoadableDetachableModel.of(() ->
|
||||||
gradingReport.getObject().getProject()
|
gradeCalculatorService.getSupervisorCalculator(gradingReport.getObject().getProject())
|
||||||
);
|
);
|
||||||
add(new GradingReportPointsPanel("points", gradingReport, supervisorCalculator));
|
add(new GradingReportPointsPanel("points", gradingReport, supervisorCalculator));
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class GradingReportPointsPanelTest extends SciProTest {
|
|||||||
|
|
||||||
private void startPanel() {
|
private void startPanel() {
|
||||||
panel = tester.startComponentInPage(
|
panel = tester.startComponentInPage(
|
||||||
new GradingReportPointsPanel("id", Model.of(gradingReport), gradeCalculator)
|
new GradingReportPointsPanel("id", Model.of(gradingReport), () -> gradeCalculator)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user