Designing Server Side Timer/Countdown for a Quiz App [closed] - reactjs

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 2 years ago.
Improve this question
I am building a quiz app with Ionic React. I want to implement some kind of quiz timer/countdown feature to limit time spent on every question. The catch is, if I implement a countdown function on client side or Front-end, I'm afraid that folks could tamper with the script and cheat by manipulating the timer to their advantage.
Therefore, I think the only way to prevent this is to implement the timer/countdown feature server side. However, I do not know the right way to go about this... Wouldn't a countdown function blocks the server? Or is there some other way that I do not know?

There are two ways to handle this:
http:
You can run a timer at frontend. Notify the backend with start / end timestamp of each question to calculate the duration taken for each question. If the duration falls within the allowed range, you are good to proceed. Here, frontend is your source of truth but you are validating it at the backend.
websocket:
Or you can implement a websocket to communicate in real time with the backend. In this case, you can run the timer at backend and show its progress at frontend in realtime. Backend will be your single source of truth.
You can check this post too.

Related

Frontend backend communicate data - best practice [closed]

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 am currently developing a appointment scheduler. Now I am designing my own frontend calendar (month view) and I know that I will have almost every day an appointment in the database. I had an argue about the API call structure.
He says: I should make an api call which returns a list of every day of a specific month and the days contains the respective appointments. Depending on that I should generate my Calendar.
I say: I want to generate the Structure of the Calendar independent of what i am receiving in the frontend. I will make a call that returns me all appointments of a specific month and add them to the calendar after I received it.
He says my idea has redundance and too much logic in the frontend, because it‘s recommended to keep as much logic in the backend as possible
My question is which way would have a better performance and would be the user experience affected depending on what way I take?
BTW as frontend I use React-Typescript with Redux and as backend C# Core
-
well, I think you should keep a clean separation of concerns. Your API concern is to provide scheduled appointments, which I suggest you to put out like:
[
{
"id":1234,
"datetime":"20210115T15:15:00",
"doctor":4231,
"doctorName":"Doe, John",
"patient":9999,
"patientName":"Mary"
}, ...
]
and that's it.
How this is going to be plotted on the screen is your front-end business.
I don't know who exactly im favoring here, but Keep your front-end as simple as possible is a very minimalistic point of view and likely to overburden your backend with front-end-only aspects.
He is right. Keep your front-end as simple as possible. Logic should be mainly handled by the back-end, Always remember to develop your front-end according to what you receive in your API call.

Understanding event driven architecture and state management in applications [closed]

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 2 years ago.
Improve this question
Hello guys I have a question regarding state management in applications centered around events.
Let us say take a scenario in which a some one posts a tweet on twitter, so this tweet should be visible to the users in real time. So things like posting a tweet or typing a comment etc are all real time events; where as fetching data from the server on the click of a button are all Restful in nature. Real-time communication can be achieved by using either web-sockets or server-sent-events. Now the question naturally that comes in the mind is How do we manage the data (state management) for rest as well as real time communication?
Restful resources are generally fetched as a bundle of information, but server sent event or websocket send it as a packet of information, by packet what i mean is data related to the single tweet. If we were to show a list of all tweets to the user we need to update the state to previously received tweets and incoming tweets but state management here becomes very hard.
I have looked at some solutions like RxJs which typically involves observables, and redux-saga which deals with generators. So can you share your experiences and insights to managing real time data and restful data.
End goal is how to manage rest and real time data in a live feed. Please feel free to correct me for any technical inaccuracies and/ suggestions. Thank you

What is the most efficient way to implement a facebook / twitter style feed in the MEAN stack? Should I consider socket.io? [closed]

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 6 years ago.
Improve this question
I was thinking about using angular's $interval to periodically query and check for new post, but then I've also read about socket.io.
This made me curious as to the best way to accomplish this from a cost-effective / scalable / efficient view point.
Can implementing socket.io in your build greatly increase the cost of hosting (on a platform such as heroku)?
Just wondering if someone can help my weigh relevant pros and cons.
socketio is a good solution for what you want to achieve. I don't know well heroku, but I use it with amazon aws and nodejs and it works fine. you can use interval and the http service of angular, but you will waist a lot of time for the heavy handshake of http protocol. socketio is trying to use websockets first (ws or secure wss) and it is much lighter when considering "network waist". it has a fallback to use the regular http long polling....go for it with socketio. you'll have a little work to do (really easy) to adjust sock.on listeners and emitters inside a service, and bind your view to this service, or use rootscope broadcast instead... enjoy :)

What's the plan for getting realtime live updates to GraphQL queries? [closed]

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
Facebook's own product uses GraphQL and is also a great example of a realtime experience. E.g. when someone likes something, everyone can see the like appear in their feed.
But all of the documentation for GraphQL uses a stateless server where every query is like making an HTTP GET or HTTP POST at a single point in time.
So it's not clear how the average developer will be able to build something as realtime as Facebook itself.
E.g. what kind of state will the server track when we have realtime GraphQL? Will the client send over a bundle of GraphQL queries to watch? Or will the server track a higher-level aspect of the client's state to infer which GraphQL queries the client cares about watching?

Spring web flow and ExtJs 4 [closed]

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 am not able to find a concrete answer yet on this forum or other's that, whether spring web flow can be used with Extjs 4.2 or later release of Extjs.
In case some one has integrated then kindly let me know the basic steps or guide to a specific example will be really helpful.
Thanks in Advance.
Rohit Dwivedi
The short answer is: "Yes".
Yes, because ExtJS does not need to (and does not) know how the server side is implemented. In its very essence, Ext sends a request to the server and expect a response, usually containing pertinent data.
In real life, you need to make decisions what part of the application logic will run on the server and what on the client and what the interface (API, request/response) will be between the two.
From the Spring site:
Spring Web Flow: Supports building web applications with controlled navigation such as checking in for a flight or applying for a loan.
So, if you want/need the server to be responsible for such flows, then go ahead.
If you want to implement the application logic (flows) at Ext client, then continue looking for the server side language/platform as you do not need the Web Flow functionality.

Resources