Skip to content

Commit

Permalink
Merge pull request #441 from yeatmanlab/enh/students-test-data
Browse files Browse the repository at this point in the history
Students test data flag
  • Loading branch information
richford authored Mar 26, 2024
2 parents 3e053e3 + 4fa3b8b commit c8c7815
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/pages/RegisterStudents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
</PvColumn>
</PvDataTable>
<div class="submit-container">
<div class="m-2">
<PvCheckbox v-model="isAllTestData" :binary="true" input-id="isTestData" />
<label for="isTestData" class="ml-2">All users are test accounts</label>
</div>
<PvButton
label="Start Registration"
:icon="activeSubmit ? 'pi pi-spin pi-spinner' : ''"
Expand Down Expand Up @@ -145,6 +149,7 @@ const router = useRouter();
const toast = useToast();
const isFileUploaded = ref(false);
const rawStudentFile = ref({});
const isAllTestData = ref(false);
// Primary Table & Dropdown refs
const dataTable = ref();
Expand All @@ -165,6 +170,7 @@ const dropdown_options = ref([
label: 'Optional',
items: [
{ label: 'Ignore this column', value: 'ignore' },
{ label: 'TestData', value: 'testData' },
{ label: 'First Name', value: 'firstName' },
{ label: 'Middle Name', value: 'middleName' },
{ label: 'Last Name', value: 'lastName' },
Expand Down Expand Up @@ -289,6 +295,7 @@ async function submitStudents() {
// Construct list of student objects, handle special columns
_forEach(rawStudentFile.value, (student) => {
let studentObj = {};
if (isAllTestData.value) studentObj['testData'] = true;
let dropdownMap = _cloneDeep(dropdown_model.value);
_forEach(modelValues, (col) => {
const columnMap = getKeyByValue(dropdownMap, col);
Expand All @@ -304,6 +311,10 @@ async function submitStudents() {
studentObj[col].push(student[columnMap]);
dropdownMap = _omit(dropdownMap, columnMap);
}
} else if (['testData'].includes(col)) {
if (student[columnMap]) {
studentObj['testData'] = true;
}
} else {
studentObj[col] = student[columnMap];
}
Expand Down Expand Up @@ -417,7 +428,7 @@ async function submitStudents() {
}
});
}
await delay(1250);
await delay(1500);
}
}
Expand Down

0 comments on commit c8c7815

Please sign in to comment.