Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b620887
Added toggle to general info unit
dboschm Apr 20, 2018
a16f0a7
Added match expression to unit populate for visible flag
dboschm Apr 21, 2018
8e10609
now Unit is also visible if the visible flag is undefined (for migrat…
dboschm Apr 21, 2018
819571c
clear imports
dboschm Apr 21, 2018
2102a8e
now TsLint conform
dboschm Apr 21, 2018
4956632
now TsLint Conform
dboschm Apr 21, 2018
189b024
Merge branch 'develop' into feature/#582-unit-visibility-toggle-2
dboschm Apr 21, 2018
1dfb54f
Merge branch 'develop' into feature/#582-unit-visibility-toggle-2
HPunktOchs Apr 23, 2018
2503019
Merge branch 'develop' into feature/#582-unit-visibility-toggle-2
PatrickSkowronek Apr 23, 2018
b72e5fc
revert
dboschm Apr 25, 2018
189c4a5
Merge remote-tracking branch 'origin/feature/#582-unit-visibility-tog…
dboschm Apr 25, 2018
e81a100
revert package-lock json
dboschm Apr 25, 2018
7feedfb
Merge branch 'develop' into feature/#582-unit-visibility-toggle-2
PatrickSkowronek Apr 25, 2018
a0c1c70
Merge branch 'develop' into feature/#582-unit-visibility-toggle-2
dboschm Apr 26, 2018
4a55af4
Changelog entry added
dboschm Apr 27, 2018
f842977
update visibility match to course model funciton populate lectures fo…
dboschm Apr 27, 2018
b7e9571
Merge branch 'develop' into feature/#582-unit-visibility-toggle-2
dboschm Apr 27, 2018
a23d961
default for units is now visible, so that is impossible to set visibl…
dboschm Apr 27, 2018
4d41934
now lint conform
dboschm Apr 27, 2018
2e3a21d
Merge branch 'develop' into feature/#582-unit-visibility-toggle-2
dboschm Apr 30, 2018
c2a2c3f
Merge branch 'develop' into feature/#582-unit-visibility-toggle-2
dboschm May 2, 2018
b297202
Merge branch 'develop' into feature/#582-unit-visibility-toggle-2
PatrickSkowronek May 4, 2018
03e7305
Merge branch 'develop' into feature/#582-unit-visibility-toggle-2
PatrickSkowronek May 4, 2018
a9c45aa
Merge branch 'develop' into feature/#582-unit-visibility-toggle-2
PatrickSkowronek May 4, 2018
b986bf5
Revert package-lock.json
May 4, 2018
18e8896
Merge remote-tracking branch 'origin/feature/#582-unit-visibility-tog…
May 4, 2018
ae06257
Fixed something missing after merge
May 4, 2018
91c9a1b
Added indicator for not visible unit
May 4, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed wording of progress display on profile page. [#715](https://github.com/h-da/geli/issues/715)
- Fixed form validator in create task [#579](https://github.com/h-da/geli/issues/579)

### Added
- Unit visibility toggle [#582](https://github.com/h-da/geli/issues/582)

### Security
- Fixed numerous severe user related security issues. [#691](https://github.com/h-da/geli/issues/691) [#709](https://github.com/h-da/geli/pull/709)
- Fixed multiple severe course related security issues. [#594](https://github.com/h-da/geli/issues/594) [#653](https://github.com/h-da/geli/issues/653) [#691](https://github.com/h-da/geli/issues/691)
Expand Down
1 change: 0 additions & 1 deletion api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions api/src/controllers/CourseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,9 @@ export class CourseController {
@Authorized(['teacher', 'admin'])
@Post('/:id/whitelist')
async whitelistStudents(
@Param('id') id: string,
@UploadedFile('file', {options: uploadOptions}) file: any,
@CurrentUser() currentUser: IUser) {
@Param('id') id: string,
@UploadedFile('file', {options: uploadOptions}) file: any,
@CurrentUser() currentUser: IUser) {
const name: string = file.originalname;
if (!name.endsWith('.csv')) {
throw new TypeError(errorCodes.upload.type.notCSV.code);
Expand Down
10 changes: 6 additions & 4 deletions api/src/models/Course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const courseSchema = new mongoose.Schema({
ref: 'User'
},
media:
{
type: mongoose.Schema.Types.ObjectId,
ref: 'Directory'
},
{
type: mongoose.Schema.Types.ObjectId,
ref: 'Directory'
},
teachers: [
{
type: mongoose.Schema.Types.ObjectId,
Expand Down Expand Up @@ -253,11 +253,13 @@ courseSchema.methods.forView = function (): ICourseView {
};

courseSchema.methods.populateLecturesFor = function (user: IUser) {
const isTeacherOrAdmin = (user.role === 'teacher' || user.role === 'admin');
return this.populate({
path: 'lectures',
populate: {
path: 'units',
virtuals: true,
match: {$or: [{visible: undefined}, {visible: true}, {visible: !isTeacherOrAdmin}]},
populate: {
path: 'progressData',
match: {user: {$eq: user._id}}
Expand Down
3 changes: 3 additions & 0 deletions api/src/models/units/Unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const unitSchema = new mongoose.Schema({
type: {
type: String
},
visible: {
type: Boolean
},
unitCreator: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
Expand Down
1 change: 0 additions & 1 deletion app/webFrontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions app/webFrontend/src/app/course/course.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@
<mat-icon color="warn">visibility_off</mat-icon>
</button>
</span>
<span class="course-admin-actions" *ngIf="course.userCanEditCourse">
<button mat-icon-button (click)="editCourse(course._id)">
<mat-icon>mode_edit</mat-icon>
</button>

<button mat-icon-button (click)="showReport(course._id)">
<mat-icon>show_chart</mat-icon>
</button>

<button mat-icon-button *ngIf="!course.active" disabled>
<mat-icon color="warn">visibility_off</mat-icon>
</button>
</span>
<span class="course-student-actions" *ngIf="this.userService.isStudent()">
<div style="float:left">
<i class="material-icons" style="margin-top: 8px;"
Expand Down
2 changes: 2 additions & 0 deletions app/webFrontend/src/app/models/units/CodeKataUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class CodeKataUnit implements ICodeKataUnit {
weight: number;
updatedAt: string;
createdAt: string;
visible: boolean;

definition: string;
code: string;
Expand All @@ -25,4 +26,5 @@ export class CodeKataUnit implements ICodeKataUnit {
this.weight = 0;
this.__t = 'code-kata';
}

}
2 changes: 2 additions & 0 deletions app/webFrontend/src/app/models/units/FileUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class FileUnit implements IFileUnit {
weight: number;
updatedAt: string;
createdAt: string;
visible: boolean;
unitCreator: any;

files: IFile[] = [];
Expand All @@ -25,4 +26,5 @@ export class FileUnit implements IFileUnit {
this.progressable = false;
this.weight = 0;
}

}
1 change: 1 addition & 0 deletions app/webFrontend/src/app/models/units/FreeTextUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class FreeTextUnit implements IFreeTextUnit {
__t: string;
progressable: boolean;
weight: number;
visible: boolean;
unitCreator: any;

markdown: string;
Expand Down
1 change: 1 addition & 0 deletions app/webFrontend/src/app/models/units/TaskUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class TaskUnit implements ITaskUnit {
__t: string;
progressable: boolean;
weight: number;
visible: boolean;
unitCreator: any;

tasks: ITask[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class CodeKataUnitFormComponent implements OnInit {
name: this.generalInfo.form.value.name,
description: this.generalInfo.form.value.description,
deadline: this.generalInfo.form.value.deadline,
visible: this.generalInfo.form.value.visible
};

if (this.model._id === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export class FileUnitFormComponent implements OnInit {
this.model = {
...this.model,
name: this.generalInfo.form.value.name,
description: this.generalInfo.form.value.description
description: this.generalInfo.form.value.description,
visible: this.generalInfo.form.value.visible

};

const reqObj = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class FreeTextUnitFormComponent implements OnInit {
...this.model,
name: this.generalInfo.form.value.name,
description: this.generalInfo.form.value.description,
visible: this.generalInfo.form.value.visible,

markdown: this.freeTextEditor.markdown
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class TaskUnitEditComponent implements OnInit {
name: this.generalInfo.form.value.name,
description: this.generalInfo.form.value.description,
deadline: this.generalInfo.form.value.deadline,
visible: this.generalInfo.form.value.visible
};

if (this.isTaskUnitValid()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@
<mat-datepicker-toggle matSuffix [for]="deadlineDatepicker"></mat-datepicker-toggle>
<mat-datepicker #deadlineDatepicker (selectedChanged)="updateDateTime($event)"></mat-datepicker>
</mat-form-field>

<div>
<mat-slide-toggle formControlName="visible">
<span *ngIf="form.value.visible">Unit can be seen by students</span>
<span *ngIf="!form.value.visible">Unit cannot be seen by students</span>
</mat-slide-toggle>
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ export class UnitGeneralInfoFormComponent implements OnInit {
}

ngOnInit() {
if (this.model !== null && this.model !== undefined && this.model.visible === undefined) {
this.model.visible = true;
}
this.form = this.formBuilder.group({
name: [this.model ? this.model.name : '', Validators.required],
description: [this.model ? this.model.description : ''],
deadline: [this.model ? this.model.deadline : '']
deadline: [this.model ? this.model.deadline : ''],
visible: [this.model ? this.model.visible : false]
});
}

Expand Down
11 changes: 8 additions & 3 deletions app/webFrontend/src/app/unit/unit.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<div *ngFor="let unit of units;">
<mat-card class="unit-card">
<button mat-icon-button *ngIf="unit.visible === false" disabled>
<mat-icon color="warn">visibility_off</mat-icon>
</button>
<mat-card-title class="unit-card-title">
{{unit.name}}
</mat-card-title>
Expand All @@ -19,9 +22,11 @@
<app-code-kata *ngSwitchCase="'code-kata'" [codeKataUnit]="unit"></app-code-kata>
<app-free-text-unit *ngSwitchCase="'free-text'" [freeTextUnit]="unit"></app-free-text-unit>
<div class="unit-detail">
<div class="user-detail" *ngIf="unit.unitCreator">{{unit.unitCreator.profile.firstName + ' ' + unit.unitCreator.profile.lastName}}</div>
<span *ngIf="unit.createdAt === unit.updatedAt">Published on: {{getFormattedDate(unit.createdAt)}}</span>
<span *ngIf="unit.createdAt !== unit.updatedAt">Changed on: {{getFormattedDate(unit.updatedAt)}}</span>
<div class="user-detail" *ngIf="unit.unitCreator">{{unit.unitCreator.profile.firstName + ' ' +
unit.unitCreator.profile.lastName}}
</div>
<span *ngIf="unit.createdAt === unit.updatedAt">Published on: {{getFormattedDate(unit.createdAt)}}</span>
<span *ngIf="unit.createdAt !== unit.updatedAt">Changed on: {{getFormattedDate(unit.updatedAt)}}</span>
</div>
</mat-card-content>
</mat-card>
Expand Down
1 change: 1 addition & 0 deletions shared/models/units/IUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export interface IUnit {
updatedAt: string;
createdAt: string;
unitCreator: IUser;
visible: boolean;
__t: string;
}