Re: New to PHP, need pointers to best practices for the design of an atypical web app

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks. JS isn't an option because the adaptive algorithm needs to score the items and I don't consider it secure to send the answer keys of an exam to a client-side script.

So, if you were me, what PHP framework or app model would you use?

-Alan


On 7/1/2019 10:58 PM, Sam Hobbs wrote:
I don't know how much you know so I apologize if I am telling youi anything you already know.

You need to understand the fundamentals of how the HTTP protocol and HTML work. Initially in the world wide web browsers would send a request for a page to the server and the server would read the HTML file and send it to the client (the browser). If that is new to you then there are thousands of places you can learn more. The important thing is that the server forgets about the request. There is nothing left in the server. The server is done with the request.

Also in the early days of the internet HTML had forms but they were very basic compared to how they are currently used. Initially a form would have a submit button that would send the form contents to the server. Normally the server would execute a Common Gateway Interface (CGI) program. The CGI program would write out a HTML file that was sent to the client. Alternatively the server would show a second HTML file but that is not relevant here. The important thing is that PHP uses the same CGI technology. PHP reads a HTML file (except with PHP in it) and writes out a HTML file that is sent to the client. And here it gets complicated. Over the years various techniques have been developed so that server-side programming could retain and/or send data across requests. One way is for data in a page to be sent as part of a request that has the relevant data.

Well there is much more to the story. If any of that is new to you then you have some reading to do.

There are two general possible solutions to your requirements, but there are many more possibilities too. One possibility would be to send all the data to the client and do all the work in the client using _javascript_ or some client-side programming. That could provide the best performance but requires you to use _javascript_ and would compromise security. Another possibility is something called a post-back and that is quite technical. It is however using technology much like an old-style HTML form except generalized and made more technical.

Monday, July 1, 2019 12:45 PM
I want to implement an adaptive test (exam) using PHP. (So, like any quiz, or any multi-page form, but using internal logic to decide what question to serve next and deciding when the exam is done.) I am a researcher (not a programmer) but I am familiar with Perl and other programming languages and with some web application models.

It looks like the vast majority of the PHP examples use the page (perhaps with parts dynamically injected using PHP) to represent the "mode" (state) of the application. I definitely want to separate my logic/code from presentation, but AFAICT the popular frameworks all use a MVC pattern where the "mode" is encoded in the URL (which is really the same since the URL specifies the page).

I don't think an exam fits well with either of these models. Even in research, a test-taker completing an exam should proceed linearly through a series of screens (consent, instructions, a series of items, optionally some post-questionnaire questions, optionally some exam results, some kind of "thank you"). And the examinee should not have any ability to modify the sequence of screens or the backend/underlying data by manipulating the URL.

Also, one of my design goals is to allow the researcher (who would install and configure this software) to control whether the optional pages appear and to modify templates to include their own content on these pages.

My inclination is to create a large index.php file that examines the user input and the current state and executes a subroutine that serves the appropriate next page (by selecting the appropriate template and filling it with appropriate information). I know this is atypical and I'd appreciate thoughts about things I may be overlooking as a newcomer to PHP and the PHP way of creating web apps. If I'm reinventing any wheels, I'd appreciate pointers to those frameworks.

I'm also having trouble finding a simple example of using a template outside of a framework. But maybe that's my newness...

-Alan
--

Alan D. Mead, Ph.D.
President, Talent Algorithms Inc.

science + technology = better workers

http://www.alanmead.org

"You're an interesting species. An interesting mix.
You're capable of such beautiful dreams, and such
horrible nightmares. You feel so lost, so cut off,
so alone, only you're not. See, in all our
searching, the only thing we've found that makes
the emptiness bearable, is each other."

-- Carl Sagan, Contact


-- 

Alan D. Mead, Ph.D.
President, Talent Algorithms Inc.

science + technology = better workers

http://www.alanmead.org

"You're an interesting species. An interesting mix. 
You're capable of such beautiful dreams, and such 
horrible nightmares. You feel so lost, so cut off, 
so alone, only you're not. See, in all our 
searching, the only thing we've found that makes 
the emptiness bearable, is each other."

-- Carl Sagan, Contact

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux