+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
@@ -479,68 +268,46 @@ export default {
scenarios: [
{
title: "",
- monitoringRating: null,
- monitoringStrengths: "",
- monitoringImprovements: "",
- controlProceduralRating: null,
- controlProceduralStrengths: "",
- controlProceduralImprovements: "",
- controlRating: null,
- controlStrengths: "",
- controlImprovements: "",
- conservatismRating: null,
- conservatismStrengths: "",
- conservatismImprovements: "",
- teamworkCommunicationsRating: null,
- teamworkCommunicationsStrengths: "",
- teamworkCommunicationsImprovements: "",
- teamworkLeadershipRating: null,
- teamworkLeadershipStrengths: "",
- teamworkLeadershipImprovements: "",
- teamworkWorkloadRating: null,
- teamworkWorkloadStrengths: "",
- teamworkWorkloadImprovements: "",
- knowledgeRating: null,
- knowledgeStrengths: "",
- knowledgeImprovements: ""
- }
+ entries: [
+ {
+ type: null,
+ rating: 0,
+ strengths: "",
+ AFIs: "",
+ },
+ ],
+ },
],
totals: [0, 0, 0, 0, 0, 0, 0, 0],
warningBound: 2.5,
- submitPassword: null
+ submitPassword: null,
+ entryTypeOptions: [
+ { value: "monitoring", text: "Monitoring" },
+ { value: "controlProcedural", text: "Control Procedural" },
+ { value: "control", text: "Control" },
+ { value: "conservatism", text: "Conservatism" },
+ { value: "teamworkCommunications", text: "Teamwork Communications" },
+ { value: "teamworkLeadership", text: "Teamwork Leadership" },
+ { value: "teamworkWorkload", text: "Teamwork Workload" },
+ { value: "knowledge", text: "Knowledge" },
+ ],
};
},
computed: {
- ...mapState(["type", "whom", "site", "tutors"])
+ ...mapState(["type", "whom", "site", "tutors"]),
},
methods: {
addAnotherObservation: function() {
this.scenarios.push({
title: "",
- monitoringRating: null,
- monitoringStrengths: "",
- monitoringImprovements: "",
- controlProceduralRating: null,
- controlProceduralStrengths: "",
- controlProceduralImprovements: "",
- controlRating: null,
- controlStrengths: "",
- controlImprovements: "",
- conservatismRating: null,
- conservatismStrengths: "",
- conservatismImprovements: "",
- teamworkCommunicationsRating: null,
- teamworkCommunicationsStrengths: "",
- teamworkCommunicationsImprovements: "",
- teamworkLeadershipRating: null,
- teamworkLeadershipStrengths: "",
- teamworkLeadershipImprovements: "",
- teamworkWorkloadRating: null,
- teamworkWorkloadStrengths: "",
- teamworkWorkloadImprovements: "",
- knowledgeRating: null,
- knowledgeStrengths: "",
- knowledgeImprovements: ""
+ entries: [
+ {
+ type: null,
+ rating: 0,
+ strengths: "",
+ AFIs: "",
+ },
+ ],
});
Vue.nextTick(function() {
window.scrollTo(
@@ -556,42 +323,34 @@ export default {
}
this.updateTotals();
},
+ addAnotherEntry: function(scenario) {
+ scenario.entries.push({
+ type: null,
+ rating: 0,
+ strengths: "",
+ AFIs: "",
+ });
+ },
updateTotals: function() {
var iTotals = [0, 0, 0, 0, 0, 0, 0, 0];
var counts = [0, 0, 0, 0, 0, 0, 0, 0];
- this.scenarios.forEach(function(element) {
- if (element.monitoringRating) {
- iTotals[0] += parseInt(element.monitoringRating);
- counts[0] += 1;
- }
- if (element.controlProceduralRating) {
- iTotals[1] += parseInt(element.controlProceduralRating);
- counts[1] += 1;
- }
- if (element.controlRating) {
- iTotals[2] += parseInt(element.controlRating);
- counts[2] += 1;
- }
- if (element.conservatismRating) {
- iTotals[3] += parseInt(element.conservatismRating);
- counts[3] += 1;
- }
- if (element.teamworkCommunicationsRating) {
- iTotals[4] += parseInt(element.teamworkCommunicationsRating);
- counts[4] += 1;
- }
- if (element.teamworkLeadershipRating) {
- iTotals[5] += parseInt(element.teamworkLeadershipRating);
- counts[5] += 1;
- }
- if (element.teamworkWorkloadRating) {
- iTotals[6] += parseInt(element.teamworkWorkloadRating);
- counts[6] += 1;
- }
- if (element.knowledgeRating) {
- iTotals[7] += parseInt(element.knowledgeRating);
- counts[7] += 1;
- }
+ var indices = {
+ monitoring: 0,
+ controlProcedural: 1,
+ control: 2,
+ conservatism: 3,
+ teamworkCommunications: 4,
+ teamworkLeadership: 5,
+ teamworkWorkload: 6,
+ knowledge: 7,
+ };
+ this.scenarios.forEach(function(scenario) {
+ scenario.entries.forEach(function(entry) {
+ if (entry.type !== null && entry.rating > 0) {
+ iTotals[indices[entry.type]] += parseInt(entry.rating);
+ counts[indices[entry.type]] += 1;
+ }
+ });
});
for (var i = 0; i < iTotals.length; i++) {
if (counts[i] !== 0) {
@@ -629,10 +388,150 @@ export default {
let axiosConfig = {
auth: {
username: "admin",
- password: this.submitPassword
- }
+ password: this.submitPassword,
+ },
};
var self = this;
+ var transformedScenarioData = [];
+ this.scenarios.forEach(function(scenario) {
+ var monitoring = scenario.entries.filter(
+ (entry) => entry.type === "monitoring"
+ );
+ var controlProcedural = scenario.entries.filter(
+ (entry) => entry.type === "controlProcedural"
+ );
+ var control = scenario.entries.filter(
+ (entry) => entry.type === "control"
+ );
+ var conservatism = scenario.entries.filter(
+ (entry) => entry.type === "conservatism"
+ );
+ var teamworkCommunications = scenario.entries.filter(
+ (entry) => entry.type === "teamworkCommunications"
+ );
+ var teamworkLeadership = scenario.entries.filter(
+ (entry) => entry.type === "teamworkLeadership"
+ );
+ var teamworkWorkload = scenario.entries.filter(
+ (entry) => entry.type === "teamworkWorkload"
+ );
+ var knowledge = scenario.entries.filter(
+ (entry) => entry.type === "knowledge"
+ );
+ transformedScenarioData.push({
+ title: scenario.title,
+ monitoringRating:
+ monitoring.length > 0
+ ? monitoring.length > 1
+ ? monitoring.reduce(
+ (a, b) => parseInt(a.rating) + parseInt(b.rating)
+ ) / monitoring.length
+ : monitoring[0].rating
+ : 0,
+ monitoringStrengths: monitoring
+ .map((entry) => entry.strengths)
+ .join("; "),
+ monitoringImprovements: monitoring
+ .map((entry) => entry.AFIs)
+ .join("; "),
+ controlProceduralRating:
+ controlProcedural.length > 0
+ ? controlProcedural.length > 1
+ ? controlProcedural.reduce(
+ (a, b) => parseInt(a.rating) + parseInt(b.rating)
+ ) / controlProcedural.length
+ : controlProcedural[0].rating
+ : 0,
+ controlProceduralStrengths: controlProcedural
+ .map((entry) => entry.strengths)
+ .join("; "),
+ controlProceduralImprovements: controlProcedural
+ .map((entry) => entry.AFIs)
+ .join("; "),
+ controlRating:
+ control.length > 0
+ ? control.length > 1
+ ? control.reduce(
+ (a, b) => parseInt(a.rating) + parseInt(b.rating)
+ ) / control.length
+ : control[0].rating
+ : 0,
+ controlStrengths: control
+ .map((entry) => entry.strengths)
+ .join("; "),
+ controlImprovements: control.map((entry) => entry.AFIs).join("; "),
+ conservatismRating:
+ conservatism.length > 0
+ ? conservatism.length > 1
+ ? conservatism.reduce(
+ (a, b) => parseInt(a.rating) + parseInt(b.rating)
+ ) / conservatism.length
+ : conservatism[0].rating
+ : 0,
+ conservatismStrengths: conservatism
+ .map((entry) => entry.strengths)
+ .join(";"),
+ conservatismImprovements: conservatism
+ .map((entry) => entry.strengths)
+ .join(";"),
+ teamworkCommunicationsRating:
+ teamworkCommunications.length > 0
+ ? teamworkCommunications.length > 1
+ ? teamworkCommunications.reduce(
+ (a, b) => parseInt(a.rating) + parseInt(b.rating)
+ ) / teamworkCommunications.length
+ : teamworkCommunications[0].rating
+ : 0,
+ teamworkCommunicationsStrengths: teamworkCommunications
+ .map((entry) => entry.strengths)
+ .join(";"),
+ teamworkCommunicationsImprovements: teamworkCommunications
+ .map((entry) => entry.AFIs)
+ .join(";"),
+ teamworkLeadershipRating:
+ teamworkLeadership.length > 0
+ ? teamworkLeadership.length > 1
+ ? teamworkLeadership.reduce(
+ (a, b) => parseInt(a.rating) + parseInt(b.rating)
+ ) / teamworkLeadership.length
+ : teamworkLeadership[0].rating
+ : 0,
+ teamworkLeadershipStrengths: teamworkLeadership
+ .map((entry) => entry.strengths)
+ .join(";"),
+ teamworkLeadershipImprovements: teamworkLeadership
+ .map((entry) => entry.AFIs)
+ .join(";"),
+ teamworkWorkloadRating:
+ teamworkWorkload.length > 0
+ ? teamworkWorkload.length > 1
+ ? teamworkWorkload.reduce(
+ (a, b) => parseInt(a.rating) + parseInt(b.rating)
+ ) / teamworkWorkload.length
+ : teamworkWorkload[0].rating
+ : 0,
+ teamworkWorkloadStrengths: teamworkWorkload
+ .map((entry) => entry.strengths)
+ .join(";"),
+ teamworkWorkloadImprovements: teamworkWorkload
+ .map((entry) => entry.AFIs)
+ .join(";"),
+ knowledgeRating:
+ knowledge.length > 0
+ ? knowledge.length > 1
+ ? knowledge.reduce(
+ (a, b) => parseInt(a.rating) + parseInt(b.rating)
+ ) / knowledge.length
+ : knowledge[0].rating
+ : 0,
+ knowledgeStrengths: knowledge
+ .map((entry) => entry.strengths)
+ .join(";"),
+ knowledgeImprovements: knowledge
+ .map((entry) => entry.AFIs)
+ .join(";"),
+ });
+ });
Vue.axios
.post(
"/observation",
@@ -641,8 +540,8 @@ export default {
tutors: this.tutors,
person: this.whom,
type: this.type,
- observed: this.scenarios.map(x => x.title).join(", "),
- scenarios: JSON.parse(JSON.stringify(this.scenarios))
+ observed: this.scenarios.map((x) => x.title).join("; "),
+ scenarios: JSON.parse(JSON.stringify(transformedScenarioData)),
},
axiosConfig
)
@@ -654,8 +553,8 @@ export default {
}
this.clearPassword();
form.classList.add("was-validated");
- }
- }
+ },
+ },
};