Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Logic challenge: Many-to-Many relationship loop (Faculty vs. Field of Study)

More
1 week 1 day ago #273306 by kkozera
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Community Edition 6.16.1
Own server or LimeSurvey hosting: Own server
Survey theme/template: Custom
==================Hi everyone,I am updating a survey for university lecturers regarding infrastructure quality, and I have encountered a logical "Many-to-Many" complexity that I am struggling to model in LimeSurvey.The Context:
  • Q12 (Faculty/Infrastructure): The lecturer selects which Faculty's classrooms/labs they used (Multiple choice).
  • Q12b (Field of Study): The lecturer indicates the Field of Study they taught (e.g., Robotics, Computer Science).
  • Q13-Q17 (Evaluation): Detailed questions about the quality of the infrastructure (equipment, internet, etc.).
The Problem (Many-to-Many):
There is no strict hierarchy. A single Field of Study (e.g., "Robotics") can have classes taking place in classrooms belonging to multiple different Faculties. Conversely, one Faculty can host multiple Fields of Study.The Desired Flow:
I need the user to evaluate the specific intersection of [Faculty] + [Field of Study].Example Scenario:
  1. Lecturer teaches the "Robotics" Field of Study.
  2. For this course, they used rooms in Faculty A AND rooms in Faculty B.
  3. The survey needs to generate two separate evaluation loops (Q13-Q17):
    • Loop 1: How was the infrastructure at Faculty A for Robotics?
    • Loop 2: How was the infrastructure at Faculty B for Robotics?
My Question:
What is the most efficient way to structure this loop?Should I:
  1. First ask to select all Faculties used (Q12).
  2. Then create a loop for each selected Faculty.
  3. Inside that loop, ask: "Which Field of Study did you teach in this specific Faculty?"
  4. Then trigger the evaluation questions (Q13-Q17)?
Or is there a better "Array Filter" or "Loop" method to handle this N:N relationship without confusing the user?Thank you for your advice!

Please Log in to join the conversation.

More
1 week 1 day ago - 1 week 23 hours ago #273307 by Joffm
Hi,
at first I would like to know, how many Faculties there are.
And of which type are the "evaluation" questions?
This to estimate whether it is advisable to run a "father-son" scenario or a single survey with tayloring is sufficient.

I understand that you want to run one survey to get the response of one lecturer, who may teach several fields in several labs.
So your first questions will be like
Q1: Multiple response
"Which fields did you teach?"

Q2: probably array(numbers)
"In which labs did you teach field1, field2, field3,...?"

And we get results like
"field1 - lab11"
"field1 - lab7"
"field1 - lab2"
"field2 - lab7"
"field3 - lab1"
"field3 - lab7"

And after you answered the questions at the beginning and preferably send a lss export of the real survey so far. we will see what to do best.

Joffm

One more:
The survey is about the infrastructure of a faculty.
Do you really expect really different valuations of one faculty in the different fields?
Shouldn't it be sufficient to ask the general questions about "noise, internet, accessibility, and whatever", and afterwards e.g. a multiple text question for each field tought in this faculty "Which remarks according to [the tought fields]?"
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 week 23 hours ago by Joffm.

Please Log in to join the conversation.

More
1 week 22 hours ago #273308 by kkozera
Hi Joffm,Thank you for the quick analysis.1. The "Redundancy" vs. Requirement:
You asked if I really expect different valuations. While I agree with you regarding the User Experience, there is a strict administrative requirement: All reporting at our University is aggregated by Field of Study.2. Technical Details:
  • Number of Faculties: 18.
  • Question Types used for each chosen faculty (as structured now):
    • List with comment (Type: O)
    • Array (Type: F)
    • Long free text (Type: T)
  • Room/Lab specific: We will NOT ask about specific room numbers. The granularity stops at the [Faculty + Field of Study] level.

Please Log in to join the conversation.

More
1 week 14 hours ago - 1 week 14 hours ago #273311 by Joffm
Hi, one more question.
Can you estimate a maximum number of combinations?
Meaning:
Taken this, the lecturer teaches three fields, each in one to three labs
"field1 - lab11"
"field1 - lab7"
"field1 - lab2"
"field2 - lab7"
"field3 - lab1"
"field3 - lab7"
Here we have 6 combinations.

Can we say "There won't be more than 30 combination of one lecturer"? 

I developped a "father-son" approach that works just fine.
But maybe a single survey with tayloring will be sufficient.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 week 14 hours ago by Joffm.

