Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build:angular18": "ng build",
"lint:fix": "ng lint --fix",
"lint": "ng lint",
"serve:angular18": "export NODE_OPTIONS=--max_old_space_size=4096 && ng serve --configuration $NODE_ENV --proxy-config proxy.conf.json",
"serve:angular18": "export NODE_OPTIONS=--max_old_space_size=4096 && ng serve --poll=2000 --configuration $NODE_ENV --proxy-config proxy.conf.json",
"start": "npm-run-all -l -s build:angular1 -p watch:angular1 serve:angular18",
"watch:angular1": "grunt delta",
"deploy:build2api": "ng build --delete-output-path=true --optimization=true --configuration production --output-path dist",
Expand All @@ -41,9 +41,9 @@
"@angular/upgrade": "^18.0",
"@ctrl/ngx-emoji-mart": "^9.2.0",
"@ngneat/hotkeys": "^4.0.0",
"@swimlane/ngx-charts": "^20.5.0",
"@uirouter/angular": "^14.0",
"@uirouter/angular-hybrid": "^18.0",
"@swimlane/ngx-charts": "^20.5.0",
"@uirouter/angularjs": "^1.0.30",
"@uirouter/core": "^6.1.0",
"@uirouter/rx": "^1.0.0",
Expand All @@ -70,6 +70,9 @@
"codemirror": "5.65.0",
"core-js": "^3.21.1",
"d3": "3.5.17",
"d3-axis": "^3.0.0",
"d3-scale": "^4.0.2",
"d3-selection": "^3.0.0",
"date-fns": "^3.6.0",
"es5-shim": "^4.5.12",
"file-saver": "^2.0.5",
Expand All @@ -82,7 +85,7 @@
"ng-csv": "0.2.3",
"ng-file-upload": "~5.0.9",
"ng-flex-layout": "^17.3.7-beta.1",
"ng2-pdf-viewer": "^10.2",
"ng2-pdf-viewer": "10.2.2",
"ngx-bootstrap": "^6.1.0",
"ngx-entity-service": "^0.0.39",
"ngx-lottie": "^11.0.2",
Expand All @@ -102,14 +105,17 @@
"@angular-eslint/eslint-plugin-template": "18.0.1",
"@angular-eslint/schematics": "18.0.1",
"@angular-eslint/template-parser": "18.0.1",
"@angular/compiler-cli": "^18.0.3",
"@angular/cli": "^18.0.4",
"@angular/compiler-cli": "^18.0.3",
"@angular/language-service": "^18.0.3",
"@commitlint/cli": "^16.0.1",
"@commitlint/config-conventional": "^17",
"@types/angular": "1.5.11",
"@types/canvas-confetti": "^1.6.0",
"@types/d3": "^3.5.17",
"@types/d3-axis": "^3.0.6",
"@types/d3-scale": "^4.0.9",
"@types/d3-selection": "^3.0.11",
"@types/file-saver": "^2.0.1",
"@types/jasmine": "~3.9.1",
"@types/jasminewd2": "~2.0.3",
Expand Down
148 changes: 148 additions & 0 deletions src/app/api/services/outcome.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import {Injectable} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';
import {GradeService} from '../models/doubtfire-model';
import {TaskService} from '../models/doubtfire-model';

@Injectable({
providedIn: 'root',
})
export class OutcomeService {
alignmentLabels: string[] = [
'The task is not related to this outcome at all',
'The task is slightly related to this outcome',
'The task is related to this outcome',
'The task is a reasonable example for this outcome',
'The task is a strong example of this outcome',
'The task is the best example of this outcome',
];

constructor(
private sanitizer: DomSanitizer,
private gradeService: GradeService,
private taskService: TaskService,
) {}

individualTaskStatusFactor(project: any, task: any) {
return (taskDefinitionId: any) => {
if (task.definition.id === taskDefinitionId) {
return this.taskService.learningWeight.get(
project.findTaskForDefinition(taskDefinitionId).status,
);
} else {
return 0;
}
};
}

individualTaskPotentialFactor(project: any, task: any) {
return (taskDefinitionId: any) => {
return task.definition.id === taskDefinitionId ? 1 : 0;
};
}

calculateTargets(unit: any, source: any, taskStatusFactor: (td: any) => number) {
const outcomes: any = {};

unit.ilos.forEach((outcome: any) => {
outcomes[outcome.id] = {0: [], 1: [], 2: [], 3: []};
});

source.taskOutcomeAlignments.forEach((align: any) => {
const td = unit.taskDef(align.taskDefinition.id);
outcomes[align.learningOutcome.id][td.targetGrade].push(align.rating * taskStatusFactor(td));
});

Object.keys(outcomes).forEach((key) => {
const outcome = outcomes[key];
Object.keys(outcome).forEach((gradeKey) => {
const scale = Math.pow(2, parseInt(gradeKey, 10));
outcome[gradeKey] =
outcome[gradeKey].reduce((memo: number, num: number) => memo + num, 0) * scale;
});
});

return outcomes;
}

calculateTaskContribution(unit: any, project: any, task: any) {
const outcomeSet: any[] = [];
outcomeSet[0] = this.calculateTargets(
unit,
unit,
this.individualTaskStatusFactor(project, task),
);

Object.keys(outcomeSet[0]).forEach((key) => {
outcomeSet[0][key] = Object.values(outcomeSet[0][key] as any).reduce(
(memo: number, num: any) => memo + (num as number),
0,
);
});

outcomeSet[0].title = 'Current Task Contribution';
return outcomeSet;
}

calculateTaskPotentialContribution(unit: any, project: any, task: any) {
const outcomes = this.calculateTargets(
unit,
unit,
this.individualTaskPotentialFactor(project, task),
);

Object.keys(outcomes).forEach((key) => {
outcomes[key] = Object.values(outcomes[key]).reduce(
(memo: number, num: any) => memo + (num as number),
0,
);
});

outcomes['title'] = 'Potential Task Contribution';
return outcomes;
}

calculateProgress(unit: any, project: any) {
const outcomeSet: any[] = [];
outcomeSet[0] = this.calculateTargets(unit, unit, project.taskStatusFactor.bind(project));

outcomeSet.forEach((outcomes) => {
Object.keys(outcomes).forEach((key) => {
outcomes[key] = Object.values(outcomes[key]).reduce(
(memo: number, num: any) => memo + (num as number),
0,
);
});
});

outcomeSet[0].title = 'Your Progress';
return outcomeSet;
}

targetsByGrade(unit: any, source: any) {
const result: any[] = [];
const outcomes = this.calculateTargets(unit, source, unit.taskStatusFactor);

const values: Record<string, any[]> = {'0': [], '1': [], '2': [], '3': []};

Object.keys(outcomes).forEach((key) => {
const outcome = outcomes[key];
Object.keys(outcome).forEach((gradeKey) => {
values[gradeKey].push({
label: this.sanitizer.bypassSecurityTrustHtml(
unit.outcome(parseInt(key, 10)).abbreviation,
),
value: outcome[gradeKey],
});
});
});

Object.keys(values).forEach((gradeKey) => {
result.push({
key: this.gradeService.grades[gradeKey],
values: values[gradeKey],
});
});

return result;
}
}
144 changes: 0 additions & 144 deletions src/app/common/services/outcome-service.coffee

This file was deleted.

1 change: 0 additions & 1 deletion src/app/common/services/services.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
angular.module("doubtfire.common.services", [
'doubtfire.common.services.outcome-service'
'doubtfire.common.services.analytics'
'doubtfire.common.services.dates'
'doubtfire.common.services.listener'
Expand Down
Loading