Fixed overall observation scores being stored as ints instead of floats.
This commit is contained in:
parent
20599d48fd
commit
ba36ddd5cb
@ -26,7 +26,7 @@ public class NewObservation {
|
|||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private int monitoring, control, conservatism, teamwork, knowledge;
|
private float monitoring, control, conservatism, teamwork, knowledge;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
@ -49,7 +49,7 @@ public class Observation implements Serializable {
|
|||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private int monitoring, control, conservatism, teamwork, knowledge;
|
private float monitoring, control, conservatism, teamwork, knowledge;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
@ -37,7 +37,8 @@ public class ObservationResource {
|
|||||||
|
|
||||||
@POST
|
@POST
|
||||||
@UnitOfWork
|
@UnitOfWork
|
||||||
public long add(@NotNull @Valid NewObservation newObservation) {
|
public long add(@NotNull NewObservation newObservation) {
|
||||||
|
log.info(newObservation.toString());
|
||||||
final DateTime submissionDate = LocalDate.now().toDateTimeAtStartOfDay();
|
final DateTime submissionDate = LocalDate.now().toDateTimeAtStartOfDay();
|
||||||
Set<Tutor> tutors = new HashSet<>();
|
Set<Tutor> tutors = new HashSet<>();
|
||||||
for (long l : newObservation.getTutorIds()) {
|
for (long l : newObservation.getTutorIds()) {
|
||||||
|
@ -23,7 +23,7 @@ public class ObservationDaoTest extends DaoTestBase {
|
|||||||
private final Site site = Site.builder().name("Test site").build();
|
private final Site site = Site.builder().name("Test site").build();
|
||||||
|
|
||||||
private final Observation observation = Observation.builder().observed("Just a test observation").type(TrainingType.INITIAL)
|
private final Observation observation = Observation.builder().observed("Just a test observation").type(TrainingType.INITIAL)
|
||||||
.site(site).monitoring(1).control(2).conservatism(3).teamwork(4).knowledge(5).whom("Group A")
|
.site(site).monitoring(1f).control(2f).conservatism(3f).teamwork(4f).knowledge(5f).whom("Group A")
|
||||||
.observations(Collections.singletonList(new ObservationEntry("MONITORING", 5, "some", "another sum")))
|
.observations(Collections.singletonList(new ObservationEntry("MONITORING", 5, "some", "another sum")))
|
||||||
.date(DateTime.parse("2018-09-18T00:00:00.000Z")).build();
|
.date(DateTime.parse("2018-09-18T00:00:00.000Z")).build();
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class ObservationResourceTest {
|
|||||||
when(tutorDao.get(1)).thenReturn(tutors.get(0));
|
when(tutorDao.get(1)).thenReturn(tutors.get(0));
|
||||||
when(tutorDao.get(2)).thenReturn(tutors.get(1));
|
when(tutorDao.get(2)).thenReturn(tutors.get(1));
|
||||||
resources.target("/observation").request().post(Entity.json(NewObservation.builder().type("INITIAL")
|
resources.target("/observation").request().post(Entity.json(NewObservation.builder().type("INITIAL")
|
||||||
.conservatism(1).control(2).knowledge(3).monitoring(4).teamwork(5).siteId(1).tutorIds(Arrays.asList(1L, 2L))
|
.conservatism(1f).control(2f).knowledge(3f).monitoring(4f).teamwork(5f).siteId(1).tutorIds(Arrays.asList(1L, 2L))
|
||||||
.observed("").whom("Group A").rawData(new ArrayList<>()).build()));
|
.observed("").whom("Group A").rawData(new ArrayList<>()).build()));
|
||||||
verify(dao, times(1)).persist(any(Observation.class));
|
verify(dao, times(1)).persist(any(Observation.class));
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,8 @@ export default new Vuex.Store({
|
|||||||
site: null,
|
site: null,
|
||||||
tutors: [],
|
tutors: [],
|
||||||
description: null,
|
description: null,
|
||||||
type: null
|
type: null,
|
||||||
|
whom: null
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setSite(state, newSite) {
|
setSite(state, newSite) {
|
||||||
@ -23,13 +24,15 @@ export default new Vuex.Store({
|
|||||||
setType(state, newType) {
|
setType(state, newType) {
|
||||||
state.type = newType;
|
state.type = newType;
|
||||||
},
|
},
|
||||||
|
setWhom(state, newWhom) {
|
||||||
|
state.whom = newWhom;
|
||||||
|
},
|
||||||
resetStore(state) {
|
resetStore(state) {
|
||||||
state = {
|
state.site = null;
|
||||||
site: null,
|
state.tutors = [];
|
||||||
tutors: [],
|
state.description = null;
|
||||||
description: null,
|
state.type = null;
|
||||||
type: null
|
state.whom = null;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {}
|
actions: {}
|
||||||
|
@ -28,6 +28,13 @@
|
|||||||
</b-form-group>
|
</b-form-group>
|
||||||
</b-col>
|
</b-col>
|
||||||
</b-row>
|
</b-row>
|
||||||
|
<b-row align-h="center">
|
||||||
|
<b-col>
|
||||||
|
<b-form-group label="Who">
|
||||||
|
<b-form-input :value="whom" @input="setWhom" type="text" style="text-align:center;"></b-form-input>
|
||||||
|
</b-form-group>
|
||||||
|
</b-col>
|
||||||
|
</b-row>
|
||||||
<b-row align-h="center">
|
<b-row align-h="center">
|
||||||
<b-col>
|
<b-col>
|
||||||
<b-form-group label="Description">
|
<b-form-group label="Description">
|
||||||
@ -83,10 +90,7 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.site = null;
|
this.resetStore();
|
||||||
this.description = null;
|
|
||||||
this.type = null;
|
|
||||||
this.tutors = [];
|
|
||||||
Vue.axios
|
Vue.axios
|
||||||
.get("/api/site/all")
|
.get("/api/site/all")
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@ -100,7 +104,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["site", "description", "type", "tutors"])
|
...mapState(["site", "description", "type", "tutors", "whom"])
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
site: function() {
|
site: function() {
|
||||||
@ -111,7 +115,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(["setSite", "setDescription", "setType", "setTutors"]),
|
...mapMutations([
|
||||||
|
"setSite",
|
||||||
|
"setDescription",
|
||||||
|
"setType",
|
||||||
|
"setTutors",
|
||||||
|
"setWhom",
|
||||||
|
"resetStore"
|
||||||
|
]),
|
||||||
getTutors: function() {
|
getTutors: function() {
|
||||||
if (this.site != null) {
|
if (this.site != null) {
|
||||||
Vue.axios.get("/api/site/" + this.site + "/tutors").then(response => {
|
Vue.axios.get("/api/site/" + this.site + "/tutors").then(response => {
|
||||||
|
@ -2,16 +2,6 @@
|
|||||||
<b-container>
|
<b-container>
|
||||||
<h3>
|
<h3>
|
||||||
<v-icon name="tag" scale="1.5" />{{type}}/{{description}}</h3>
|
<v-icon name="tag" scale="1.5" />{{type}}/{{description}}</h3>
|
||||||
<div>
|
|
||||||
<b-modal ref="submissionModal" hide-footer title="Confirm Submission" @hidden="hideModal">
|
|
||||||
<div class="d-block text-center">
|
|
||||||
<p>Enter confirmation code in order to submit.</p>
|
|
||||||
<b-form-input type="password" v-model="submitPassword" style="text-align:center;" />
|
|
||||||
</div>
|
|
||||||
<b-btn class="mt-3" variant="outline-success" block @click="reallySubmit">Submit</b-btn>
|
|
||||||
<b-btn class="mt-3" variant="outline-danger" block @click="hideModal">Close</b-btn>
|
|
||||||
</b-modal>
|
|
||||||
</div>
|
|
||||||
<b-container class="sidebar">
|
<b-container class="sidebar">
|
||||||
<b-row align-v="center" class="sidebar-vert-padding">
|
<b-row align-v="center" class="sidebar-vert-padding">
|
||||||
<b-col class="centered-image">
|
<b-col class="centered-image">
|
||||||
@ -120,7 +110,7 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["description", "type"])
|
...mapState(["description", "type", "whom", "site", "tutors"])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addAnotherObservation: function() {
|
addAnotherObservation: function() {
|
||||||
@ -193,8 +183,40 @@ export default {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
var form = document.getElementById("submission-form");
|
var form = document.getElementById("submission-form");
|
||||||
|
console.log({
|
||||||
|
siteId: this.site,
|
||||||
|
tutorIds: this.tutors,
|
||||||
|
observed: this.description,
|
||||||
|
whom: this.whom,
|
||||||
|
type: this.type,
|
||||||
|
monitoring: this.totals[0],
|
||||||
|
control: this.totals[1],
|
||||||
|
conservatism: this.totals[2],
|
||||||
|
teamwork: this.totals[3],
|
||||||
|
knowledge: this.totals[4],
|
||||||
|
rawData: JSON.parse(JSON.stringify(this.observations))
|
||||||
|
});
|
||||||
if (form.checkValidity()) {
|
if (form.checkValidity()) {
|
||||||
this.showModal();
|
Vue.axios
|
||||||
|
.post("/api/observation", {
|
||||||
|
siteId: this.site,
|
||||||
|
tutorIds: this.tutors,
|
||||||
|
observed: this.description,
|
||||||
|
whom: this.whom,
|
||||||
|
type: this.type,
|
||||||
|
monitoring: this.totals[0],
|
||||||
|
control: this.totals[1],
|
||||||
|
conservatism: this.totals[2],
|
||||||
|
teamwork: this.totals[3],
|
||||||
|
knowledge: this.totals[4],
|
||||||
|
rawData: JSON.parse(JSON.stringify(this.observations))
|
||||||
|
})
|
||||||
|
.then(function(response) {
|
||||||
|
console.log(response);
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
form.classList.add("was-validated");
|
form.classList.add("was-validated");
|
||||||
},
|
},
|
||||||
@ -204,30 +226,6 @@ export default {
|
|||||||
hideModal() {
|
hideModal() {
|
||||||
this.$refs.submissionModal.hide();
|
this.$refs.submissionModal.hide();
|
||||||
this.submitPassword = null;
|
this.submitPassword = null;
|
||||||
},
|
|
||||||
reallySubmit() {
|
|
||||||
var form = document.getElementById("submission-form");
|
|
||||||
if (form.checkValidity()) {
|
|
||||||
Vue.axios
|
|
||||||
.post("/api/observation", {
|
|
||||||
siteId: this.site,
|
|
||||||
tutorIds: this.tutors,
|
|
||||||
observed: this.description,
|
|
||||||
type: this.type,
|
|
||||||
monitoring: this.totals[0],
|
|
||||||
control: this.totals[1],
|
|
||||||
conservatism: this.totals[2],
|
|
||||||
teamwork: this.totals[3],
|
|
||||||
knowledge: this.totals[4],
|
|
||||||
rawData: this.observations
|
|
||||||
})
|
|
||||||
.then(function(response) {
|
|
||||||
console.log(response);
|
|
||||||
})
|
|
||||||
.catch(function(error) {
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user