Skip to content

Commit

Permalink
CSCEXAM-1209 Modify visibility of external tags for teachers
Browse files Browse the repository at this point in the history
  • Loading branch information
Matti Lupari committed Nov 26, 2023
1 parent 68fd1f9 commit e14b67e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/QuestionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public Result getQuestion(Long id, Http.Request request) {
Query<Question> query = DB.find(Question.class);
PathProperties pp = PathProperties.parse(
"(*, questionOwners(id, firstName, lastName, userIdentifier, email), " +
"attachment(id, fileName), options(id, correctOption, defaultScore, option, claimChoiceType), tags(id, name), " +
"attachment(id, fileName), options(id, correctOption, defaultScore, option, claimChoiceType), tags(id, name, creator(id)), " +
"examSectionQuestions(id, examSection(name, exam(name, state))))"
);
pp.apply(query);
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/exam/exam.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export interface ReverseQuestion extends Question {
export interface Tag {
id?: number;
name: string;
creator?: User;
}

export interface Question {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ export class LibraryResultsComponent implements OnInit, OnChanges {
return user;
};

printTags = (question: LibraryQuestion) => question.tags.map((t) => t.name.toUpperCase()).join(', ');
printTags = (question: LibraryQuestion) => {
const ownTags = question.tags.filter((t) => t.creator?.id === this.user.id);
return ownTags.map((t) => t.name).join(', ');
};

pageSelected = (event: { page: number }) => (this.currentPage = event.page);

Expand Down
14 changes: 10 additions & 4 deletions ui/src/app/question/tags/tag-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
* See the Licence for the specific language governing permissions and limitations under the Licence.
*/
import { HttpClient } from '@angular/common/http';
import { Component, Input } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import type { NgbTypeaheadSelectItemEvent } from '@ng-bootstrap/ng-bootstrap';
import type { Observable } from 'rxjs';
import { from } from 'rxjs';
import { debounceTime, distinctUntilChanged, exhaustMap, map } from 'rxjs/operators';
import { SessionService } from 'src/app/session/session.service';
import type { Question, Tag } from '../../exam/exam.model';
import { QuestionDraft } from '../question.service';

Expand Down Expand Up @@ -61,7 +62,7 @@ import { QuestionDraft } from '../question.service';
</div>
<div class="col">
<ul class="list-inline mart10">
<li *ngFor="let tag of question.tags" class="list-inline-item">
<li *ngFor="let tag of ownTags" class="list-inline-item">
{{ tag.name }}
<button
class="reviewer-remove"
Expand All @@ -80,12 +81,17 @@ import { QuestionDraft } from '../question.service';
</form>
`,
})
export class TagPickerComponent {
export class TagPickerComponent implements OnInit {
@Input() question!: Question | QuestionDraft;
tagName = '';
newTag: Tag = { name: '' };
ownTags: Tag[] = [];

constructor(private http: HttpClient) {}
constructor(private http: HttpClient, private Session: SessionService) {}

ngOnInit() {
this.ownTags = this.question.tags.filter((t) => t.creator?.id === this.Session.getUser().id);
}

getTags$ = (text$: Observable<string>): Observable<Tag[]> =>
text$.pipe(
Expand Down

0 comments on commit e14b67e

Please sign in to comment.