Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate:grade task modal #564

Merged
merged 57 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
80348b4
fix: ensure test dependencies are compatible
tancnle Apr 14, 2022
646d860
test: add test command and doc
tancnle Apr 14, 2022
7ddf0c1
fix: add missing dependencies in component tests
tancnle Apr 15, 2022
cbffcdf
fix: disable incomplete user service tests
tancnle Apr 17, 2022
e7059c7
ci: run unit tests in GitHub CI
tancnle Apr 17, 2022
9d37660
refactor: remove task sheet viewer component
PerryRose Apr 18, 2022
a0d3122
Merge pull request #6 from thoth-tech/fix/front-end-tests
tancnle Apr 19, 2022
5cea7b6
new: create inital files for grade-icon migration
PerryRose Apr 24, 2022
048e3f9
refactor: unlink old component, add in new and downgrade
PerryRose Apr 24, 2022
eb743d8
migrate: complete grade-icon component migration
PerryRose Apr 24, 2022
83cc377
refactor: remove old grade-icon component
PerryRose Apr 24, 2022
3965e82
refactor: update all usages of component
PerryRose Apr 25, 2022
f21ef4a
refactor: improve component styling
PerryRose Apr 25, 2022
9b51b83
test: add unit tests for grade-icon component
PerryRose Apr 25, 2022
f44f6d1
Merge pull request #9 from thoth-tech/fix/remove-task-sheet-viewer
tancnle Apr 27, 2022
44b1172
docs: update Thoth Tech build badge reference
tancnle May 2, 2022
64b2cb2
Merge pull request #21 from thoth-tech/docs/fix-build-badge-references
tancnle May 6, 2022
75ea3f2
refactor: remove duplicate line in scss files
PerryRose May 9, 2022
9951f05
refactor: use prettier on migrated component
PerryRose May 9, 2022
629649a
Merge pull request #18 from thoth-tech/migrate/grade-icon
PerryRose May 11, 2022
432de28
feat: format code using ESLint and Prettier
tancnle May 11, 2022
cc49268
fix: include angular relevant lint rules
tancnle May 13, 2022
f60fdda
fix: address minor eslint issues
tancnle May 13, 2022
3a9f15d
fix: report all lint issues as warning
tancnle May 13, 2022
b5cda5e
docs: update formatting instructions
tancnle May 13, 2022
528e543
ci: use same lint command for development and CI
tancnle May 13, 2022
5484df0
fix: escape dashes in unicode regex
tancnle May 19, 2022
526a957
Merge pull request #23 from thoth-tech/feat/prettier-formatter
tancnle May 20, 2022
ded3377
new: create initial files for migration of grade-task-modal
PerryRose Apr 25, 2022
3a28de2
new: create service to show grade-task-modal
PerryRose Apr 25, 2022
efc33e7
refactor: add and downgrade service to angularjs module
PerryRose Apr 25, 2022
7d5906e
refactor: unlink old component and add in new
PerryRose Apr 25, 2022
a399698
refactor: update task service to call migrated component
PerryRose Apr 26, 2022
7c24000
migrate: complete migration for rating quality-point tasks
PerryRose May 7, 2022
5f921b0
refactor: add ability to grade tasks, tidy up component
PerryRose May 12, 2022
bcbd4e1
refactor: prevent negative ratings
PerryRose May 14, 2022
0531c37
test: add unit tests
PerryRose May 14, 2022
e24df85
refactor: remove old component files
PerryRose May 14, 2022
da5d9fa
fix: buttons alignment in safari
PerryRose May 14, 2022
83c8d6e
refactor: add spacing between rating and grading
PerryRose May 16, 2022
729915b
refactor: ran prettier
PerryRose May 16, 2022
026af08
refactor: append df prefix to component selector
PerryRose May 16, 2022
0fc9b54
refactor: remove br and add spacing with ngstyle
PerryRose May 17, 2022
603e738
style: remove inline style and create class
PerryRose May 22, 2022
873a859
refactor: perform rating calculation in ts file
PerryRose May 22, 2022
d525750
refactor: allow mat-slider to begin at 0
PerryRose May 22, 2022
845cd08
refactor: replace buttons style with align
PerryRose May 22, 2022
2e4dde8
style: replace margin with padding
PerryRose May 22, 2022
72db500
test: fix test to reflect rating of 0
PerryRose May 22, 2022
d8b4305
test: add test for rating label
PerryRose May 25, 2022
dc6bf5f
refactor: remove console logging
PerryRose May 28, 2022
03429c8
chore: upstream changes into grade task modal
macite Jul 22, 2022
9e9fccc
Merge branch 'quality/entity-service-to-npm' into thoth-tech-migrate/…
macite Jul 22, 2022
63c11d1
update: merge quality service to task modal
leocomsci Aug 8, 2022
a61ec9b
fix: fix some minor error
leocomsci Aug 8, 2022
f5960e8
chore: change welcome component name
leocomsci Aug 9, 2022
b33c516
Merge branch 'migrate/grade-task-modal' of https://github.com/thoth-t…
macite Nov 4, 2024
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
9 changes: 9 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"root": true,
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "warn"
},
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"env": {
"browser": true,
"jasmine": true
},
"overrides": [
{
"files": ["*.ts"],
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,14 @@ TODO:

## Table of Contents

1. [Getting Started](#getting-started)
2. [Resources](#resources)
3. [Contributing](#contributing)
4. [Deployment](#deployment)
5. [License](#license)
- [Doubtfire Web ![CI](https://github.com/doubtfire-lms/doubtfire-web/actions/workflows/nodejs-ci.yml)](#doubtfire-web-)
- [Migration Progress](#migration-progress)
- [Table of Contents](#table-of-contents)
- [Getting Started](#getting-started)
- [Deployment](#deployment)
- [Resources](#resources)
- [Contributing](#contributing)
- [License](#license)

## Getting Started

Expand Down
1 change: 0 additions & 1 deletion src/app/common/common.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ angular.module("doubtfire.common", [
'doubtfire.common.filters'
'doubtfire.common.modals'
'doubtfire.common.file-uploader'
'doubtfire.common.grade-icon'
'doubtfire.common.content-editable'
'doubtfire.common.alert-list'
])
16 changes: 0 additions & 16 deletions src/app/common/grade-icon/grade-icon.coffee

This file was deleted.

3 changes: 3 additions & 0 deletions src/app/common/grade-icon/grade-icon.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<span class="grade-icon">
{{ gradeLetter }}
</span>
13 changes: 13 additions & 0 deletions src/app/common/grade-icon/grade-icon.component.scss
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;
}
86 changes: 86 additions & 0 deletions src/app/common/grade-icon/grade-icon.component.spec.ts
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]);
});
});
});
25 changes: 25 additions & 0 deletions src/app/common/grade-icon/grade-icon.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Component, OnInit, Input, Inject } from '@angular/core';
import { gradeService } from 'src/app/ajs-upgraded-providers';

@Component({
selector: 'grade-icon',
templateUrl: 'grade-icon.component.html',
styleUrls: ['grade-icon.component.scss'],
})
export class GradeIconComponent implements OnInit {
@Input() grade: string = 'F';
@Input() index: number;

gradeText: string;
gradeLetter: string;

constructor(@Inject(gradeService) private GradeService: any) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a new equivalent of this in typescript.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if you can remove the GradeService from this and use the new code


ngOnInit(): void {
if (this.index == undefined) {
this.index = this.GradeService.grades.indexOf(this.grade);
}
this.gradeText = this.GradeService.grades[this.index];
this.gradeLetter = this.GradeService.gradeAcronyms[this.gradeText];
}
}
48 changes: 0 additions & 48 deletions src/app/common/grade-icon/grade-icon.scss

This file was deleted.

8 changes: 0 additions & 8 deletions src/app/common/grade-icon/grade-icon.tpl.html

This file was deleted.

4 changes: 4 additions & 0 deletions src/app/doubtfire-angular.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ import { HeaderComponent } from './common/header/header.component';
import { UnitDropdownComponent } from './common/header/unit-dropdown/unit-dropdown.component';
import { TaskDropdownComponent } from './common/header/task-dropdown/task-dropdown.component';
import { SplashScreenComponent } from './home/splash-screen/splash-screen.component';
import { GradeIconComponent } from './common/grade-icon/grade-icon.component';
import { GradeTaskModalComponent } from './tasks/modals/grade-task-modal/grade-task-modal.component';
import { HttpErrorInterceptor } from './common/services/http-error.interceptor';
import { TaskDefinitionService } from './api/services/task-definition.service';
import { TaskOutcomeAlignmentService } from './api/services/task-outcome-alignment.service';
Expand Down Expand Up @@ -234,6 +236,8 @@ import { TransitionHooksService } from './sessions/transition-hooks.service';
UnitDropdownComponent,
TaskDropdownComponent,
SplashScreenComponent,
GradeIconComponent,
GradeTaskModalComponent,
ObjectSelectComponent,
WelcomeComponent,
HeroSidebarComponent,
Expand Down
25 changes: 14 additions & 11 deletions src/app/doubtfire-angularjs.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import 'build/src/app/visualisations/achievement-box-plot.js';
import 'build/src/app/tasks/task-submission-viewer/task-submission-viewer.js';
import 'build/src/app/tasks/task-status-selector/task-status-selector.js';
import 'build/src/app/tasks/modals/upload-submission-modal/upload-submission-modal.js';
import 'build/src/app/tasks/modals/grade-task-modal/grade-task-modal.js';
import 'build/src/app/tasks/modals/modals.js';
import 'build/src/app/tasks/modals/plagiarism-report-modal/plagiarism-report-modal.js';
import 'build/src/app/tasks/task-definition-selector/task-definition-selector.js';
Expand Down Expand Up @@ -175,7 +174,6 @@ import 'build/src/app/common/modals/comments-modal/comments-modal.js';
import 'build/src/app/common/modals/csv-result-modal/csv-result-modal.js';
import 'build/src/app/common/modals/progress-modal/progress-modal.js';
import 'build/src/app/common/modals/modals.js';
import 'build/src/app/common/grade-icon/grade-icon.js';
import 'build/src/app/common/file-uploader/file-uploader.js';
import 'build/src/app/common/common.js';
import 'build/src/app/common/services/listener-service.js';
Expand Down Expand Up @@ -267,6 +265,8 @@ import { TaskSubmissionHistoryComponent } from './tasks/task-submission-history/
import { HeaderComponent } from './common/header/header.component';
import { GlobalStateService } from './projects/states/index/global-state.service';
import { TransitionHooksService } from './sessions/transition-hooks.service';
import { GradeIconComponent } from './common/grade-icon/grade-icon.component';
import { GradeTaskModalService } from './tasks/modals/grade-task-modal/grade-task-modal.service';
import { AuthenticationService } from './api/services/authentication.service';
import { ProjectService } from './api/services/project.service';
import { ObjectSelectComponent } from './common/obect-select/object-select.component';
Expand Down Expand Up @@ -316,6 +316,7 @@ DoubtfireAngularJSModule.factory('checkForUpdateService', downgradeInjectable(Ch
DoubtfireAngularJSModule.factory('TaskAssessmentModal', downgradeInjectable(TaskAssessmentModalService));
DoubtfireAngularJSModule.factory('TaskSubmission', downgradeInjectable(TaskSubmissionService));
DoubtfireAngularJSModule.factory('GlobalStateService', downgradeInjectable(GlobalStateService));
DoubtfireAngularJSModule.factory('GradeTaskModal', downgradeInjectable(GradeTaskModalService));
DoubtfireAngularJSModule.factory('TransitionHooksService', downgradeInjectable(TransitionHooksService));

// directive -> component
Expand Down Expand Up @@ -367,15 +368,17 @@ DoubtfireAngularJSModule.directive(
downgradeComponent({ component: TaskDescriptionCardComponent })
);

DoubtfireAngularJSModule.directive('taskAssessor', downgradeComponent({ component: TaskAssessorComponent }));
DoubtfireAngularJSModule.directive(
'taskAssessmentComment',
downgradeComponent({ component: TaskAssessmentCommentComponent })
);
DoubtfireAngularJSModule.directive(
'taskSubmissionHistory',
downgradeComponent({ component: TaskSubmissionHistoryComponent })
);
DoubtfireAngularJSModule.directive('taskAssessor',
downgradeComponent({ component: TaskAssessorComponent }));
DoubtfireAngularJSModule.directive('taskAssessmentComment',
downgradeComponent({ component: TaskAssessmentCommentComponent }));
DoubtfireAngularJSModule.directive('taskSubmissionHistory',
downgradeComponent({ component: TaskSubmissionHistoryComponent }));

DoubtfireAngularJSModule.directive(
'gradeIcon',
downgradeComponent({ component: GradeIconComponent })
);

// Global configuration
DoubtfireAngularJSModule.directive(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="contrib in team.memberContributions | orderBy:memberSortOrder:reverse">
<td>{{contrib.project.student.name}}</td>
<tr ng-repeat="member in team.members | orderBy:memberSortOrder:reverse">
<td>{{member.student_name}}</td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't look right - with the new service we do not have any snake case properties

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check everything in this...

<td class="text-left">
<grade-icon grade="contrib.project.targetGrade"></grade-icon>
<grade-icon [index]="member.targetGrade"></grade-icon>
</td>
<td>
<rating
class="group-member-contribution-rating"
ng-click="checkClearRating(contrib)"
ng-model="contrib.rating"
on-hover="hoveringOver(contrib, value)"
on-leave="hoveringOver(contrib, null)"
ng-click="checkClearRating(member)"
ng-model="member.rating"
on-hover="hoveringOver(member, value)"
on-leave="hoveringOver(member, null)"
max="numStars"
state-on="'fa fa-child rating-outline'"
state-off="'fa fa-child rating-disabled'">
</rating>
<span
class="label {{percentClass(contrib.percent)}}"
ng-show="contrib.overStar">
<span ng-show="contrib.percent > 0">
{{contrib.percent}} % effort
class="label {{percentClass(member.percent)}}"
ng-show="member.overStar">
<span ng-show="member.percent > 0">
{{member.percent}} % effort
</span>
<span ng-hide="contrib.percent > 0">
<span ng-hide="member.percent > 0">
No effort
</span>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h4>No members in group</h4>
<td class="student-id" ng-show="unitRole">{{member.student.username || "N/A"}}</td>
<td class="student-name">{{member.student.name}}</td>
<td ng-show="unitRole" class="student-grade text-left">
<grade-icon grade="member.targetGrade"></grade-icon>
<grade-icon [index]="member.targetGrade"></grade-icon>
</td>
<td class="actions" ng-if="canRemoveMembers">
<button ng-click="removeMember(member)" class="btn btn-sm btn-danger" ng-hide="project">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h3 class="panel-title">Target Grade</h3>
<div class="panel-body text-center">
<p class="btn-group">
<label ng-repeat="grade in grades" ng-click="chooseGrade($index)" class="btn btn-default col-sm-3 text-center" ng-model="project.targetGrade" btn-radio="{{$index}}">
<grade-icon grade="grade" tooltip="Select a {{grade}} as your target grade" tooltip-append-to-body="true" class="text-{{$index == project.targetGrade ? 'primary' : 'muted'}}"></grade-icon>
<grade-icon [grade]="grade" tooltip="Select a {{grade}} as your target grade" tooltip-append-to-body="true"></grade-icon>
</label>
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { async, ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { plagiarismReportModal } from 'src/app/ajs-upgraded-providers';

import { TaskPlagiarismCardComponent } from './task-plagiarism-card.component';
Expand Down
Loading