Please Log in to join the conversation.

More
1 week 5 hours ago - 1 week 5 hours ago #273312 by kkozera
Hi Joffm,

My answer wasn't posted by the system yesterday, I wonder why.

Thank you for the quick analysis.

1. The "Redundancy" vs. Requirement:
You asked if I really expect different valuations. While I agree with you regarding the User Experience, there is a strict administrative requirement: All reporting at our University is aggregated by Field of Study.

 2. Technical Details:
  • Number of Faculties: 18.
  • Question Types used in the loop:
    • List with comment (Type: O)
    • Array (Type: F)
    • Long free text (Type: T)
  • Room/Lab specific: We will NOT ask about specific room numbers. The granularity stops at the [Faculty + Field of Study] level.
3. The Structure:
I cannot share the .lss file due to sensitive data policies. If information that I provided isn't sufficient then I will create and export .lss file with fake questions. I have attached a bar chart that visualizes possible combinations.

One of the professors have taught students from 18 different fields of study, meaning we have 18 faculties times 18 fields of study = 324 possible combinations.
80% of proffesors taught in 4 or fewer fields of study so it gives 72 possible combinations.Here is a simulation of what professor might decide to score (He taught in 4 fields of study and decided to score only 3 of them):

Faculty 1 - Field of study 1
Faculty 2 - Field of study 2
Faculty 10 - Field of study 2
Faculty 12 - Field of study 2
Faculty 15 - Field of study 1
Faculty 18 - Field of study 3
Last edit: 1 week 5 hours ago by kkozera. Reason: Correct formatting

Please Log in to join the conversation.

More
1 week 4 hours ago #273313 by Joffm

One of the professors have taught students from 18 different fields of study, meaning we have 18 faculties times 18 fields of study = 324 possible combinations.


This means he taught each of the 18 fields in each of the 18 faculties? Is this realistic? I don't think so.

There moght have been a misunderstanding about "my combinazopns".

As you show here 
Faculty 1 - Field of study 1
Faculty 2 - Field of study 2
Faculty 10 - Field of study 2
Faculty 12 - Field of study 2
Faculty 15 - Field of study 1
Faculty 18 - Field of study 3

this lecturer tought field 1 in 2 faculties, field 2 in three faculties and field 3 in 1 faculties, which results in 6 combinations.
My question was about a maximumm number of such combinations that ONE lecturer may cover.

Given the types of repeated questions and supposing the array contains not more than 10 subquestions, in a single survey you can handle about 60 combinations.

Is it an open or a closed survey?
If "closed" there may be an option to create a single survey with "unlimited" combinations.

Joffm
 
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
1 week 3 hours ago - 1 week 3 hours ago #273314 by kkozera
To clarify the "Many-to-Many" necessity with an example:

If the respondent is a Mathematics professor, they might teach a single calculus course that is attended by students from multiple different Fields of Study. While we know what they taught, we don't know where (which Faculty buildings/labs were used). Therefore, the survey must allow the user to link their Fields of Study to any of the 18 Faculties.

However, I have an idea to simplify the user input:
Since this is a closed survey (token-based), I don't necessarily need to show a generic list of all possible Fields of Study to everyone.
I have the ability to dynamically generate/customize the survey so that each professor sees only the Fields of Study they actually taught.


Hope this helps clarify the context. Thank you for your help!
Last edit: 1 week 3 hours ago by kkozera. Reason: Correct formatting

Please Log in to join the conversation.

More
6 days 23 hours ago #273321 by Joffm
Hi,

If the respondent is a Mathematics professor, they might teach a single calculus course that is attended by students from multiple different Fields of Study. While we know what they taught, we don't know where (which Faculty buildings/labs were used). Therefore, the survey must allow the user to link their Fields of Study to any of the 18 Faculties.

Oh, that was my misunderstanding
The fields of study is the field of study of the students, not the teacher.
And the respondent - the teacher - is to answer for each of these different fields x faculties? 

Anyway: 
Two solutions:
1. One single survey, which links to itself at the end for each selected combination.
a. In the first round the respondent selects fields and facs and answers these three questions for all selected facs of the first field.
b. Now the survey calls itself, and only shows the questions about the facs of the second selected field
c. And so on, until all fields are answered.
To do this, you have to install the plugin "updateTokenByResponse", the combinations and the SAVEDID are stored and updated as additional attributes.

2. A "father-son" approach
a. In the first survey the fields and facs are selected
b. This survey links to the "son", with the SAVEDID and the selected fields and facs as parameter.
c. The questions for the facs of the first field are shown.
d. The parameter is updated and this (second) survey links to itself.
e. And so on till all fields are answered.
No plugin needed

Some examples.
 
Either "blank - X" or "blank - Yes" or "No - Yes", up to you.
 


This way you won't get in trouble with any limitation of the database - not LimeSurvey
Read here about the limitation of size of several databases (MySQL, Microsoft SQL, PostgreSQL)
[url] www.limesurvey.org/manual/General_FAQ/en...does_LimeSurvey_have ...[/url]

Because we create a new record in the dataset for each field there won't be problems.

A in my opinion better solution would be to call the survey for each selected combination.
Would be really easy to analyse without restructuring the dataset.

But you still did not send the lss export of a ptototype of the survey.

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
6 days 4 hours ago #273328 by kkozera

And the respondent - the teacher - is to answer for each of these different fields x faculties? 

Preferably, the teacher would be able to choose which ones they want to answer. If they want to grade only 2 out of the 4 fields of study they taught across 4 faculties, that should be possible.

Note that the teacher may have had classes in various buildings across the entire campus. For example, they might want to grade Field of Study 1 at Faculty 1, 2, 3, and 4. Let's take a Mathmetician for example. He has a students group from field of Automatics and Robotics and he teaches linear algebra. He had lessons with the student group in different classrooms across campus in faculty 1, faculty 2, faculty 3 and faculty 4 buildings. He wants to score Field of Study 1 against Faculty 1, 2, 3 and 4. It's an extreme edge case.

I have attached anonymized .lss file with the structure we use now (only faculties -> faculty = buildings of the faculty)

Please Log in to join the conversation.

More
6 days 1 hour ago - 6 days 1 hour ago #273331 by Joffm

If they want to grade only 2 out of the 4 fields of study they taught across 4 faculties, that should be possible.

Then they select only these two.

But where in your survey do you ask for the "field of study"?
And: Open or closed survey?
I#d prefer a closed survey.


 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 days 1 hour ago by Joffm.

Please Log in to join the conversation.

More
6 days 4 minutes ago - 6 days 3 minutes ago #273332 by Joffm
Hi,
here I show the result of the design I explained yesterday.
You get one record of your general "unicorn" questions and then for each selected combination one record.
pid is the PersonID.
This way the analysis should be quite easy,
All variables are in the same column and also the variables to filter - if you want to run a t-Test, an ANOVA, or other statistical tests.

By the way:
If you want to ask facs first and then fields, well that's the same logic.

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 days 3 minutes ago by Joffm.

Please Log in to join the conversation.

More
4 days 22 hours ago #273343 by Joffm
Here two sample surveys
1. The open survey

File Attachment:

File Name: fields_fac...open.lss
File Size:251.77 KB

Nothing else needed.

2. The closed survey

File Attachment:

File Name: fields_fac...osed.lss
File Size:236.27 KB

Here there are used two additional attributes "pid" (the personal ID of the respondent) and "pool" (the "combinations").
These are updated by the plugin "updateTokenByResponse"
[url] gitlab.com/SondagesPro/TokenManagement/updateTokenByResponse [/url]
When generating the participant list, all participant have to get an initial value of "pid" and "pool" of 0.

Furthermore you see in question "faculties" 
the script to insert dropdowns
the additional tooltips to give more information of the faculties 

In the group description of "faculty" you see the nested IF to show the text of the field.
You also could use
{if(eqField=='01',Q1_01.shown, if(eqField=='02',Q1_02.shown, if(eqField=='02',...
You may add the same for the faculty.

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
2 days 1 hour ago - 2 days 1 hour ago #273363 by kkozera
Hi Joffm,

Thank you so much for your hard work and for preparing both survey samples. I really appreciate the detailed explanation.

However, I have run into a major roadblock. Unfortunately, our university's IT administrator has strictly refused to install the "updateTokenByResponse" plugin due to internal policies.Given this limitation, could you please advise on how to implement the "father-son" structure?

I was trying to do it myself but it's not so easy.

Kamil
Last edit: 2 days 1 hour ago by kkozera.

Please Log in to join the conversation.

More
1 day 19 hours ago #273374 by Joffm

could you please advise on how to implement the "father-son" structure?

Tomorrow - Tuesday - I'll send it.
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
5 hours 1 minute ago #273383 by Joffm
Sorry, had some other work to complete.
Friday, promised 

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose