Skip to content

Commit

Permalink
Communication: Create channels for test-exams (#7171)
Browse files Browse the repository at this point in the history
  • Loading branch information
lennart-keller authored Sep 14, 2023
1 parent 9e8bd09 commit d3075d0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ public Channel createExerciseChannel(Exercise exercise, Optional<String> channel
* @return the created channel
*/
public Channel createExamChannel(Exam exam, Optional<String> channelName) {
if (exam.isTestExam()) {
return null;
}
Channel channelToCreate = createDefaultChannel(channelName, "exam-", exam.getTitle());
channelToCreate.setIsPublic(false);
channelToCreate.setExam(exam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class ExamUpdateComponent implements OnInit {
next: (response: HttpResponse<Course>) => {
this.exam.course = response.body!;
this.course = response.body!;
this.hideChannelNameInput = exam.testExam || (exam.id !== undefined && exam.channelName === undefined) || !isMessagingEnabled(this.course);
this.hideChannelNameInput = (exam.id !== undefined && exam.channelName === undefined) || !isMessagingEnabled(this.course);
},
error: (err: HttpErrorResponse) => onError(this.alertService, err),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1028,9 +1028,12 @@ private List<Exam> createExamsWithInvalidDates(Course course) {
void testCreateTestExam_asInstructor() throws Exception {
// Test the creation of a test exam
Exam examA = ExamFactory.generateTestExam(course1);
request.post("/api/courses/" + course1.getId() + "/exams", examA, HttpStatus.CREATED);
URI examUri = request.post("/api/courses/" + course1.getId() + "/exams", examA, HttpStatus.CREATED);
Exam savedExam = request.get(String.valueOf(examUri), HttpStatus.OK, Exam.class);

verify(examAccessService).checkCourseAccessForInstructorElseThrow(course1.getId());
Channel channelFromDB = channelRepository.findChannelByExamId(savedExam.getId());
assertThat(channelFromDB).isNotNull();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { of, throwError } from 'rxjs';
import { RouterTestingModule } from '@angular/router/testing';
import { FormsModule } from '@angular/forms';
import { FontAwesomeTestingModule } from '@fortawesome/angular-fontawesome/testing';
import { Course } from 'app/entities/course.model';
import { Course, CourseInformationSharingConfiguration } from 'app/entities/course.model';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { FormDateTimePickerComponent } from 'app/shared/date-time-picker/date-time-picker.component';
import { MarkdownEditorComponent } from 'app/shared/markdown-editor/markdown-editor.component';
Expand Down Expand Up @@ -57,6 +57,7 @@ describe('Exam Update Component', () => {

const course = new Course();
course.id = 1;
course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING;
const routes = [
{ path: 'course-management/:courseId/exams/:examId', component: DummyComponent },
{ path: 'course-management/:courseId/exams', component: DummyComponent },
Expand Down Expand Up @@ -211,6 +212,14 @@ describe('Exam Update Component', () => {
expect(component.isValidConfiguration).toBeFalse();
});

it('should show channel name input for test exams', fakeAsync(() => {
examWithoutExercises.testExam = true;
examWithoutExercises.channelName = 'test-exam';
component.ngOnInit();
tick();
expect(component.hideChannelNameInput).toBeFalse();
}));

it('should validate the example solution publication date correctly', () => {
const newExamWithoutExercises = new Exam();
newExamWithoutExercises.id = 2;
Expand Down

0 comments on commit d3075d0

Please sign in to comment.