Skip to content

Commit

Permalink
Feature/grading instructions/display sgi in assessment view fix (ls1i…
Browse files Browse the repository at this point in the history
  • Loading branch information
HanyaElhashemy authored Apr 20, 2020
1 parent 1cadf45 commit 84c84d7
Show file tree
Hide file tree
Showing 38 changed files with 303 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public ResponseEntity<Exercise> getExercise(@PathVariable Long exerciseId) {

User user = userService.getUserWithGroupsAndAuthorities();
Exercise exercise = exerciseService.findOneWithCategories(exerciseId);

List<GradingCriterion> gradingCriteria = gradingCriterionService.findByExerciseIdWithEagerGradingCriteria(exerciseId);
exercise.setGradingCriteria(gradingCriteria);
if (!authCheckService.isAllowedToSeeExercise(exercise, user)) {
return forbidden();
}
Expand Down Expand Up @@ -142,6 +143,9 @@ public ResponseEntity<Exercise> getExerciseForTutorDashboard(@PathVariable Long
exampleSubmissions.removeIf(exampleSubmission -> exampleSubmission.getSubmission().getResult() == null);
exercise.setExampleSubmissions(new HashSet<>(exampleSubmissions));

List<GradingCriterion> gradingCriteria = gradingCriterionService.findByExerciseIdWithEagerGradingCriteria(exerciseId);
exercise.setGradingCriteria(gradingCriteria);

TutorParticipation tutorParticipation = tutorParticipationService.findByExerciseAndTutor(exercise, user);
if (exampleSubmissions.size() == 0 && tutorParticipation.getStatus().equals(TutorParticipationStatus.REVIEWED_INSTRUCTIONS)) {
tutorParticipation.setStatus(TutorParticipationStatus.TRAINED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,19 @@ public class FileUploadSubmissionResource {

private final ParticipationService participationService;

private final GradingCriterionService gradingCriterionService;

public FileUploadSubmissionResource(CourseService courseService, FileUploadSubmissionService fileUploadSubmissionService, FileUploadExerciseService fileUploadExerciseService,
AuthorizationCheckService authCheckService, UserService userService, ExerciseService exerciseService, ParticipationService participationService) {
AuthorizationCheckService authCheckService, UserService userService, ExerciseService exerciseService, ParticipationService participationService,
GradingCriterionService gradingCriterionService) {
this.userService = userService;
this.exerciseService = exerciseService;
this.courseService = courseService;
this.fileUploadSubmissionService = fileUploadSubmissionService;
this.fileUploadExerciseService = fileUploadExerciseService;
this.authCheckService = authCheckService;
this.participationService = participationService;
this.gradingCriterionService = gradingCriterionService;
}

/**
Expand Down Expand Up @@ -142,13 +146,16 @@ public ResponseEntity<FileUploadSubmission> getFileUploadSubmission(@PathVariabl
var fileUploadSubmission = fileUploadSubmissionService.findOne(submissionId);
var studentParticipation = (StudentParticipation) fileUploadSubmission.getParticipation();
var fileUploadExercise = (FileUploadExercise) studentParticipation.getExercise();
List<GradingCriterion> gradingCriteria = gradingCriterionService.findByExerciseIdWithEagerGradingCriteria(fileUploadExercise.getId());
fileUploadExercise.setGradingCriteria(gradingCriteria);
User user = userService.getUserWithGroupsAndAuthorities();
if (!authCheckService.isAtLeastTeachingAssistantForExercise(fileUploadExercise, user)) {
return forbidden();
}
fileUploadSubmission = fileUploadSubmissionService.getLockedFileUploadSubmission(submissionId, fileUploadExercise);
// Make sure the exercise is connected to the participation in the json response
studentParticipation.setExercise(fileUploadExercise);
fileUploadSubmission.getParticipation().getExercise().setGradingCriteria(gradingCriteria);
this.fileUploadSubmissionService.hideDetails(fileUploadSubmission, user);
return ResponseEntity.ok(fileUploadSubmission);
}
Expand Down Expand Up @@ -216,6 +223,8 @@ public ResponseEntity<FileUploadSubmission> getFileUploadSubmissionWithoutAssess
@RequestParam(value = "lock", defaultValue = "false") boolean lockSubmission) {
log.debug("REST request to get a file upload submission without assessment");
final Exercise fileUploadExercise = exerciseService.findOneWithAdditionalElements(exerciseId);
List<GradingCriterion> gradingCriteria = gradingCriterionService.findByExerciseIdWithEagerGradingCriteria(exerciseId);
fileUploadExercise.setGradingCriteria(gradingCriteria);
final User user = userService.getUserWithGroupsAndAuthorities();
if (!authCheckService.isAtLeastTeachingAssistantForExercise(fileUploadExercise, user)) {
return forbidden();
Expand Down Expand Up @@ -248,6 +257,7 @@ public ResponseEntity<FileUploadSubmission> getFileUploadSubmissionWithoutAssess
// Make sure the exercise is connected to the participation in the json response
final StudentParticipation studentParticipation = (StudentParticipation) fileUploadSubmission.getParticipation();
studentParticipation.setExercise(fileUploadExercise);
fileUploadSubmission.getParticipation().getExercise().setGradingCriteria(gradingCriteria);
this.fileUploadSubmissionService.hideDetails(fileUploadSubmission, user);
return ResponseEntity.ok(fileUploadSubmission);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ public class ModelingSubmissionResource {

private final UserService userService;

private final GradingCriterionService gradingCriterionService;

public ModelingSubmissionResource(ModelingSubmissionService modelingSubmissionService, ModelingExerciseService modelingExerciseService,
ParticipationService participationService, CourseService courseService, AuthorizationCheckService authCheckService, CompassService compassService,
ExerciseService exerciseService, UserService userService) {
ExerciseService exerciseService, UserService userService, GradingCriterionService gradingCriterionService) {
this.modelingSubmissionService = modelingSubmissionService;
this.modelingExerciseService = modelingExerciseService;
this.participationService = participationService;
Expand All @@ -72,6 +74,7 @@ public ModelingSubmissionResource(ModelingSubmissionService modelingSubmissionSe
this.compassService = compassService;
this.exerciseService = exerciseService;
this.userService = userService;
this.gradingCriterionService = gradingCriterionService;
}

/**
Expand Down Expand Up @@ -192,14 +195,16 @@ public ResponseEntity<ModelingSubmission> getModelingSubmission(@PathVariable Lo
ModelingSubmission modelingSubmission = modelingSubmissionService.findOne(submissionId);
final StudentParticipation studentParticipation = (StudentParticipation) modelingSubmission.getParticipation();
final ModelingExercise modelingExercise = (ModelingExercise) studentParticipation.getExercise();
List<GradingCriterion> gradingCriteria = gradingCriterionService.findByExerciseIdWithEagerGradingCriteria(modelingExercise.getId());
modelingExercise.setGradingCriteria(gradingCriteria);
final User user = userService.getUserWithGroupsAndAuthorities();
if (!authCheckService.isAtLeastTeachingAssistantForExercise(modelingExercise, user)) {
return forbidden();
}
modelingSubmission = modelingSubmissionService.getLockedModelingSubmission(submissionId, modelingExercise);
// Make sure the exercise is connected to the participation in the json response

studentParticipation.setExercise(modelingExercise);
modelingSubmission.getParticipation().getExercise().setGradingCriteria(gradingCriteria);
this.modelingSubmissionService.hideDetails(modelingSubmission, user);
return ResponseEntity.ok(modelingSubmission);
}
Expand All @@ -217,6 +222,8 @@ public ResponseEntity<ModelingSubmission> getModelingSubmissionWithoutAssessment
@RequestParam(value = "lock", defaultValue = "false") boolean lockSubmission) {
log.debug("REST request to get a modeling submission without assessment");
final Exercise exercise = exerciseService.findOneWithAdditionalElements(exerciseId);
List<GradingCriterion> gradingCriteria = gradingCriterionService.findByExerciseIdWithEagerGradingCriteria(exerciseId);
exercise.setGradingCriteria(gradingCriteria);
final User user = userService.getUserWithGroupsAndAuthorities();
if (!authCheckService.isAtLeastTeachingAssistantForExercise(exercise, user)) {
return forbidden();
Expand Down Expand Up @@ -248,6 +255,7 @@ public ResponseEntity<ModelingSubmission> getModelingSubmissionWithoutAssessment
// Make sure the exercise is connected to the participation in the json response
final StudentParticipation studentParticipation = (StudentParticipation) modelingSubmission.getParticipation();
studentParticipation.setExercise(exercise);
modelingSubmission.getParticipation().getExercise().setGradingCriteria(gradingCriteria);
this.modelingSubmissionService.hideDetails(modelingSubmission, user);
return ResponseEntity.ok(modelingSubmission);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ public class TextAssessmentResource extends AssessmentResource {

private final Optional<AutomaticTextFeedbackService> automaticTextFeedbackService;

private final GradingCriterionService gradingCriterionService;

public TextAssessmentResource(AuthorizationCheckService authCheckService, ResultService resultService, TextAssessmentService textAssessmentService,
TextBlockService textBlockService, TextBlockRepository textBlockRepository, TextExerciseService textExerciseService, TextSubmissionRepository textSubmissionRepository,
UserService userService, TextSubmissionService textSubmissionService, WebsocketMessagingService messagingService, ExerciseService exerciseService,
Optional<AutomaticTextFeedbackService> automaticTextFeedbackService, ResultRepository resultRepository) {
Optional<AutomaticTextFeedbackService> automaticTextFeedbackService, ResultRepository resultRepository, GradingCriterionService gradingCriterionService) {
super(authCheckService, userService, exerciseService, textSubmissionService, textAssessmentService, resultRepository);

this.resultService = resultService;
Expand All @@ -78,6 +80,7 @@ public TextAssessmentResource(AuthorizationCheckService authCheckService, Result
this.textSubmissionService = textSubmissionService;
this.messagingService = messagingService;
this.automaticTextFeedbackService = automaticTextFeedbackService;
this.gradingCriterionService = gradingCriterionService;
}

/**
Expand Down Expand Up @@ -275,6 +278,8 @@ public ResponseEntity<Participation> retrieveParticipationForSubmission(@PathVar
final User user = userService.getUserWithGroupsAndAuthorities();
final Participation participation = textSubmission.getParticipation();
final TextExercise exercise = (TextExercise) participation.getExercise();
List<GradingCriterion> gradingCriteria = gradingCriterionService.findByExerciseIdWithEagerGradingCriteria(exercise.getId());
exercise.setGradingCriteria(gradingCriteria);
checkAuthorization(exercise, user);
final boolean isAtLeastInstructorForExercise = authCheckService.isAtLeastInstructorForExercise(exercise, user);
final boolean computeFeedbackSuggestions = automaticTextFeedbackService.isPresent() && exercise.isAutomaticAssessmentEnabled();
Expand Down Expand Up @@ -327,6 +332,7 @@ public ResponseEntity<Participation> retrieveParticipationForSubmission(@PathVar
if (textSubmission.getBlocks() == null || !isInitialized(textSubmission.getBlocks()) || textSubmission.getBlocks().isEmpty()) {
textBlockService.computeTextBlocksForSubmissionBasedOnSyntax(textSubmission);
}
textSubmission.getParticipation().getExercise().setGradingCriteria(gradingCriteria);

if (!isAtLeastInstructorForExercise && participation instanceof StudentParticipation) {
final StudentParticipation studentParticipation = (StudentParticipation) participation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ public class TextSubmissionResource {

private final UserService userService;

private final GradingCriterionService gradingCriterionService;

public TextSubmissionResource(TextSubmissionRepository textSubmissionRepository, ExerciseService exerciseService, TextExerciseService textExerciseService,
CourseService courseService, AuthorizationCheckService authorizationCheckService, TextSubmissionService textSubmissionService, UserService userService) {
CourseService courseService, AuthorizationCheckService authorizationCheckService, TextSubmissionService textSubmissionService, UserService userService,
GradingCriterionService gradingCriterionService) {
this.textSubmissionRepository = textSubmissionRepository;
this.exerciseService = exerciseService;
this.textExerciseService = textExerciseService;
this.courseService = courseService;
this.authorizationCheckService = authorizationCheckService;
this.textSubmissionService = textSubmissionService;
this.userService = userService;
this.gradingCriterionService = gradingCriterionService;
}

/**
Expand Down Expand Up @@ -197,7 +201,8 @@ public ResponseEntity<TextSubmission> getTextSubmissionWithoutAssessment(@PathVa
@RequestParam(value = "lock", defaultValue = "false") boolean lockSubmission) {
log.debug("REST request to get a text submission without assessment");
Exercise exercise = exerciseService.findOneWithAdditionalElements(exerciseId);

List<GradingCriterion> gradingCriteria = gradingCriterionService.findByExerciseIdWithEagerGradingCriteria(exerciseId);
exercise.setGradingCriteria(gradingCriteria);
if (!authorizationCheckService.isAtLeastTeachingAssistantForExercise(exercise)) {
return forbidden();
}
Expand Down Expand Up @@ -228,6 +233,7 @@ public ResponseEntity<TextSubmission> getTextSubmissionWithoutAssessment(@PathVa
// Make sure the exercise is connected to the participation in the json response
final StudentParticipation studentParticipation = (StudentParticipation) textSubmission.getParticipation();
studentParticipation.setExercise(exercise);
textSubmission.getParticipation().getExercise().setGradingCriteria(gradingCriteria);
textSubmissionService.hideDetails(textSubmission, userService.getUserWithGroupsAndAuthorities());
return ResponseEntity.ok(textSubmission);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="card mb-3">
<div (drop)="drop($event)" (dragover)="allowDrop($event)" class="card mb-3">
<div class="card-header" [class.color-cyan]="assessment.type == FeedbackType_AUTOMATIC">
<fa-icon [icon]="'trash-alt'" class="float-right" (click)="delete()" *ngIf="!disabled"></fa-icon>
<h4 *ngIf="block?.text || assessment.reference" class="card-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,26 @@ export class AssessmentDetailComponent {
public get sanitizedText(): string {
return sanitize(this.text);
}
/**
* Allows the drop of an SGI Element
*/
allowDrop(event: DragEvent) {
event.preventDefault();
}
/**
* Connects the SGI with the Feedback of a Submission Element
* @param {Event} event - The drop event
* the SGI element sent on drag in processed in this method
* the corresponding drag method is in StructuredGradingInstructionsAssessmentLayoutComponent
*/
drop(event: any) {
event.preventDefault();
const data = event.dataTransfer.getData('text');
const instruction = JSON.parse(data);
const credits = instruction.credits;
const feedback = instruction.feedback;
this.assessment.credits = credits;
this.assessment.detailText = feedback;
this.assessmentChange.emit(this.assessment);
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
<h4 jhiTranslate="artemisApp.assessment.generalFeedback">General Feedback</h4>
<textarea class="form-control" rows="2" maxlength="5000" [ngModel]="text" (ngModelChange)="onTextChange($event)"></textarea>
<div class="row mt-2">
<h4 class="col-12" jhiTranslate="artemisApp.assessment.generalFeedback">General Feedback</h4>
<div class="col-12 col-lg-8 col-xl-6">
<textarea ondrop="return false;" class="form-control" rows="2" maxlength="5000" [ngModel]="text" (ngModelChange)="onTextChange($event)"></textarea>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { ArtemisProgrammingExerciseInstructionsRenderModule } from 'app/exercise
import { ExpandableSectionComponent } from './expandable-section/expandable-section.component';
import { CollapsableAssessmentInstructionsComponent } from './collapsable-assessment-instructions/collapsable-assessment-instructions.component';
import { AssessmentInstructionsComponent } from './assessment-instructions/assessment-instructions.component';
import { ArtemisAssessmentSharedModule } from 'app/assessment/assessment-shared.module';
import { StructuredGradingInstructionsAssessmentLayoutComponent } from 'app/assessment/structured-grading-instructions-assessment-layout/structured-grading-instructions-assessment-layout.component';

@NgModule({
imports: [CommonModule, NgbModule, ArtemisSharedModule, ArtemisModelingEditorModule, ArtemisProgrammingExerciseInstructionsRenderModule],
declarations: [ExpandableSectionComponent, AssessmentInstructionsComponent, CollapsableAssessmentInstructionsComponent],
exports: [CollapsableAssessmentInstructionsComponent, AssessmentInstructionsComponent],
imports: [CommonModule, NgbModule, ArtemisSharedModule, ArtemisModelingEditorModule, ArtemisProgrammingExerciseInstructionsRenderModule, ArtemisAssessmentSharedModule],
declarations: [ExpandableSectionComponent, AssessmentInstructionsComponent, CollapsableAssessmentInstructionsComponent, StructuredGradingInstructionsAssessmentLayoutComponent],
exports: [CollapsableAssessmentInstructionsComponent, ExpandableSectionComponent, StructuredGradingInstructionsAssessmentLayoutComponent, AssessmentInstructionsComponent],
})
export class AssessmentInstructionsModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ <h3>{{ exercise.title }}</h3>

<jhi-expandable-section headerKey="assessmentInstructions.gradingCriteria">
<p class="markdown-preview" [innerHTML]="gradingInstructions"></p>
<jhi-structured-grading-instructions-assessment-layout [criteria]="criteria"></jhi-structured-grading-instructions-assessment-layout>
</jhi-expandable-section>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { TextExercise } from 'app/entities/text-exercise.model';
import { ModelingExercise } from 'app/entities/modeling-exercise.model';
import { FileUploadExercise } from 'app/entities/file-upload-exercise.model';
import { ProgrammingExercise } from 'app/entities/programming-exercise.model';
import { GradingCriterion } from 'app/exercises/shared/structured-grading-criterion/grading-criterion.model';

@Component({
selector: 'jhi-assessment-instructions',
Expand All @@ -20,6 +21,7 @@ export class AssessmentInstructionsComponent {
sampleSolution?: SafeHtml;
sampleSolutionModel?: UMLModel;
sampleSolutionDiagramType?: UMLDiagramType;
criteria: GradingCriterion[];

readonly ExerciseType = ExerciseType;

Expand All @@ -29,6 +31,7 @@ export class AssessmentInstructionsComponent {
this.exercise = exercise;
this.problemStatement = this.markdownService.safeHtmlForMarkdown(exercise.problemStatement);
this.gradingInstructions = this.markdownService.safeHtmlForMarkdown(exercise.gradingInstructions);
this.criteria = exercise.gradingCriteria;

let sampleSolutionMarkdown: string | undefined;
switch (exercise.type) {
Expand Down
Loading

0 comments on commit 84c84d7

Please sign in to comment.