Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I'm trying to plan out a simple web app. A user is presented with a question that has two or three possible answers. Depending on their answer, they're taken to another question.
i.e.
ChoiceC
ChoiceA ---> Question 2 ---> ChoiceD
Question 1 -->
ChoiceB ---> Question 3 ---> ChoiceE
ChoiceF
This seems to me a like a tree, where each question and answer is a node, and depending on what path you go down, you're exposed to a specific set of other questions/answers.
I'm trying to figure out how to implement this with reusable React components. I could potentially create a component for each question, but that doesn't seem like good practice. Does anyone have any experience building these sorts of 'choose-your-own-adventure' style questionnaires?
You can use a map that saves for every answer what the next question is.
In your case an entry could be [ChoiceA, Question2]. In your program you can then story a variable current_question that gets updated based on your map.
This solution may only be insufficient if the same answer can arise in different contexts and lead to different outcomes. In this case maybe should be a question/answer-pair that determines what comes next.
If you really want to overkill your problem, you can implement a directed labeled graph. The questions would be the nodes in this case and the edge-labels are your answers which lead to the next question/node.
The most pragmatic solution would of course be to don't use a datastructure at all and just stack if-else. This is not scalable though.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I want to know that in order to make a dynamic search application which looks through all the collections and gives the users the ability to use facets, collection facets, pagination, sorting etc what should be the right approach?
I found two functions for this: search:search, and cts:search. Which matches my needs best?
search:search is built on top of cts:search (as well as other APIs). They’re designed to work together. You should start with search:search, though. It is designed specifically for your faceted search use case and includes many conveniences and best practices that might not be obvious with the lower-level APIs, for example, concurrent facet resolution and pagination. If you need to do something more sophisticated than what search:search provides out-of-the-box, you can call out to other libraries.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I need help with creating a survey app. My idea is for the app to display questions and have users click buttons to answer. At the end, the app should show each user which user had answers closest to theirs. I need help with the following things:
*How to set up the questions and buttons for the answers
*How to compare all the answers and show each user at the end
*How to make it so there is a separate url for each survey being taken
Answering any of these questions would be very helpful.
For grouping the participants by how close their answers are, you could use the k-means clustering algorithm, of which there's already a JavaScript implementation you could use.
Well, I don't see where Socket.io fits, other than that you could use Survey.js Library to help you build the interface, store the data in the same format, JSON, in MongoDB. There you can group like here, returning the documents data of same value.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I've been working on a project (you should probably see the link to better understand what I am talking about). To make things better, I decided to make a like system.
Each posts contain a like button and a number next to it that indicates how many people liked the post.
Like (4)
The current one in my project is just plain text with an empty link, and the number is a dummy.
Like (4)
Is it possible to actually make the like button actually work? What would I need to use?
I think you need php/SQL to keep track of the votes made. So you need to learn php and SQL or rely on an extension someone else made. If you happen to use one of the more popular CMS's (Joomla/Wordpress) you can probably get it without ever having to worry about the coding.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
We are going to display a list of 25-entries on a webpage out of (at least) 5000 entries in the database. The entries should be sortable and you should be able to filter the results according to their names.
In my world, you send a request to the server asking for 25 entries that matches your criterion. However my colleague suggested a different approach; to ask for all 5000 entries and then sort and filter them with JavaScript.
I think that's stupid, but I'm afraid I'm missing something. What would you say are the pros and cons of this two approaches?
Or use AJAX, returning HTML, for the next/ prev paging. That could give you a nice solution.
Then you don't have the white screen, the UI tends to appear more slick & responsive, you can write a nice (clean & simple) server handler & your colleague can be happy writing some JQuery & AJAX.
It keeps the app scalable, to any number of rows, and the UI is more slick & responsive.. which was perhaps the point of the JS idea.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I made a website that does absolutely nothing, and I've proven to myself that people like to stay there - I've already logged 11+ hours worth of cumulative time on the page.
My question is whether it would be possible (or practical) to use the website as a distributed computing site.
My first impulse was to find out if there were any JavaScript distributed computing projects already active, so that I could put a piece of code on the page and be done. Unfortunately, all I could find was a big list of websites that thought it might be a cool idea.
I'm thinking that I might want to start with something like integer factorization - in this case, RSA numbers. It would be easy for the server to check if an answer was correct (simply test for modulus equals zero), and also easy to implement.
Is my idea feasible? Is there already a project out there that I can use?
Take a look at http://www.igvita.com/2009/03/03/collaborative-map-reduce-in-the-browser/ and http://www.igvita.com/2009/03/07/collaborative-swarm-computing-notes/