//////////////////////////////////////////////////
exam.info
//////////////////////////////////////////////////
; $Id: exam.info ,v-1.0 2007/02/15 dries Exp $
name = Example
description = This is Example module.
package = Core - options
version = VERSION

version = "1.0"
project = "exam"

///////////////////////////////////////////////////
exam.module
//////////////////////////////////////////////////

// $Id: exam.module , v-1.0 2007/02/15 Exp $

/**
 * @ file
 * This is file module exam
 */
 
/**
 * Implementation of hook_help()
 */
function exam_help($section) {
 
	return $output;
} 

/**
 * Implementation of hook_perm()
 */
function exam_perm() {
  return array('exam admin access', 'exam user access');
}

/**
 * Implementation of hook_menu()
 */
function exam_menu() {
	 $items 	= NULL;
	 $access_admin 	= user_access('route admin access');
	 
	 $items[] = array(
	  'path'  => 'admin/telecom/exam',
	  'title'  => t('exam'),
	  'description' => t("View, edit, and delete your site's exam"),
	  'callback' => 'drupal_get_form',
	  'callback arguments' => array('exam_admin_edit'),
	  'access' => $access_admin,
	 );

	 $items[] = array(
	  'path'  => 'admin/telecom/exam/list',
	  'title'  => t('List exam'),
	  'description' => t("View, edit, and delete your site's exam"),
	  'callback' => 'drupal_get_form',
	  'callback arguments' => array('exam_admin_edit'),
	  'access' => $access_admin,
	  'type'  =>  MENU_DEFAULT_LOCAL_TASK,
	  'weight' => 0
	 );
	 
	 return $items;
} 
 
/**
 * User define add exam 
 * Show form add exam    func: exam_admin_admin()
 */
function exam_admin_edit() {
	
	$form['name'] = array(
		'#type'	=> 'textfield',
		'#title'=> t('Name'),
		'#size' => 25
	);
	$form['age'] = array(
		'#type'	=> 'textfield',
		'#title'=> t('age'),
		'#size' => 25
	);
	$form['submit'] = array(
		'#type'	=>	'submit',
		'#value'=> t('Sunmit')
	);
	
	$row = array(4, 5, 6);
	
	if($_POST['submit'])
		$row = array($_POST['name'], $_POST['age'], 3);
	
	$header = array(t('One'), t('Two'), t('Three'));
	
	$form['table'] = array(
		'#type'		=> 'item',
		'#value'	=>	template($header, $row)
	);
	
	
	
	return $form;
}


function template($header, $rows) {
	$output = "<table><tr>";
	for($i=0; $i<count($header); $i++) {
		$output .= "<td>".$header[$i]."</td>"; 
	}
	$output .= "</tr><tr>";
	for($i=0; $i<count($rows); $i++) {
		$output .= "<td>".$rows[$i]."</td>";
	}
	$output .= "</tr></table>";
	
	return $output;
}