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
|
||||
@JsonProperty
|
||||
private int monitoring, control, conservatism, teamwork, knowledge;
|
||||
private float monitoring, control, conservatism, teamwork, knowledge;
|
||||
|
||||
@NonNull
|
||||
@JsonProperty
|
||||
|
@ -49,7 +49,7 @@ public class Observation implements Serializable {
|
||||
|
||||
@NonNull
|
||||
@JsonProperty
|
||||
private int monitoring, control, conservatism, teamwork, knowledge;
|
||||
private float monitoring, control, conservatism, teamwork, knowledge;
|
||||
|
||||
@NonNull
|
||||
@JsonProperty
|
||||
|
@ -37,7 +37,8 @@ public class ObservationResource {
|
||||
|
||||
@POST
|
||||
@UnitOfWork
|
||||
public long add(@NotNull @Valid NewObservation newObservation) {
|
||||
public long add(@NotNull NewObservation newObservation) {
|
||||
log.info(newObservation.toString());
|
||||
final DateTime submissionDate = LocalDate.now().toDateTimeAtStartOfDay();
|
||||
Set<Tutor> tutors = new HashSet<>();
|
||||
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 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")))
|
||||
.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(2)).thenReturn(tutors.get(1));
|
||||
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()));
|
||||
verify(dao, times(1)).persist(any(Observation.class));
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ export default new Vuex.Store({
|
||||
site: null,
|
||||
tutors: [],
|
||||
description: null,
|
||||
type: null
|
||||
type: null,
|
||||
whom: null
|
||||
},
|
||||
mutations: {
|
||||
setSite(state, newSite) {
|
||||
@ -23,13 +24,15 @@ export default new Vuex.Store({
|
||||
setType(state, newType) {
|
||||
state.type = newType;
|
||||
},
|
||||
setWhom(state, newWhom) {
|
||||
state.whom = newWhom;
|
||||
},
|
||||
resetStore(state) {
|
||||
state = {
|
||||
site: null,
|
||||
tutors: [],
|
||||
description: null,
|
||||
type: null
|
||||
};
|
||||
state.site = null;
|
||||
state.tutors = [];
|
||||
state.description = null;
|
||||
state.type = null;
|
||||
state.whom = null;
|
||||
}
|
||||
},
|
||||
actions: {}
|
||||
|
@ -28,6 +28,13 @@
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
</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-col>
|
||||
<b-form-group label="Description">
|
||||
@ -83,10 +90,7 @@ export default {
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.site = null;
|
||||
this.description = null;
|
||||
this.type = null;
|
||||
this.tutors = [];
|
||||
this.resetStore();
|
||||
Vue.axios
|
||||
.get("/api/site/all")
|
||||
.then(response => {
|
||||
@ -100,7 +104,7 @@ export default {
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
...mapState(["site", "description", "type", "tutors"])
|
||||
...mapState(["site", "description", "type", "tutors", "whom"])
|
||||
},
|
||||
watch: {
|
||||
site: function() {
|
||||
@ -111,7 +115,14 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(["setSite", "setDescription", "setType", "setTutors"]),
|
||||
...mapMutations([
|
||||
"setSite",
|
||||
"setDescription",
|
||||
"setType",
|
||||
"setTutors",
|
||||
"setWhom",
|
||||
"resetStore"
|
||||
]),
|
||||
getTutors: function() {
|
||||
if (this.site != null) {
|
||||
Vue.axios.get("/api/site/" + this.site + "/tutors").then(response => {
|
||||
|
@ -2,16 +2,6 @@
|
||||
<b-container>
|
||||
<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-row align-v="center" class="sidebar-vert-padding">
|
||||
<b-col class="centered-image">
|
||||
@ -120,7 +110,7 @@ export default {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(["description", "type"])
|
||||
...mapState(["description", "type", "whom", "site", "tutors"])
|
||||
},
|
||||
methods: {
|
||||
addAnotherObservation: function() {
|
||||
@ -193,8 +183,40 @@ export default {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
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()) {
|
||||
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");
|
||||
},
|
||||
@ -204,30 +226,6 @@ export default {
|
||||
hideModal() {
|
||||
this.$refs.submissionModal.hide();
|
||||
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