Disastrous experience with Xojo Cloud

[quote=488595:@Val Kozmenko]If someone is interested to take a look at the code, here is the link to the DropBox folder

XOJO project file

The web compiled and deployed from the link above is here

EPNW[/quote]
You have to avoid timer 2, Update lenght mabe in the LostFocus event

Also delete timer 3, just check if the name is not empty on the buton click

Hi, Ivan,

Thank you for looking into the code.

The Timer 2 counts characters as the users type. They need to know the character count in real time as they type.

I guess I can remove Timer 3.

How about Timer 1? Is there anything wrong with its code?

I appreciate your feedback.

Val

Yes, I noticed, thats why I sugested to use another way.

You have to understand what is going on with xojo, the timer is on the client, but all the logic is on the server.

Each time timer 2 runs (each second) you are sending the content of the 6 textboxes to the server, the server check the lenght and then sends back those lenghts to the client.

With more than a couple users, is too much traffic for the app.

Once each seccond may work as it is just the time, but only if you dont have Timer 2 and 3

HI, Ivan,

You convinced me about Timer 2 and Timer 3 - I will get rid of them.

I will test how it works with Timer 1 running each second, and I might change it to 2 seconds.

Thank you again,

Val

Hello Val,

I did attempt to PM this link to you last night but the message has disappeared from my recent activity.

Link to my example project file .

I only use a single timer. Please review the button and timer ‘action’ code. All code is commented.

Kind regards, Andrew

Hello, Andrew,

Thank you for your kind help. I appreciate it. I will spend some time over your code.

Your approach to the “Start” button is very interesting with the elegant code.

I usually create buttons with only two positions, for example “Start” and “Stop” (simulated toggle button).

To distinguish between two states, I usually create a variable ClickCounter as Integer, and perform calculations if the number of clicks is odd or even.

Your approach, when clicking the button changes its caption and based on the caption different code is executed, opens new opportunities.

In my app I can get rid of the “Save and Download” button and put its code into the “Start” button.

I will look closely at the timer’s code too.

Thank you, again,

Val

H, guys,

I appreciate everyone’s help and advices.

It was mentioned in one of the posts in this thread that I had too many instances of the app on the server even after the users closed their browsers.

What is the normal procedure to close the session?

Is there a tutorial somewhere to read about how the server part and the client part communicate? I believe this communication is the main difference between web and desktop applications.

Thank you, guys, again,

Val

[quote=488653:@Val Kozmenko]H, guys,

I appreciate everyone’s help and advices.

It was mentioned in one of the posts in this thread that I had too many instances of the app on the server even after the users closed their browsers.

What is the normal procedure to close the session?

Is there a tutorial somewhere to read about how the server part and the client part communicate? I believe this communication is the main difference between web and desktop applications.

Thank you, guys, again,

Val[/quote]
The main thing to remember is that the browser and app communicate asynchronously. That is, an action is taken on one end, and sometime in the not too distant future, the command will reach the other end. That time lag, while typically small, can make all the difference in the world to a time sensitive app.

As I mentioned earlier, sessions will close on their own if they can, but only if all references to everything created can be removed.

After reading the discussion of your design, I am thinking that your app was simply hanging with too much activity and then another instance would start up with the next request, and that one would hang, and so on.

Something to note though… Ivan’s description of how text is sent to the server isn’t 100% correct. Text controls send data to the server periodically when the user pauses for a moment, not when the timer fires. If the user is typing very quickly and doesn’t pause at all, your character count will not be calculated until your test is over and the data is sent to the server. If you require finer control over this, you may want to create your own input control using the WebSDK.

Hello Val,

A couple of final suggestions…

Suggestion 1:

Counting characters entered by the user…

I recommend using the KeyPressed event in your WebTextArea controls to count characters typed.

This code sample updates a WebTextField with the number of characters typed in WebTextArea. Subtracts a char when backspace is typed, ignores the tab key (when tabbing between fields), adds a character for everything else.

The point is, it performs the count independently (outside of your timer).

// Text Area | KeyPressed Event // counting characters If Details.KeyCode = Details.KeyBackspace Then tfChars1.Text = Str(Val(tfChars1.Text) -1) // reduce the count for each backspace key ElseIf Details.KeyCode = Details.KeyTab Then tfChars1.Text = Str(Val(tfChars1.Text)) // maintain the count for each tab key Else tfChars1.Text = Str(Val(tfChars1.Text) +1) // increase the count for all other keys End If

Suggestion 2:

Avoid multiple timers running at once. Whilst it may be technically possible to run multiple timers at once, it is difficult to troubleshoot. Try and reimagine your workflow for a single timer.

I have updated my earlier example on Xojo Cloud to include counters running off the KeyPressed event of each WebTextArea control. It is available here.

Have a nice weekend.

Kind regards, Andrew

