Line 74: Line 74:
  
 
*Thus, the entire program is extremely easy to manage and various actions can be handled separately to display certain html code that can be neatly tucked away within functions.
 
*Thus, the entire program is extremely easy to manage and various actions can be handled separately to display certain html code that can be neatly tucked away within functions.
*Now what was given above was a very top level design of how to make a web app.
+
*Now what was given above was a very top level design of how to make a web app. The following section provides code snippets that explain the process in more detail.
  
The following section provides code snippets that explain the process in more detail.
+
==Actions==
 +
 
 +
*One of the way php decides what to do with user input data is through actions.
 +
*HTML forms, radio buttons, checklists etc. all need a defined action when the data is submitted. The handling action may be a page, or another function within the web page.
 +
*Since we described in built functions as a better way of doing things, the method described here will use functions.
 +
<pre>
 +
<form action="index.php?action=doThis"  method="post"><input type="submit" value = "Do This"></form>
 +
</pre>
 +
*This code generates a very simple button that says Do This. The form lives inside some html code within the file index.php.
 +
*Now whenever the user presses this button, the form passes the value doThis into the form action.
 +
*This action value is now available for handling, but to access it, we need the following code:
 +
 
 +
<pre>
 +
$action = $_GET["action"];
 +
</pre>
 +
 
 +
 
 +
*Once this is done, the value of action lives inside the variable $action. Now this can be used to call a certain function that handles this particular action. Something like
 +
 
 +
<pre>
 +
$html .= handleAction($action);
 +
 
 +
function handleAction($action){
 +
 
 +
if($action == "doThis"{
 +
  $html = some_html_code for the desired action}
 +
  }
 +
return $html
 +
 
 +
}
 +
 
 +
</pre>
 +
 
 +
 
 +
*What this means is that everytime the variable action receives the value doThis from the above form, the handleAction function loads
 +
the desired action html code into the variable $html which is returned by the handleAction function.
 +
*Once returned the statement
 +
$html .= handleAction($action); appends the returned html code to the existing html code hence effectively handling the action without changing the basic page structure.

Revision as of 23:03, 8 April 2010

Project ROAR: Rhea Online Testing Resource

Introduction

Project ROAR was initiated in the Spring semester of 2010, as an attempt to provide students and professors the ability to create online tests; a forum for academic interaction, where professors could test students, and students in turn could post their own questions. The inspiration for this project came from the evident lack of an open source testing platform. Freshmen in the school of engineering, physics and math for example, are required to pay as much as $25 for similar testing software, simply to have access to pre-existing quizzes and tests. The RHEA Development team decided to overcome this problem by conceptualizing an open source web-app based on the Rhea server, that would give students and professors the same ability without the need for these expensive third party software.

The ROAR Team

Documentation

  • Project ROAR is intended to be a long-term project that starts off with a concept and basic functionality, which can then be expanded by future teams.
  • This page will serve as the ROAR development team project log, wherein all the documentation and project details may be accessed by future development teams.


The initial thought process: how ROAR was born

This section includes a preview of what the development team initially came up with for how ROAR should look and feel, as well as its functionality. The following PDF includes the thinking behind the name ROAR, as well as a mock web page showing its intended features.

Media:roar_concept.pdf


Tools

  • Since the eventual goal for ROAR is to be integrated into the MediaWiki platform where RHEA lives, what is needed is a php or javascript based web app that communicated with the RHEA database.
  • Therefore, for those interested in the project, a working knowledge of the following tools is recommended:
    • HTML
    • PHP
    • CSS
    • SQL
  • In addition knowing how to set up and work on a LAMP/WAMP server is very useful.


Code Repository

  • Rather than making individual form handling pages, it is much cleaner to organize the web app using functions.

Here is how a well organized php file ends up looking like

*****************************************
<?php


function basic_html(){

   $html = <<<page_html
              <!--------SOME HTML---------------->
           page_html;
   return $html;
}

function1(){
}
function2(){
}

if{(some action required) 
     $html .= functioncall1();
}elseif{(some other action)
     $html .= functioncall2();
}else{
     $html .= basic_html;
}

echo $html;
?>
***********************************************
  • Thus, the entire program is extremely easy to manage and various actions can be handled separately to display certain html code that can be neatly tucked away within functions.
  • Now what was given above was a very top level design of how to make a web app. The following section provides code snippets that explain the process in more detail.

Actions

  • One of the way php decides what to do with user input data is through actions.
  • HTML forms, radio buttons, checklists etc. all need a defined action when the data is submitted. The handling action may be a page, or another function within the web page.
  • Since we described in built functions as a better way of doing things, the method described here will use functions.
<form action="index.php?action=doThis"  method="post"><input type="submit" value = "Do This"></form>
  • This code generates a very simple button that says Do This. The form lives inside some html code within the file index.php.
  • Now whenever the user presses this button, the form passes the value doThis into the form action.
  • This action value is now available for handling, but to access it, we need the following code:
$action = $_GET["action"];


  • Once this is done, the value of action lives inside the variable $action. Now this can be used to call a certain function that handles this particular action. Something like
$html .= handleAction($action);

function handleAction($action){

if($action == "doThis"{
   $html = some_html_code for the desired action}
   }
return $html

}


  • What this means is that everytime the variable action receives the value doThis from the above form, the handleAction function loads

the desired action html code into the variable $html which is returned by the handleAction function.

  • Once returned the statement

$html .= handleAction($action); appends the returned html code to the existing html code hence effectively handling the action without changing the basic page structure.

Alumni Liaison

has a message for current ECE438 students.

Sean Hu, ECE PhD 2009