Skip to content

prepUserImportData* problems #474

@couthcommander

Description

@couthcommander

prepUserImportData calls prepUserImportData_validateAllFormsPresent. If "consolidate" is FALSE, prepUserImportData_extractFormName is also called. As an aside and as noted in #465, this should only happen when "forms" is a column in the data set.

The last line of prepUserImportData_extractFormName (the returned value) is "instrument[instrument_present]". Simply, it returns a vector of validated instruments that were passed to the function as seen here:

form_access_forms <- prepUserImportData_extractFormName(data$forms, instrument)

This is then tested

all_form_access <- all(form_access_forms %in% instrument)

if (!all_form_access){
  msg <- sprintf("At least one user is missing an entry for the form(s): %s", 
                 paste0(setdiff(instrument, all_form_access), collapse = ", "))
  coll$push(msg)
}

In the consolidate==FALSE scenario, it's impossible for "all_form_access" to be FALSE. So something is amiss.

Trying to understand the motivation, we find this comment:

if not consolidating forms, we need to make sure all of the forms are represented in the standard format

which should fit the context of the error message:

At least one user is missing an entry for the form(s)

It seems like the true check should be this: setdiff(instrument, all_form_access). This would imply that prepUserImportData_extractFormName should check for the presence of each instrument in every element of "data$forms". (everything above also applies to "data$forms_export")

These two functions should be updated to reflect the intended usage.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions