GithubHelp home page GithubHelp logo

Question groups support about surveyor_gui HOT 33 CLOSED

kjayma avatar kjayma commented on July 1, 2024
Question groups support

from surveyor_gui.

Comments (33)

kjayma avatar kjayma commented on July 1, 2024

Ok. Ill look at surveyor tonight and give it some thought.
On May 21, 2014 11:45 AM, "Alessandro Lepore" [email protected]
wrote:

This is my main concern because most of my questions uses group.
Would like to discuss how this can be implemented, not sure how to start.


Reply to this email directly or view it on GitHubhttps://github.com//issues/7
.

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

Not a simple exercise. Here are my thoughts ...

From a ui perspective:

  • There are so many different question types, best not to deal with it on the questions view but on the main surveyform view instead. Don't think it needs its own popup window.
  • On the main surveyform view, add buttons for "Add Question Group" next to "Add Question"
  • Clicking Add Question Group creates a new question group. This means creating a fieldset on the form, which will wrap the underlying questions. Clicking the button will also need to create a new row in the Question Group table. More on this below ... Now we have a place to put the questions - so we can put some "Add Question" buttons in this new fieldset. We paint the fieldset with a thick or colored border to indicate a question group (not red or dotted line - these designate mandatory and dependent respectively). Maybe a blue border would work.
  • within the new question group, we'll need a button for delete question group.
  • we'll need to provide cut and paste buttons and a drag handle too.
  • we label the fieldset with the term "Question Group"
  • Adding questions appears the same to user as it always did. The questions window pops up as usual.
  • We'll need to play with formatting to make it look nice.

From a processing perspective:

  • Question Group model does not have a foreign key into survey, survey_section, or question as far as I can see. It works the other way around - question has a foreign key into question_group. This is fine for DSL but problematic for GUI - that's because the DSL will always create a question group at the same time it creates questions. For gui, it is two distinct and time-separated operations. This means we can have orphan question groups if we delete a survey before adding any questions to the question group. Yuk. We probably need a migration that adds survey_secton id to question_group. We also need a corresponding belongs_to statement in the question_group model. Its safe to say a question group should always belong to a survey_section, just as a question does. When we add question group, it needs to pick up survey_section id and pass it on to the ajax call (see below).
  • We'll need a has_many question_groups in the survey_section model, with a dependent destroy. That will take care of the orphan problem.
  • The "Add Question Group" button needs to add a row to question_group when clicked. We'll need an ajax call to add the question group, a new question_group controller for it to call, and crud methods in the controller. You can take a look at the "Add Section" button as a template.
  • If we click an "Add Question" button in a question group fieldset, we must pass the question group id to the ajax call.
  • The question form will need to have a hidden field for question_group id.
  • Strong parameters will need to be adjusted accordingly for all of the above.
  • When the ajax call to the question builder completes, we need to make sure to put the new question back into the appropriate question_group fieldset. We should create a set of partials to facilitate this.
  • We need to accommodate cut and paste, and drag and drop of question groups. This is complicated. We have a display_order for sections - no problem to move sections. We have a display_order for questions. No problem to move questions. Question groups? Not so much - no display_order. And even if we had a display_order attribute in question groups, we would need the question display_order and the question_group display_order to be synchronized. We need to have the question group positioning rely on the questions.

Not sure yet how to do this, but I think it will involve some methods in the Question model, and maybe a new class to handle moving around question groups.

That's all I've got for now.

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

thanks for your thoughts!
in general i think the question group logic should be hidden to the user in some way for complex groups like grids.
your idea may work for simple groups like "put all those questions under the same name (group)".

looking at SM types..
i'll need to replicate those 3 "matrix" types (for the third i tweaked surveyor so it's actually custom stuff).
i'm a bit worried 😟

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

their UI for grid is actually very basic
this can be a way for my grids... "simply" get data from textareas and then do all the hard work to build the correct stuff

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

Hmm, I like that. We could toss the add row buttons for building answers and do it the same way. Much simpler.

The approach you point to eliminates the issue of orphan question groups. So in this case, we build two new question_types in the Question model.

Alessandro, what kind of time constraints are you up against?

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

I think this would be easier to do if we switch the question builder to an Exhibit Pattern. If you can hang loose for a few days, I could whip something up.

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

i'm pretty short with time, need to do most of the work this weekend and next week

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

I did some work to be able to generate rows based on lines in a textbox. You can take a look at the answers_from_text branch.

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

Almost have grids working. Take a look at show_groups_in_surveyform branch.

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

good! looking at it right now.
noticed a problem: when i edit a grid question and close the box, also without changes, SurveyformsController#replace_question does something wrong, rows disappear and i get a list of the column values.

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

Yeah, its not there yet. I'm going to get it green, but then I'm going to have to refactor some. Peeling back the onion, my original idea became a lot more complicated than I wanted.

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

bug report: create survey, add grid question, add another grid question: i get 10 grid questions and not 2

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

more in general, seems a good start to me! this is becoming good stuff.
agree that this whole thing is inherently complex, refactor can be very important to avoid going crazy with the code.
but i had not chance to take a deep look to the code yet.

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

Reproduced thie issue - will address it.

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

10 grid questions issue fixed and pushed.

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

thanks!!

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

Think this one is just about put to bed. Repeaters still outstanding.

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

bug report:
if i add an "other" answer at question creation i get a text field on all answers.
instead, if i edit a question and add an "other" answer, i get the text box only on that one (correct).
tried with "Multiple Choice (only one answer)"

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

i'm not sure about that "Are you:" question from my seed file.
That's two different questions (pick one AND a text field) grouped under the same title.
there's a simple way to support that?
or maybe it's better to ask the client create two separate questions...

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

but i have also those grids with a free text area at the end...
i think is basically the "comment" here https://github.com/NUBIC/surveyor/blob/master/doc/question%20types.png

maybe just adding an optional, simple free text "comment" may solve ?

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

about Repeaters i don't know nothing (probably because i don't need them 😄)

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

So there are two major items outstanding,

  1. Simple group - create a group of simple questions (picks allowed but not grids). They display inline or down the page. Will work on that today. I think that may be all you need to support your target survey.
  2. Repeaters - you may not need them, but they are a useful part of surveyor. If you look at the kitchen sink survey, there's a question for "What cars do you own?" and it asks about make, model, and year. What if a survey taker has 2 cars, or even 10? They need to be able to specify make, model, and year for as many cars as they own. Since the survey maker can't know how many cars there are, we give the survey taker an add question button. I think surveyor_gui should support this (but we can get your priorities knocked out first).

There's one more item that I'm not sure is worth supporting. This is the ability to add multiple possible answers to a single question, like the kitchen sink "Help me write an Improv sketch question". It has text fields for "who", "what", and "where". To me, this always seemed redundant with groups and potentially confusing.

I think you should take a look at your survey and rethink using logic. IMHO, its sometimes a better alternative to a group question. If your application may eventually go mobile, it would suck for the user to have to navigate a massive group question. Much simpler to ask them one question at a time and only show the other questions in the group if they apply.

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

not sure about the 1), i'll try to explain better:
what i need is not a generic way of grouping different questions but "just" adding a comment field to some (both picks and grids).
the comment is basically a single text question, i've read the word "comment" on that surveyor image.

for example what SM does is, when adding the "other" answer, asking if it has to be one of the answers or a separate one (comment). can work for me.

what do you think?

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

So would the comment be a single field at the bottom? Like this:

            A              B              C

X
Y
Z
Comment: __________

?

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

yes, just a name (to be inserted) and a textarea.
if i'm not wrong is like what surveyor creates as response_class: :string, display_type: "hidden_label"

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

Need to play with surveyor a bit and see how it mixes grids with other questions into the same group. Would want to come up with a generic solution for this.

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

fixed this bug:

bug report:
if i add an "other" answer at question creation i get a text field on all answers.
instead, if i edit a question and add an "other" answer, i get the text box only on that one (correct).
tried with "Multiple Choice (only one answer)"

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

Comments working well for grid. Showing properly on surveyform for picks, however, will need slight customization to surveyor to suppress radio button - that's outstanding.

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

looks good! no problems so far.
how do you suggest radio suppression? via JS or template?

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

Template - need to query the newly added attribute; is_comment attribute == false ? show radio button : hide radio button

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

grid dropdowns working. Missing a bunch ot tests and some stuff I need to get green again though.

from surveyor_gui.

kjayma avatar kjayma commented on July 1, 2024

added a columns model to support grids (not rows) which will need to be supported in Surveyor with some custom code in the views.

from surveyor_gui.

alepore avatar alepore commented on July 1, 2024

grid dropdowns looks very good, closing this

from surveyor_gui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.