Skip to content

Commit d3a29d1

Browse files
Merge branch 'release-5.20.1'
2 parents 4985e57 + 87326c3 commit d3a29d1

62 files changed

Lines changed: 916 additions & 1840 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wise",
3-
"version": "5.20.0",
3+
"version": "5.20.1",
44
"description": "Web-based Inquiry Science Environment",
55
"main": "app.js",
66
"browserslist": [

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<artifactId>wise</artifactId>
3535
<packaging>war</packaging>
3636
<name>Web-based Inquiry Science Environment</name>
37-
<version>5.20.0</version>
37+
<version>5.20.1</version>
3838
<url>http://wise5.org</url>
3939
<licenses>
4040
<license>

src/main/resources/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.20.0
1+
5.20.1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div>
2+
<label class='node__label--vertical-alignment' i18n>JSON</label>
3+
<button mat-button class='topButton mat-raised-button mat-primary'
4+
(click)="toggleJSONView()"
5+
matTooltip="Show JSON" i18n-matTooltip matTooltipPosition="above">
6+
<mat-icon>code</mat-icon>
7+
</button>
8+
</div>
9+
<div *ngIf="showJSONAuthoring" fxLayout="column" fxLayoutGap="8px">
10+
<span i18n>Close the JSON view to save the changes</span>
11+
<mat-form-field fxFlex appearance="outline">
12+
<mat-label i18n>Edit Component JSON</mat-label>
13+
<textarea class="mat-body-1" matInput cdkTextareaAutosize [(ngModel)]="componentContentJSONString"
14+
(ngModelChange)='jsonChanged.next($event)'></textarea>
15+
</mat-form-field>
16+
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
div {
2+
margin-bottom: 10px;
3+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import * as angular from 'angular';
2+
import { Component, Input } from "@angular/core";
3+
import { UpgradeModule } from "@angular/upgrade/static";
4+
import { NotificationService } from "../../../../../wise5/services/notificationService";
5+
import { TeacherProjectService } from '../../../../../wise5/services/teacherProjectService';
6+
import { Subject, Subscription } from 'rxjs';
7+
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
8+
9+
@Component({
10+
selector: 'edit-component-json',
11+
templateUrl: 'edit-component-json.component.html',
12+
styleUrls: ['edit-component-json.component.scss']
13+
})
14+
export class EditComponentJsonComponent {
15+
16+
validComponentContentJSONString: string;
17+
componentContentJSONString: string;
18+
@Input()
19+
componentId: string;
20+
nodeChangedSubscription: Subscription;
21+
@Input()
22+
nodeId: string;
23+
showJSONAuthoring: boolean = false;
24+
jsonChanged: Subject<string> = new Subject<string>();
25+
jsonChangedSubscription: Subscription;
26+
27+
constructor(private upgrade: UpgradeModule, private NotificationService: NotificationService,
28+
private ProjectService: TeacherProjectService) {
29+
}
30+
31+
ngOnInit() {
32+
this.setComponentContentJsonString()
33+
this.jsonChangedSubscription = this.jsonChanged
34+
.pipe(
35+
debounceTime(1000),
36+
distinctUntilChanged()
37+
)
38+
.subscribe(() => {
39+
if (this.isJSONValid()) {
40+
this.rememberRecentValidJSON();
41+
this.NotificationService.showJSONValidMessage();
42+
} else {
43+
this.NotificationService.showJSONInvalidMessage();
44+
}
45+
});
46+
this.nodeChangedSubscription = this.ProjectService.nodeChanged$.subscribe(() => {
47+
this.setComponentContentJsonString();
48+
});
49+
}
50+
51+
ngOnDestory() {
52+
this.jsonChangedSubscription.unsubscribe();
53+
this.nodeChangedSubscription.unsubscribe();
54+
}
55+
56+
setComponentContentJsonString() {
57+
const authoringComponentContent = this.ProjectService.getComponentByNodeIdAndComponentId(
58+
this.nodeId, this.componentId);
59+
this.componentContentJSONString = angular.toJson(authoringComponentContent, 4);
60+
}
61+
62+
toggleJSONView(): void {
63+
if (this.showJSONAuthoring) {
64+
if (this.isJSONValid()) {
65+
this.saveChanges();
66+
this.showJSONAuthoring = false;
67+
} else {
68+
const doRollback =
69+
confirm(this.upgrade.$injector.get('$filter')('translate')('jsonInvalidErrorMessage'));
70+
if (doRollback) {
71+
this.rollbackToRecentValidJSON();
72+
this.saveChanges();
73+
}
74+
}
75+
} else {
76+
this.showJSONAuthoring = true;
77+
this.rememberRecentValidJSON();
78+
}
79+
}
80+
81+
isJSONValid(): boolean {
82+
try {
83+
angular.fromJson(this.componentContentJSONString);
84+
return true;
85+
} catch (e) {
86+
return false;
87+
}
88+
}
89+
90+
saveChanges(): void {
91+
try {
92+
const editedComponentContent = angular.fromJson(this.componentContentJSONString);
93+
this.ProjectService.replaceComponent(this.nodeId, this.componentId, editedComponentContent);
94+
this.ProjectService.componentChanged();
95+
} catch(e) {
96+
this.NotificationService.showJSONInvalidMessage();
97+
}
98+
}
99+
100+
rememberRecentValidJSON(): void {
101+
this.validComponentContentJSONString = this.componentContentJSONString;
102+
}
103+
104+
rollbackToRecentValidJSON(): void {
105+
this.componentContentJSONString = this.validComponentContentJSONString;
106+
}
107+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<mat-form-field>
2+
<mat-label i18n>Max Score</mat-label>
3+
<input matInput
4+
type='number'
5+
[(ngModel)]='authoringComponentContent.maxScore'
6+
(ngModelChange)='maxScoreChanged.next($event)'/>
7+
</mat-form-field>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Component, Input } from "@angular/core";
2+
import { Subject, Subscription } from "rxjs";
3+
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
4+
import { TeacherProjectService } from "../../../../../wise5/services/teacherProjectService";
5+
6+
@Component({
7+
selector: 'edit-component-max-score',
8+
templateUrl: 'edit-component-max-score.component.html'
9+
})
10+
export class EditComponentMaxScoreComponent {
11+
12+
@Input()
13+
authoringComponentContent: any;
14+
maxScoreChanged: Subject<string> = new Subject<string>();
15+
maxScoreChangedSubscription: Subscription;
16+
17+
constructor(private ProjectService: TeacherProjectService) {
18+
}
19+
20+
ngOnInit() {
21+
this.maxScoreChangedSubscription = this.maxScoreChanged
22+
.pipe(
23+
debounceTime(1000),
24+
distinctUntilChanged()
25+
)
26+
.subscribe(() => {
27+
this.ProjectService.componentChanged();
28+
});
29+
}
30+
31+
ngOnDestroy() {
32+
this.maxScoreChangedSubscription.unsubscribe();
33+
}
34+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div>
2+
<label class='node__label--vertical-alignment' i18n>Rubric</label>
3+
<button mat-button class='topButton mat-raised-button mat-primary'
4+
(click)='showRubricAuthoring = !showRubricAuthoring'
5+
matTooltip="Edit Component Rubric" i18n-matTooltip matTooltipPosition="above">
6+
<mat-icon>message</mat-icon>
7+
</button>
8+
</div>
9+
<wise-authoring-tinymce-editor *ngIf='showRubricAuthoring'
10+
[(model)]='rubric'
11+
(modelChange)='rubricChanged()'>
12+
</wise-authoring-tinymce-editor>

0 commit comments

Comments
 (0)