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
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.
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.
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… Ivans description of how text is sent to the server isnt 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 doesnt 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.
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.
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.
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.
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.
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.
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).