-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
288 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
3 changes: 3 additions & 0 deletions
3
src/app/multiple-choice-question/multiple-choice-question.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
<p>multiple-choice-question works!</p> | ||
|
25 changes: 25 additions & 0 deletions
25
src/app/multiple-choice-question/multiple-choice-question.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { MultipleChoiceQuestionComponent } from './multiple-choice-question.component'; | ||
|
||
describe('MultipleChoiceQuestionComponent', () => { | ||
let component: MultipleChoiceQuestionComponent; | ||
let fixture: ComponentFixture<MultipleChoiceQuestionComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ MultipleChoiceQuestionComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(MultipleChoiceQuestionComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
src/app/multiple-choice-question/multiple-choice-question.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {Component, Input, OnInit} from '@angular/core'; | ||
// import {faCheck, faTimes} from '@fortawesome/free-solid-svg-icons'; | ||
|
||
|
||
@Component({ | ||
selector: 'app-multiple-choice-question', | ||
templateUrl: './multiple-choice-question.component.html', | ||
styleUrls: ['./multiple-choice-question.component.css'] | ||
}) | ||
export class MultipleChoiceQuestionComponent implements OnInit { | ||
|
||
@Input() | ||
question = {_id: '', title: '', question: '', choices: [], correct: '', answer: '' }; | ||
grading = false; | ||
// faCheck = faCheck; faTimes = faTimes; | ||
|
||
grade = () => { this.grading = true; }; | ||
|
||
constructor() { } | ||
|
||
ngOnInit(): void { | ||
|
||
} | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<p>quiz works!</p> | ||
<ul class="list-group"> | ||
<li *ngFor="let question of questions" class="list-group-item"> | ||
<div [ngSwitch]="question.type"> | ||
<app-multiple-choice-question | ||
[question]="question" | ||
*ngSwitchCase="'MULTIPLE_CHOICE'"></app-multiple-choice-question> | ||
<app-true-false-question | ||
[question]="question" | ||
*ngSwitchCase="'TRUE_FALSE'"></app-true-false-question> | ||
</div> | ||
</li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { QuizComponent } from './quiz.component'; | ||
|
||
describe('QuizComponent', () => { | ||
let component: QuizComponent; | ||
let fixture: ComponentFixture<QuizComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ QuizComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(QuizComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import {ActivatedRoute} from '@angular/router'; | ||
import {QuestionService} from '../../services/question-service'; | ||
|
||
@Component({ | ||
selector: 'app-quiz', | ||
templateUrl: './quiz.component.html', | ||
styleUrls: ['./quiz.component.css'] | ||
}) | ||
export class QuizComponent implements OnInit { | ||
questions = []; | ||
quizId = ''; | ||
constructor(private svc: QuestionService, | ||
private route: ActivatedRoute | ||
) { } | ||
|
||
ngOnInit(): void { | ||
this.route.params.subscribe(ps => { | ||
console.log('ps', ps); | ||
this.quizId = ps.quizId; | ||
this.svc.findQuestionsForQuiz(this.quizId) | ||
.then(qs => this.questions = qs); | ||
}); | ||
|
||
} | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
<h2>Quizzes</h2> | ||
<ul class="list-group"> | ||
<li *ngFor="let quiz of quizzes" class="list-group-item"> | ||
<a routerLink="/courses/{{courseId}}/quizzes/{{quiz._id}}"> | ||
{{quiz.title}} | ||
</a> | ||
<a class="btn btn-primary float-right" | ||
routerLink="/courses/{{courseId}}/quizzes/{{quiz._id}}"> | ||
Start | ||
</a> | ||
</li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { QuizzesListComponent } from './quizzes-list.component'; | ||
|
||
describe('QuizzesListComponent', () => { | ||
let component: QuizzesListComponent; | ||
let fixture: ComponentFixture<QuizzesListComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ QuizzesListComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(QuizzesListComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import {ActivatedRoute} from '@angular/router'; | ||
import {QuizzesService} from '../../services/quizzes-service'; | ||
|
||
@Component({ | ||
selector: 'app-quizzes-list', | ||
templateUrl: './quizzes-list.component.html', | ||
styleUrls: ['./quizzes-list.component.css'] | ||
}) | ||
export class QuizzesListComponent implements OnInit { | ||
|
||
constructor(private service: QuizzesService, | ||
private route: ActivatedRoute) { } | ||
|
||
courseId = ''; | ||
quizzes = []; | ||
|
||
ngOnInit(): void { | ||
this.route.params.subscribe(params => { | ||
console.log('quizParams', params); | ||
this.courseId = params.courseId; | ||
this.service.findAllQuizzes() | ||
.then(quizzes => this.quizzes = quizzes); | ||
}); | ||
|
||
} | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>true-false-question works!</p> |
25 changes: 25 additions & 0 deletions
25
src/app/true-false-question/true-false-question.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TrueFalseQuestionComponent } from './true-false-question.component'; | ||
|
||
describe('TrueFalseQuestionComponent', () => { | ||
let component: TrueFalseQuestionComponent; | ||
let fixture: ComponentFixture<TrueFalseQuestionComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ TrueFalseQuestionComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TrueFalseQuestionComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
src/app/true-false-question/true-false-question.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-true-false-question', | ||
templateUrl: './true-false-question.component.html', | ||
styleUrls: ['./true-false-question.component.css'] | ||
}) | ||
export class TrueFalseQuestionComponent implements OnInit { | ||
|
||
constructor() { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {Injectable} from '@angular/core'; | ||
|
||
@Injectable() | ||
export class QuestionService { | ||
findQuestionsForQuiz = (qid: any) => | ||
fetch(`http://localhost:3008/api/quizzes/${qid}/questions`) | ||
.then(response => response.json()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {Injectable} from '@angular/core'; | ||
|
||
@Injectable() | ||
export class QuizzesService { | ||
findAllQuizzes = () => | ||
fetch('http://localhost:3008/api/quizzes') | ||
.then(response => response.json()) | ||
findQuizForCourse = (qid: any) => | ||
fetch(`http://localhost:3008/api/quizzes/${qid}`) | ||
.then(response => response.json()) | ||
findQuestionsForQuiz = (qid: any) => | ||
fetch(`http://localhost:3008/api/quizzes/${qid}/questions`) | ||
.then(response => response.json()) | ||
} | ||
|