Skip to content

Commit

Permalink
SAK-43455 Make the grading and student rubrics kb accessible (sakaipr…
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Mar 26, 2020
1 parent d5e3e83 commit f8559a0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {RubricsElement} from "./rubrics-element.js";
import {html} from "/webcomponents/assets/lit-element/lit-element.js";
import {tr} from "./sakai-rubrics-language.js";
import { RubricsElement } from "./rubrics-element.js";
import { html } from "/webcomponents/assets/lit-element/lit-element.js";
import { tr } from "./sakai-rubrics-language.js";

export class SakaiRubricGradingComment extends RubricsElement {

Expand All @@ -16,25 +16,27 @@ export class SakaiRubricGradingComment extends RubricsElement {
return {
criterion: { type: Object },
entityId: { attribute: "entity-id", type: String },
evaluatedItemId: { attribute: "evaluated-item-id", type: String },
evaluatedItemId: { attribute: "evaluated-item-id", type: String }
};
}

set criterion(newValue) {

var oldValue = this._criterion;
this._criterion = newValue;
this._criterion.comments = (newValue.comments && newValue.comments.indexOf("null") === 0) ? "" : newValue.comments;
this._criterion.comments = newValue.comments && newValue.comments.indexOf("null") === 0 ? "" : newValue.comments;
this.requestUpdate("criterion", oldValue);
}

get criterion() { return this._criterion; }
get criterion() {
return this._criterion;
}

render() {

return html`
<!-- edit icon -->
<div style="cursor: pointer;" class="comment-icon fa fa-2x fa-comments ${this.criterion.comments ? "active": ""}" @click="${this.toggleEditor}" title="${tr("criterion_comment")}"></div>
<div tabindex="0" style="cursor: pointer;" class="comment-icon fa fa-2x fa-comments ${this.criterion.comments ? "active" : ""}" @click=${this.toggleEditor} @keypress=${this.toggleEditor} title="${tr("criterion_comment")}"></div>
<!-- popover -->
<div id="criterion-editor-${this.criterion.id}-${this.randombit}" class="popover criterion-edit-popover left">
Expand Down Expand Up @@ -76,7 +78,7 @@ export class SakaiRubricGradingComment extends RubricsElement {
var popover = $(`#criterion-editor-${this.criterion.id}-${this.randombit}`);

popover[0].style.left = e.target.offsetLeft - 270 + "px";
popover[0].style.top = ((e.target.offsetTop + e.target.offsetHeight/2 + 20) - popover.height()/2) + "px";
popover[0].style.top = e.target.offsetTop + e.target.offsetHeight / 2 + 20 - popover.height() / 2 + "px";

this.setupEditor();

Expand All @@ -99,23 +101,19 @@ export class SakaiRubricGradingComment extends RubricsElement {
if (!this.criterion.comments) {
this.criterion.comments = "";
}
this.dispatchEvent(new CustomEvent('update-comment', {detail: {evaluatedItemId: this.evaluatedItemId, entityId: this.entityId, criterionId: this.criterion.id, value: this.criterion.comments}, bubbles: true, composed: true}));
this.dispatchEvent(new CustomEvent('update-comment', { detail: { evaluatedItemId: this.evaluatedItemId, entityId: this.entityId, criterionId: this.criterion.id, value: this.criterion.comments }, bubbles: true, composed: true }));
this.requestUpdate();
}

setupEditor() {

try {
var commentEditor = CKEDITOR.replace('criterion_' + this.evaluatedItemId + '_' + this.entityId + '_comment_' + this.criterion.id + '|' + this.randombit + '|', {
toolbar : [
// ['Bold', 'Italic', 'Underline', '-', 'Link', 'Unlink'],
['Bold', 'Italic', 'Underline'],
['NumberedList','BulletedList', 'Blockquote']
],
height: 40,
toolbar: [['Bold', 'Italic', 'Underline'], ['NumberedList', 'BulletedList', 'Blockquote']],
height: 40
});

commentEditor.on('change', (e) => this.criterion.comments = commentEditor.getData() );
commentEditor.on('change', e => this.criterion.comments = commentEditor.getData());
} catch (error) {
console.log(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class SakaiRubricGrading extends RubricsElement {
translatedTotalPoints: { type: Number },
selectedRatings: { type: Array },
criteria: { type: Array },
rubric: { type: Object },
rubric: { type: Object }
};
}

Expand All @@ -46,7 +46,9 @@ export class SakaiRubricGrading extends RubricsElement {
} else this._token = newValue;
}

get token() { return this._token; }
get token() {
return this._token;
}

attributeChangedCallback(name, oldVal, newVal) {

Expand All @@ -72,7 +74,7 @@ export class SakaiRubricGrading extends RubricsElement {
<div class="cr-table">
<div class="cr-table-row">
${c.ratings.map(r => html`
<div class="rating-item ${this.selectedRatings.includes(r.id) ? "selected" : ""}" data-rating-id="${r.id}" id="rating-item-${r.id}" data-criterion-id="${c.id}" @click="${this.toggleRating}">
<div class="rating-item ${this.selectedRatings.includes(r.id) ? "selected" : ""}" tabindex="0" data-rating-id="${r.id}" id="rating-item-${r.id}" data-criterion-id="${c.id}" @keypress=${this.toggleRating} @click=${this.toggleRating}>
<h5 class="criterion-item-title">${r.title}</h5>
<p>${r.description}</p>
<span class="points" data-points="${r.points}">${r.points.toLocaleString(this.locale)} <sr-lang key="points">Points</sr-lang></span>
Expand Down Expand Up @@ -202,7 +204,7 @@ export class SakaiRubricGrading extends RubricsElement {
points: c.pointoverride || c.selectedvalue,
comments: c.comments,
pointsAdjusted: c.pointoverride !== c.selectedvalue,
selectedRatingId: c.selectedRatingId,
selectedRatingId: c.selectedRatingId
};
});

Expand All @@ -212,7 +214,7 @@ export class SakaiRubricGrading extends RubricsElement {
evaluatedItemOwnerId: window.top.portal.siteId,
overallComment: "",
criterionOutcomes: crit,
toolItemRubricAssociation: this.association._links.self.href,
toolItemRubricAssociation: this.association._links.self.href
};

if (this.evaluation && this.evaluation.id) {
Expand All @@ -227,9 +229,9 @@ export class SakaiRubricGrading extends RubricsElement {
headers: {
"Authorization": this.token,
"Accept": "application/json",
"Content-Type": "application/json",
"Content-Type": "application/json"
},
method: this.evaluation && this.evaluation.id ? "PATCH" : "POST",
method: this.evaluation && this.evaluation.id ? "PATCH" : "POST"
}).then(r => r.json()).then(r => this.evaluation = r);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {RubricsElement} from "./rubrics-element.js";
import {html} from "/webcomponents/assets/lit-element/lit-element.js";
import {unsafeHTML} from "/webcomponents/assets/lit-html/directives/unsafe-html.js";
import {tr} from "./sakai-rubrics-language.js";
import { RubricsElement } from "./rubrics-element.js";
import { html } from "/webcomponents/assets/lit-element/lit-element.js";
import { unsafeHTML } from "/webcomponents/assets/lit-html/directives/unsafe-html.js";
import { tr } from "./sakai-rubrics-language.js";

export class SakaiRubricStudentComment extends RubricsElement {

Expand All @@ -20,16 +20,18 @@ export class SakaiRubricStudentComment extends RubricsElement {

var oldValue = this._criterion;
this._criterion = newValue;
this._criterion.comments = (newValue.comments && newValue.comments.indexOf("null") === 0) ? "" : newValue.comments;
this._criterion.comments = newValue.comments && newValue.comments.indexOf("null") === 0 ? "" : newValue.comments;
this.requestUpdate("criterion", oldValue);
}

get criterion() { return this._criterion; }
get criterion() {
return this._criterion;
}

render() {

return html`
<div style="${this.criterion.comments ? "cursor: pointer;" : ""}" class="comment-icon fa fa-2x fa-comments ${this.criterion.comments ? "active": ""}" @click="${this.toggleComment}" title="${tr("criterion_comment_student")}"></div>
<div tabindex="0" style="${this.criterion.comments ? "cursor: pointer;" : ""}" class="comment-icon fa fa-2x fa-comments ${this.criterion.comments ? "active" : ""}" @click=${this.toggleComment} @keypress=${this.toggleComment} title="${tr("criterion_comment_student")}"></div>
<!-- popover -->
<div id="criterion-comment-viewer-${this.criterion.id}-${this.randombit}" class="popover criterion-edit-popover left">
Expand Down Expand Up @@ -66,7 +68,7 @@ export class SakaiRubricStudentComment extends RubricsElement {

this.classList.add('show-tooltip');
popover[0].style.left = e.target.offsetLeft - 270 + "px";
popover[0].style.top = (e.target.offsetTop + e.target.offsetHeight/2 - popover.height()/2) + "px";
popover[0].style.top = e.target.offsetTop + e.target.offsetHeight / 2 - popover.height() / 2 + "px";
popover.show();
} else {
this.classList.remove('show-tooltip');
Expand Down

0 comments on commit f8559a0

Please sign in to comment.