forked from doubtfire-lms/doubtfire-web
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'migrate/grade-task-modal' of https://github.com/thoth-t…
…ech/doubtfire-web into thoth-tech-migrate/grade-task-modal
- Loading branch information
Showing
30 changed files
with
587 additions
and
219 deletions.
There are no files selected for viewing
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<span class="grade-icon"> | ||
{{ gradeLetter }} | ||
</span> |
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 @@ | ||
.grade-icon { | ||
color: #fff; | ||
font-size: 1em; | ||
border-radius: 100%; | ||
width: 2.25em; | ||
height: 2.25em; | ||
font-weight: 100; | ||
margin: 0 auto; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background-color: #333333; | ||
} |
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,86 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { GradeIconComponent } from './grade-icon.component'; | ||
import { gradeService } from 'src/app/ajs-upgraded-providers'; | ||
|
||
describe('GradeIconComponent', () => { | ||
let component: GradeIconComponent; | ||
let fixture: ComponentFixture<GradeIconComponent>; | ||
let gradeServiceStub: jasmine.SpyObj<any>; | ||
|
||
beforeEach( | ||
waitForAsync(() => { | ||
gradeServiceStub = { | ||
grades: ['Pass', 'Credit', 'Distinction', 'High Distinction'], | ||
gradeAcronyms: { | ||
Fail: 'F', | ||
Pass: 'P', | ||
Credit: 'C', | ||
Distinction: 'D', | ||
'High Distinction': 'HD', | ||
0: 'P', | ||
1: 'C', | ||
2: 'D', | ||
3: 'HD', | ||
}, | ||
}; | ||
|
||
gradeServiceStub.grades[-1] = 'Fail'; | ||
gradeServiceStub.gradeAcronyms[-1] = 'F'; | ||
|
||
TestBed.configureTestingModule({ | ||
declarations: [GradeIconComponent], | ||
providers: [{ provide: gradeService, useValue: gradeServiceStub }], | ||
}).compileComponents(); | ||
}) | ||
); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(GradeIconComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should set the index value when undefined', () => { | ||
component.index = undefined; | ||
component.ngOnInit(); | ||
|
||
expect(component.index).toEqual(-1); | ||
}); | ||
|
||
it('should set the grade to Fail when given invalid input', () => { | ||
component.index = undefined; | ||
component.grade = 'Tomato'; | ||
component.ngOnInit(); | ||
|
||
expect(component.index).toEqual(-1); | ||
expect(component.gradeText).toEqual('Fail'); | ||
expect(component.gradeLetter).toEqual('F'); | ||
}); | ||
|
||
it('should appropriate set the grade when passed a grade value', () => { | ||
gradeServiceStub.grades.forEach((grade: string) => { | ||
component.grade = grade; | ||
component.index = undefined; | ||
component.ngOnInit(); | ||
|
||
expect(component.index).toEqual(gradeServiceStub.grades.indexOf(grade)); | ||
expect(component.gradeText).toEqual(grade); | ||
expect(component.gradeLetter).toEqual(gradeServiceStub.gradeAcronyms[grade]); | ||
}); | ||
}); | ||
|
||
it('should appropriate set the grade when passed a grade index', () => { | ||
gradeServiceStub.grades.forEach((_, index: number) => { | ||
component.index = index - 1; | ||
component.ngOnInit(); | ||
|
||
expect(component.index).toEqual(index - 1); | ||
expect(component.gradeText).toEqual(gradeServiceStub.grades[component.index]); | ||
expect(component.gradeLetter).toEqual(gradeServiceStub.gradeAcronyms[component.gradeText]); | ||
}); | ||
}); | ||
}); |
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, OnInit, Input } from '@angular/core'; | ||
import { GradeService } from '../services/grade.service'; | ||
|
||
@Component({ | ||
selector: 'grade-icon', | ||
templateUrl: 'grade-icon.component.html', | ||
styleUrls: ['grade-icon.component.scss'], | ||
}) | ||
export class GradeIconComponent implements OnInit { | ||
@Input() grade: string | number = 'F'; | ||
@Input() index: number; | ||
|
||
gradeText: string; | ||
gradeLetter: string; | ||
|
||
constructor(private gradeService: GradeService) {} | ||
|
||
ngOnInit(): void { | ||
if (this.index == undefined) { | ||
this.index = this.gradeService.gradeNumbers[this.grade] || this.grade; | ||
} | ||
this.gradeText = this.gradeService.grades[this.index]; | ||
this.gradeLetter = this.gradeService.gradeAcronyms[this.gradeText]; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Oops, something went wrong.