Are you sure of that? I just tried again the example, I type as fast as I can (bot hands just smashing keys, no pauses) and still the character count updates every second. Can you please try it and explain the behavior?

[quote=488661:@Andrew Paul Dickey]This code sample updates a WebTextField with the number of characters typed in WebTextArea. Subtracts a char when backspace is typed, ignores the tab key (when tabbing between fields), adds a character for everything else.

The point is, it performs the count independently (outside of your timer).[/quote]

That is even worst, instead of sending the text to the server every second as with the timer, it wil try to send all the text on EACH key press. I just tried your example, typed as fast as I can (bot hands just smashing keys, no pauses), looks good counting, but when I stopped, the counter keeped moving another 5 secods with all the traffic on queue, server will crash with even less users typing.

The character count needs to be implemented in pure Javascript. Anything else is going to be unreliable and costly.

I am. The framework code actually waits a full second after the person finishes typing to send updated text to the server. It’s one of the things that we’re specifically working on improving in the Web Framework 2.0.

That’s the sad part. In the future I would prefer that my “Xojo Client Side” functions can be pushed transpiled as Javascript equivalents and used/consumed/fired at the client side alongside with “Xojo Client Side Widgets”. No Xojo user should need to know Javascript in the future.
The experience should be: drag, drop, set events, write code… done. All in Xojo.

That’s not true of any development tool. When you’re delivering complex solutions, sometimes you need more than one language.

Maybe you down know other development tools, because, it’s already done with 2 that I know.

Thats weird. Maybe I dont explain myself.

If the framework code waits a full second after the person finishes typing to send updated text to the server…

Why is not “waiting” in this case? Each time the timer fires, the server “knows” the current lenght of the text in the textfield, Even if the typing is continuous, (not finished nor pausing)

The code in the timer is:

Dim thisString1 As String = TextArea1.Text
Dim thisStringCount1 As Integer = thisString1.Len
Label10.Text=Str(thisStringCount1)

[quote=488755:@Ivan Tellez]Thats weird. Maybe I dont explain myself.

If the framework code waits a full second after the person finishes typing to send updated text to the server…

Why is not “waiting” in this case? Each time the timer fires, the server “knows” the current lenght of the text in the textfield, Even if the typing is continuous, (not finished nor pausing)

The code in the timer is:

Dim thisString1 As String = TextArea1.Text Dim thisStringCount1 As Integer = thisString1.Len Label10.Text=Str(thisStringCount1) [/quote]
I’m just telling you how the code is written.

Hello Val,

This is a great thread…

I do agree with @Tim Parnell that the count is best implemented in Javascript.

As @Ivan Tellez suggests there is an overhead to counting chars using KeyPressed. However, in an academic setting where students are typing well reasoned answers (not smashing keys), there is no particular count-lag. In fact, student entry/typing speeds are very measured/moderate. So whilst KeyPressed is inferior to implementing your character counts in Javascript, it functions solidly.

Val, I was merely suggesting a strategy whereby the timer is used to enable and disable the UI, based on a given time constraint with all other logic placed outside of the timer.

@Greg O’Lone Val is likely attempting to limit student answer to (n) number of chars (say for example 300 chars). I have often wondered why the WebTextArea does not have a LimitText property like the WebTextField has. LimitText would likely provide Val a no-code solution to limiting entry. Alternatively, the WebTextField could gain a Multline property, enjoyed by the WebListBox. Of course, as you suggested earlier Val could create his own custom control.

Val, please question your need to count chars so precisely, or at all.

For examination apps I have designed (in consultation with lectures/tutors/teachers) there is preferred a middle ground to mid-long response questions. I rarely count chars. I usually place a guide (line or image (green, yellow red zones) next to each WebTextArea indicating an appropriate length answer, without implementing a limit to the length of the response. When the timer expires, the UI is locked to the user. The exam responses are then formatted into a document for marking. In the document, based on char limits set in the database for each question, I highlight the over limit content in italics/underline/strikethrough etc. The marker (lecturer/tutor/teacher) then has the flexibility to consider or dismiss the additional content.

Again, I hope that helps.

Normal average typing speed is around 190 chars in 1 min, and the whole purpose of the app is for students to improve their speed.

Sending the text to the server 190+ in one minute is not any better than the current way of sending it 60 times with the timer.

Easy @Ivan Tellez! You are confusing Val’s app with the quick example I built to help Val implement his app logic into a single WebTimer. Val’s app has nothing to do with improving typing speed and neither does mine. Really! The typing task is for the sake of having an example, it could have been anything.

Val’s app is both about limiting student time and limiting chars entered during a quiz (nothing whatsoever to do with typing speed).

Please read the thread more closely.

The rest of what I said holds true. Students generally type at a modest speed during tests (they think, formulate, type, review, edit - it’s observably slow).

Kind regards, Andrew