Server Communication

Recently, Andy sent the following posting to the C.a.R. newsgroup

Let me try and explain what I have in mind…

I want to be able to create assignments for students to work on… However the difficult bit is that I want to be able to store their solutions in a database and then replay them.

To do this I need to be able to do 2 things:

  • The first thing I need to do is feed the XML code usually stored in the .job/.zir file directly into the Applet (using PHP and MySQL) without having to first save the file. I noticed that Geometriagon uses a PARAM called “constructionText” into which they directly feed their construction (or at least that is how it looks when I view the source code of their page). However when I tried that it didn’t work?
  • The second thing I need to be able to do is to take a construction that a students has completed (as part of an assignment) and store the construction. Is it possible to take the construction that a student has done which correctly finished an assignment, and feed the XML into a variable that could then be stored in a MySQL database…

My intention is to eventually be able to set up a system of about 60+ constructions starting with very simple ones and building up. The system would then require them to login and would track which problems they completed (maybe force them to do them in order). Then once they have completed a problem they would be required to input some form of explanation for how they tackled the problem. Students who had finished a problem would then be able to view other peoples solutions with descriptions.

Here is my answer

I think I understood what you want to do.

First, there is no such thing as an XML stream from the server to the applet. If you want to store constructions in an SQL server, you need PHP or similar (e.g. Java Servlets) running on the server. PHP will ask the SQL database and provide the content for the Web. The applet, running on the client, can access this content just like a file under some name. The fact that the content ist dynamic, does not matter for the applet. So, once you have SQL/PHP running on the server, the current applet version will read the construction with its file parameter.

A possibly nice feature would be a choice in the applet betweeen several constructions. However, another idea is to extend the application to be able to read the construction from the Web with HTTP. Users of your database should then use the application or Java Web Start, and load the constructions from a server instead of from the local file system. You can use a restricted icon set for these constructions.

To store constructions from applets can be done with signed applets in the current Java versions. After all, there is the PUT command for HTTP, and we all have used forms to upload content to a server. I will check how this can be acomplished and implement a scheme for this in C.a.R. You will have to run a service in your Web server to accept the data, possibly PHP based, and to store the content into your database.

Thanks for this idea, Rene.

Thinking about this, I came up with the following idea. However, I do not have any experience with server communcation to SQL, so maybe someone can tell me, if I’m on the right track.

I could easily provide scripting functions to get and put constructions to C.a.R. via PHP on the same Web page as the applet. Thus, the construction could be loaded into a a Web form edit area, or sent directly to a server. Also PHP could send a construnction to the applet.

Would this solve the problems described above? — Rene Grothmann (Admin) 2005/12/27 10:43

Rene, this is exactly what I would be looking for. What I would do is use PHP to echo the variable (taken form the MySQL) into a parameter of the applet. Then the otherway round I would use a form to submit the solution when completed into MySQL server.

It may be worth talking with polarprof who wrote the Geometriagon site using CaR as he has already done some work on this in getting his site up and running.



I did some experiments. I succeeded in pasting the construction to a text area, when the user presses a button. I did that with JavaScript. However, I failed the other way round. The multiline textarea input reaches C.a.R. as an empty string. If there is only one line, it does the job.

Has anyone an idea what to do?

Rene Grothmann (Admin) 2006/01/06 15:01

I have now succeeded in Javascript communication. The demo scripting page (coming version 4.09) contains an example, where the construction is loaded into a textarea and put back to the applet. The remaining problem is some delay in the first reaction. Javascript/Java communication seems to need some startup time (in Firefox at least).

Rene Grothmann (Admin) 2006/01/19 09:55

todo/servercommunication.txt · Last modified: 2006/01/19 09:58 by rene
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki