Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/CCEExamQuestionslist.php

<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "CCEExamQuestionsinfo.php" ?>
<?php include "CCEUsersinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Create page object
$CCEExamQuestions_list = new cCCEExamQuestions_list();
$Page =& $CCEExamQuestions_list;

// Page init
$CCEExamQuestions_list->Page_Init();

// Page main
$CCEExamQuestions_list->Page_Main();
?>
<?php include "header.php" ?>
<?php if ($CCEExamQuestions->Export == "") { ?>
<script type="text/javascript">
<!--

// Create page object
var CCEExamQuestions_list = new ew_Page("CCEExamQuestions_list");

// page properties
CCEExamQuestions_list.PageID = "list"; // page ID
CCEExamQuestions_list.FormID = "fCCEExamQuestionslist"; // form ID
var EW_PAGE_ID = CCEExamQuestions_list.PageID; // for backward compatibility

// extend page with validate function for search
CCEExamQuestions_list.ValidateSearch = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (this.ValidateRequired) {
		var infix = "";

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj))
			return false;
	}
	for (var i=0; i<fobj.elements.length; i++) {
		var elem = fobj.elements[i];
		if (elem.name.substring(0,2) == "s_" || elem.name.substring(0,3) == "sv_")
			elem.value = "";
	}
	return true;
}

// extend page with Form_CustomValidate function
CCEExamQuestions_list.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
CCEExamQuestions_list.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCEExamQuestions_list.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="js/ckeditor-patch.js"></script>
<script type="text/javascript">
<!--
_width_multiplier = 20;
_height_multiplier = 60;
var ew_DHTMLEditors = [];

// update value from editor to textarea
function ew_UpdateTextArea() {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof CKEDITOR != 'undefined') {			
		var inst;			
		for (inst in CKEDITOR.instances)
			CKEDITOR.instances[inst].updateElement();
	}
}

// update value from textarea to editor
function ew_UpdateDHTMLEditor(name) {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof CKEDITOR != 'undefined') {
		var inst = CKEDITOR.instances[name];		
		if (inst)
			inst.setData(inst.element.value);
	}
}

// focus editor
function ew_FocusDHTMLEditor(name) {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof CKEDITOR != 'undefined') {
		var inst = CKEDITOR.instances[name];	
		if (inst)
			inst.focus();
	}
}

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<?php } ?>
<?php if ($CCEExamQuestions->Export == "") { ?>
<?php } ?>
<?php
	$bSelectLimit = EW_SELECT_LIMIT;
	if ($bSelectLimit) {
		$CCEExamQuestions_list->lTotalRecs = $CCEExamQuestions->SelectRecordCount();
	} else {
		if ($rs = $CCEExamQuestions_list->LoadRecordset())
			$CCEExamQuestions_list->lTotalRecs = $rs->RecordCount();
	}
	$CCEExamQuestions_list->lStartRec = 1;
	if ($CCEExamQuestions_list->lDisplayRecs <= 0 || ($CCEExamQuestions->Export <> "" && $CCEExamQuestions->ExportAll)) // Display all records
		$CCEExamQuestions_list->lDisplayRecs = $CCEExamQuestions_list->lTotalRecs;
	if (!($CCEExamQuestions->Export <> "" && $CCEExamQuestions->ExportAll))
		$CCEExamQuestions_list->SetUpStartRec(); // Set up start record position
	if ($bSelectLimit)
		$rs = $CCEExamQuestions_list->LoadRecordset($CCEExamQuestions_list->lStartRec-1, $CCEExamQuestions_list->lDisplayRecs);
?>
<p><span class="phpmaker" style="white-space: nowrap;"><?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CCEExamQuestions->TableCaption() ?>
<?php if ($CCEExamQuestions->Export == "" && $CCEExamQuestions->CurrentAction == "") { ?>
&nbsp;&nbsp;<a href="<?php echo $CCEExamQuestions_list->ExportPrintUrl ?>"><img src="images/print.gif" alt="<?php echo ew_HtmlEncode($Language->Phrase("PrinterFriendly")) ?>" title="<?php echo ew_HtmlEncode($Language->Phrase("PrinterFriendly")) ?>" width="16" height="16" border="0"></a>
&nbsp;&nbsp;<a href="<?php echo $CCEExamQuestions_list->ExportExcelUrl ?>"><img src='images/exportxls.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("ExportToExcel")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("ExportToExcel")) ?>' width='16' height='16' border='0'></a>
&nbsp;&nbsp;<a href="<?php echo $CCEExamQuestions_list->ExportWordUrl ?>"><img src='images/exportdoc.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("ExportToWord")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("ExportToWord")) ?>' width='16' height='16' border='0'></a>
&nbsp;&nbsp;<a name="emf_CCEExamQuestions" id="emf_CCEExamQuestions" href="javascript:void(0);" onclick="ew_EmailDialogShow({lnk:'emf_CCEExamQuestions',hdr:ewLanguage.Phrase('ExportToEmail'),f:document.fCCEExamQuestionslist,sel:false});"><img src='images/exportemail.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("ExportToEmail")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("ExportToEmail")) ?>' width='16' height='16' border='0'></a>
<?php } ?>
</span></p>
<?php if ($Security->CanSearch()) { ?>
<?php if ($CCEExamQuestions->Export == "" && $CCEExamQuestions->CurrentAction == "") { ?>
<a href="javascript:ew_ToggleSearchPanel(CCEExamQuestions_list);" style="text-decoration: none;"><img id="CCEExamQuestions_list_SearchImage" src="images/collapse.gif" alt="" width="9" height="9" border="0"></a><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("Search") ?></span><br>
<div id="CCEExamQuestions_list_SearchPanel">
<form name="fCCEExamQuestionslistsrch" id="fCCEExamQuestionslistsrch" class="ewForm" action="<?php echo ew_CurrentPage() ?>" onsubmit="return CCEExamQuestions_list.ValidateSearch(this);">
<input type="hidden" id="t" name="t" value="CCEExamQuestions">
<?php
if ($gsSearchError == "")
	$CCEExamQuestions_list->LoadAdvancedSearch(); // Load advanced search

// Render for search
$CCEExamQuestions->RowType = EW_ROWTYPE_SEARCH;

// Render row
$CCEExamQuestions_list->RenderRow();
?>
<table class="ewBasicSearch">
	<tr>
		<td><span class="phpmaker"><?php echo $CCEExamQuestions->Questionnaire_ID->FldCaption() ?></span></td>
		<td><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_Questionnaire_ID" id="z_Questionnaire_ID" value="="></span></td>
		<td>			
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<?php $CCEExamQuestions->Questionnaire_ID->EditAttrs["onchange"] = "ew_UpdateOpt('x_Section_ID','x_Questionnaire_ID',true); " . @$CCEExamQuestions->Questionnaire_ID->EditAttrs["onchange"]; ?>
<select id="x_Questionnaire_ID" name="x_Questionnaire_ID" title="<?php echo $CCEExamQuestions->Questionnaire_ID->FldTitle() ?>"<?php echo $CCEExamQuestions->Questionnaire_ID->EditAttributes() ?>>
<?php
if (is_array($CCEExamQuestions->Questionnaire_ID->EditValue)) {
	$arwrk = $CCEExamQuestions->Questionnaire_ID->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEExamQuestions->Questionnaire_ID->AdvancedSearch->SearchValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span>
			</div>
		</td>
	</tr>
	<tr>
		<td><span class="phpmaker"><?php echo $CCEExamQuestions->Section_ID->FldCaption() ?></span></td>
		<td><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_Section_ID" id="z_Section_ID" value="="></span></td>
		<td>			
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<select id="x_Section_ID" name="x_Section_ID" title="<?php echo $CCEExamQuestions->Section_ID->FldTitle() ?>"<?php echo $CCEExamQuestions->Section_ID->EditAttributes() ?>>
<?php
if (is_array($CCEExamQuestions->Section_ID->EditValue)) {
	$arwrk = $CCEExamQuestions->Section_ID->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEExamQuestions->Section_ID->AdvancedSearch->SearchValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `Section_ID`, `Section_Name`, '' AS Disp2Fld FROM `CCEExamSections`";
$sWhereWrk = "`Questionnaire_ID` IN ({filter_value})";
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY `Display_Order` Asc";
$sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
?>
<input type="hidden" name="s_x_Section_ID" id="s_x_Section_ID" value="<?php echo $sSqlWrk; ?>">
<input type="hidden" name="lft_x_Section_ID" id="lft_x_Section_ID" value="1">
</span>
			</div>
		</td>
	</tr>
</table>
<table class="ewBasicSearch">
	<tr>
		<td><span class="phpmaker">
			<input type="text" name="<?php echo EW_TABLE_BASIC_SEARCH ?>" id="<?php echo EW_TABLE_BASIC_SEARCH ?>" size="20" value="<?php echo ew_HtmlEncode($CCEExamQuestions->getSessionBasicSearchKeyword()) ?>">
			<input type="Submit" name="Submit" id="Submit" value="<?php echo ew_BtnCaption($Language->Phrase("QuickSearchBtn")) ?>">&nbsp;
			<a href="<?php echo $CCEExamQuestions_list->PageUrl() ?>cmd=reset"><?php echo $Language->Phrase("ShowAll") ?></a>&nbsp;
		</span></td>
	</tr>
	<tr>
	<td><span class="phpmaker"><label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value=""<?php if ($CCEExamQuestions->getSessionBasicSearchType() == "") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("ExactPhrase") ?></label>&nbsp;&nbsp;<label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="AND"<?php if ($CCEExamQuestions->getSessionBasicSearchType() == "AND") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("AllWord") ?></label>&nbsp;&nbsp;<label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="OR"<?php if ($CCEExamQuestions->getSessionBasicSearchType() == "OR") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("AnyWord") ?></label></span></td>
	</tr>
</table>
</form>
</div>
<?php } ?>
<?php } ?>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$CCEExamQuestions_list->ShowMessage();
?>
<br>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<?php if ($CCEExamQuestions->Export == "") { ?>
<div class="ewGridUpperPanel">
<?php if ($CCEExamQuestions->CurrentAction <> "gridadd" && $CCEExamQuestions->CurrentAction <> "gridedit") { ?>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
	<tr>
		<td nowrap>
<?php if (!isset($CCEExamQuestions_list->Pager)) $CCEExamQuestions_list->Pager = new cPrevNextPager($CCEExamQuestions_list->lStartRec, $CCEExamQuestions_list->lDisplayRecs, $CCEExamQuestions_list->lTotalRecs) ?>
<?php if ($CCEExamQuestions_list->Pager->RecordCount > 0) { ?>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><?php echo $Language->Phrase("Page") ?>&nbsp;</span></td>
<!--first page button-->
	<?php if ($CCEExamQuestions_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $CCEExamQuestions_list->PageUrl() ?>start=<?php echo $CCEExamQuestions_list->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/firstdisab.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--previous page button-->
	<?php if ($CCEExamQuestions_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $CCEExamQuestions_list->PageUrl() ?>start=<?php echo $CCEExamQuestions_list->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/prevdisab.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--current page number-->
	<td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $CCEExamQuestions_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($CCEExamQuestions_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $CCEExamQuestions_list->PageUrl() ?>start=<?php echo $CCEExamQuestions_list->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/nextdisab.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--last page button-->
	<?php if ($CCEExamQuestions_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $CCEExamQuestions_list->PageUrl() ?>start=<?php echo $CCEExamQuestions_list->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/lastdisab.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
	<td><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("of") ?>&nbsp;<?php echo $CCEExamQuestions_list->Pager->PageCount ?></span></td>
	</tr></table>
	</td>	
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>
	<span class="phpmaker"><?php echo $Language->Phrase("Record") ?>&nbsp;<?php echo $CCEExamQuestions_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $CCEExamQuestions_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $CCEExamQuestions_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($CCEExamQuestions_list->sSrchWhere == "0=101") { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("EnterSearchCriteria") ?></span>
	<?php } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoRecord") ?></span>
	<?php } ?>
	<?php } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoPermission") ?></span>
	<?php } ?>
<?php } ?>
		</td>
	</tr>
</table>
</form>
<?php } ?>
<span class="phpmaker">
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $CCEExamQuestions_list->AddUrl ?>"><?php echo $Language->Phrase("AddLink") ?></a>&nbsp;&nbsp;
<?php } ?>
</span>
</div>
<?php } ?>
<form name="fCCEExamQuestionslist" id="fCCEExamQuestionslist" class="ewForm" action="" method="post">
<div id="gmp_CCEExamQuestions" class="ewGridMiddlePanel">
<?php if ($CCEExamQuestions_list->lTotalRecs > 0) { ?>
<table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
<?php echo $CCEExamQuestions->TableCustomInnerHtml ?>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<?php

// Render list options
$CCEExamQuestions_list->RenderListOptions();

// Render list options (header, left)
$CCEExamQuestions_list->ListOptions->Render("header", "left");
?>
<?php if ($CCEExamQuestions->Question_ID->Visible) { // Question_ID ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->Question_ID) == "") { ?>
		<td><?php echo $CCEExamQuestions->Question_ID->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->Question_ID) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->Question_ID->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->Question_ID->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->Question_ID->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->Questionnaire_ID->Visible) { // Questionnaire_ID ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->Questionnaire_ID) == "") { ?>
		<td><?php echo $CCEExamQuestions->Questionnaire_ID->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->Questionnaire_ID) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->Questionnaire_ID->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->Questionnaire_ID->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->Questionnaire_ID->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->Section_ID->Visible) { // Section_ID ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->Section_ID) == "") { ?>
		<td><?php echo $CCEExamQuestions->Section_ID->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->Section_ID) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->Section_ID->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->Section_ID->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->Section_ID->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->Question->Visible) { // Question ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->Question) == "") { ?>
		<td><?php echo $CCEExamQuestions->Question->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->Question) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->Question->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->Question->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->Question->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->Display_Order->Visible) { // Display_Order ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->Display_Order) == "") { ?>
		<td><?php echo $CCEExamQuestions->Display_Order->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->Display_Order) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->Display_Order->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->Display_Order->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->Display_Order->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->IsMulti->Visible) { // IsMulti ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->IsMulti) == "") { ?>
		<td><?php echo $CCEExamQuestions->IsMulti->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->IsMulti) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->IsMulti->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->IsMulti->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->IsMulti->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->IsOptional->Visible) { // IsOptional ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->IsOptional) == "") { ?>
		<td><?php echo $CCEExamQuestions->IsOptional->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->IsOptional) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->IsOptional->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->IsOptional->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->IsOptional->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->Answer_Type->Visible) { // Answer_Type ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->Answer_Type) == "") { ?>
		<td><?php echo $CCEExamQuestions->Answer_Type->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->Answer_Type) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->Answer_Type->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->Answer_Type->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->Answer_Type->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->Answer_Template->Visible) { // Answer_Template ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->Answer_Template) == "") { ?>
		<td><?php echo $CCEExamQuestions->Answer_Template->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->Answer_Template) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->Answer_Template->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->Answer_Template->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->Answer_Template->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->Model_Answer->Visible) { // Model_Answer ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->Model_Answer) == "") { ?>
		<td><?php echo $CCEExamQuestions->Model_Answer->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->Model_Answer) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->Model_Answer->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->Model_Answer->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->Model_Answer->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->ParentQuestionID->Visible) { // ParentQuestionID ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->ParentQuestionID) == "") { ?>
		<td><?php echo $CCEExamQuestions->ParentQuestionID->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->ParentQuestionID) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->ParentQuestionID->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->ParentQuestionID->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->ParentQuestionID->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->RequireNumber->Visible) { // RequireNumber ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->RequireNumber) == "") { ?>
		<td><?php echo $CCEExamQuestions->RequireNumber->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->RequireNumber) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->RequireNumber->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->RequireNumber->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->RequireNumber->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->MinNum->Visible) { // MinNum ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->MinNum) == "") { ?>
		<td><?php echo $CCEExamQuestions->MinNum->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->MinNum) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->MinNum->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->MinNum->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->MinNum->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->MaxNum->Visible) { // MaxNum ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->MaxNum) == "") { ?>
		<td><?php echo $CCEExamQuestions->MaxNum->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->MaxNum) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->MaxNum->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->MaxNum->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->MaxNum->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->RecallPrevAnswer->Visible) { // RecallPrevAnswer ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->RecallPrevAnswer) == "") { ?>
		<td><?php echo $CCEExamQuestions->RecallPrevAnswer->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->RecallPrevAnswer) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->RecallPrevAnswer->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->RecallPrevAnswer->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->RecallPrevAnswer->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->QuestionTitle->Visible) { // QuestionTitle ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->QuestionTitle) == "") { ?>
		<td><?php echo $CCEExamQuestions->QuestionTitle->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->QuestionTitle) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->QuestionTitle->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->QuestionTitle->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->QuestionTitle->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->NumMarks->Visible) { // NumMarks ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->NumMarks) == "") { ?>
		<td><?php echo $CCEExamQuestions->NumMarks->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->NumMarks) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->NumMarks->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->NumMarks->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->NumMarks->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($CCEExamQuestions->InUse->Visible) { // InUse ?>
	<?php if ($CCEExamQuestions->SortUrl($CCEExamQuestions->InUse) == "") { ?>
		<td><?php echo $CCEExamQuestions->InUse->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $CCEExamQuestions->SortUrl($CCEExamQuestions->InUse) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEExamQuestions->InUse->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEExamQuestions->InUse->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEExamQuestions->InUse->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php

// Render list options (header, right)
$CCEExamQuestions_list->ListOptions->Render("header", "right");
?>
	</tr>
</thead>
<?php
if ($CCEExamQuestions->ExportAll && $CCEExamQuestions->Export <> "") {
	$CCEExamQuestions_list->lStopRec = $CCEExamQuestions_list->lTotalRecs;
} else {
	$CCEExamQuestions_list->lStopRec = $CCEExamQuestions_list->lStartRec + $CCEExamQuestions_list->lDisplayRecs - 1; // Set the last record to display
}
$CCEExamQuestions_list->lRecCount = $CCEExamQuestions_list->lStartRec - 1;
if ($rs && !$rs->EOF) {
	$rs->MoveFirst();
	if (!$bSelectLimit && $CCEExamQuestions_list->lStartRec > 1)
		$rs->Move($CCEExamQuestions_list->lStartRec - 1);
}

// Initialize aggregate
$CCEExamQuestions->RowType = EW_ROWTYPE_AGGREGATEINIT;
$CCEExamQuestions_list->RenderRow();
$CCEExamQuestions_list->lRowCnt = 0;
while (($CCEExamQuestions->CurrentAction == "gridadd" || !$rs->EOF) &&
	$CCEExamQuestions_list->lRecCount < $CCEExamQuestions_list->lStopRec) {
	$CCEExamQuestions_list->lRecCount++;
	if (intval($CCEExamQuestions_list->lRecCount) >= intval($CCEExamQuestions_list->lStartRec)) {
		$CCEExamQuestions_list->lRowCnt++;

	// Init row class and style
	$CCEExamQuestions->CssClass = "";
	$CCEExamQuestions->CssStyle = "";
	$CCEExamQuestions->RowAttrs = array('onmouseover'=>'ew_MouseOver(event, this);', 'onmouseout'=>'ew_MouseOut(event, this);', 'onclick'=>'ew_Click(event, this);');
	if ($CCEExamQuestions->CurrentAction == "gridadd") {
		$CCEExamQuestions_list->LoadDefaultValues(); // Load default values
	} else {
		$CCEExamQuestions_list->LoadRowValues($rs); // Load row values
	}
	$CCEExamQuestions->RowType = EW_ROWTYPE_VIEW; // Render view

	// Render row
	$CCEExamQuestions_list->RenderRow();

	// Render list options
	$CCEExamQuestions_list->RenderListOptions();
?>
	<tr<?php echo $CCEExamQuestions->RowAttributes() ?>>
<?php

// Render list options (body, left)
$CCEExamQuestions_list->ListOptions->Render("body", "left");
?>
	<?php if ($CCEExamQuestions->Question_ID->Visible) { // Question_ID ?>
		<td<?php echo $CCEExamQuestions->Question_ID->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->Question_ID->ViewAttributes() ?>><?php echo $CCEExamQuestions->Question_ID->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->Questionnaire_ID->Visible) { // Questionnaire_ID ?>
		<td<?php echo $CCEExamQuestions->Questionnaire_ID->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->Questionnaire_ID->ViewAttributes() ?>><?php echo $CCEExamQuestions->Questionnaire_ID->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->Section_ID->Visible) { // Section_ID ?>
		<td<?php echo $CCEExamQuestions->Section_ID->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->Section_ID->ViewAttributes() ?>><?php echo $CCEExamQuestions->Section_ID->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->Question->Visible) { // Question ?>
		<td<?php echo $CCEExamQuestions->Question->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->Question->ViewAttributes() ?>><?php echo $CCEExamQuestions->Question->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->Display_Order->Visible) { // Display_Order ?>
		<td<?php echo $CCEExamQuestions->Display_Order->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->Display_Order->ViewAttributes() ?>><?php echo $CCEExamQuestions->Display_Order->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->IsMulti->Visible) { // IsMulti ?>
		<td<?php echo $CCEExamQuestions->IsMulti->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->IsMulti->ViewAttributes() ?>><?php echo $CCEExamQuestions->IsMulti->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->IsOptional->Visible) { // IsOptional ?>
		<td<?php echo $CCEExamQuestions->IsOptional->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->IsOptional->ViewAttributes() ?>><?php echo $CCEExamQuestions->IsOptional->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->Answer_Type->Visible) { // Answer_Type ?>
		<td<?php echo $CCEExamQuestions->Answer_Type->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->Answer_Type->ViewAttributes() ?>><?php echo $CCEExamQuestions->Answer_Type->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->Answer_Template->Visible) { // Answer_Template ?>
		<td<?php echo $CCEExamQuestions->Answer_Template->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->Answer_Template->ViewAttributes() ?>><?php echo $CCEExamQuestions->Answer_Template->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->Model_Answer->Visible) { // Model_Answer ?>
		<td<?php echo $CCEExamQuestions->Model_Answer->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->Model_Answer->ViewAttributes() ?>><?php echo $CCEExamQuestions->Model_Answer->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->ParentQuestionID->Visible) { // ParentQuestionID ?>
		<td<?php echo $CCEExamQuestions->ParentQuestionID->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->ParentQuestionID->ViewAttributes() ?>><?php echo $CCEExamQuestions->ParentQuestionID->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->RequireNumber->Visible) { // RequireNumber ?>
		<td<?php echo $CCEExamQuestions->RequireNumber->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->RequireNumber->ViewAttributes() ?>><?php echo $CCEExamQuestions->RequireNumber->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->MinNum->Visible) { // MinNum ?>
		<td<?php echo $CCEExamQuestions->MinNum->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->MinNum->ViewAttributes() ?>><?php echo $CCEExamQuestions->MinNum->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->MaxNum->Visible) { // MaxNum ?>
		<td<?php echo $CCEExamQuestions->MaxNum->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->MaxNum->ViewAttributes() ?>><?php echo $CCEExamQuestions->MaxNum->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->RecallPrevAnswer->Visible) { // RecallPrevAnswer ?>
		<td<?php echo $CCEExamQuestions->RecallPrevAnswer->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->RecallPrevAnswer->ViewAttributes() ?>><?php echo $CCEExamQuestions->RecallPrevAnswer->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->QuestionTitle->Visible) { // QuestionTitle ?>
		<td<?php echo $CCEExamQuestions->QuestionTitle->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->QuestionTitle->ViewAttributes() ?>><?php echo $CCEExamQuestions->QuestionTitle->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->NumMarks->Visible) { // NumMarks ?>
		<td<?php echo $CCEExamQuestions->NumMarks->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->NumMarks->ViewAttributes() ?>><?php echo $CCEExamQuestions->NumMarks->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($CCEExamQuestions->InUse->Visible) { // InUse ?>
		<td<?php echo $CCEExamQuestions->InUse->CellAttributes() ?>>
<div<?php echo $CCEExamQuestions->InUse->ViewAttributes() ?>><?php echo $CCEExamQuestions->InUse->ListViewValue() ?></div>
</td>
	<?php } ?>
<?php

// Render list options (body, right)
$CCEExamQuestions_list->ListOptions->Render("body", "right");
?>
	</tr>
<?php
	}
	if ($CCEExamQuestions->CurrentAction <> "gridadd")
		$rs->MoveNext();
}
?>
</tbody>
</table>
<?php } ?>
</div>
</form>
<?php

// Close recordset
if ($rs)
	$rs->Close();
?>
<?php if ($CCEExamQuestions_list->lTotalRecs > 0) { ?>
<?php if ($CCEExamQuestions->Export == "") { ?>
<div class="ewGridLowerPanel">
<?php if ($CCEExamQuestions->CurrentAction <> "gridadd" && $CCEExamQuestions->CurrentAction <> "gridedit") { ?>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
	<tr>
		<td nowrap>
<?php if (!isset($CCEExamQuestions_list->Pager)) $CCEExamQuestions_list->Pager = new cPrevNextPager($CCEExamQuestions_list->lStartRec, $CCEExamQuestions_list->lDisplayRecs, $CCEExamQuestions_list->lTotalRecs) ?>
<?php if ($CCEExamQuestions_list->Pager->RecordCount > 0) { ?>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><?php echo $Language->Phrase("Page") ?>&nbsp;</span></td>
<!--first page button-->
	<?php if ($CCEExamQuestions_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $CCEExamQuestions_list->PageUrl() ?>start=<?php echo $CCEExamQuestions_list->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/firstdisab.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--previous page button-->
	<?php if ($CCEExamQuestions_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $CCEExamQuestions_list->PageUrl() ?>start=<?php echo $CCEExamQuestions_list->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/prevdisab.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--current page number-->
	<td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $CCEExamQuestions_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($CCEExamQuestions_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $CCEExamQuestions_list->PageUrl() ?>start=<?php echo $CCEExamQuestions_list->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/nextdisab.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--last page button-->
	<?php if ($CCEExamQuestions_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $CCEExamQuestions_list->PageUrl() ?>start=<?php echo $CCEExamQuestions_list->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/lastdisab.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
	<td><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("of") ?>&nbsp;<?php echo $CCEExamQuestions_list->Pager->PageCount ?></span></td>
	</tr></table>
	</td>	
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>
	<span class="phpmaker"><?php echo $Language->Phrase("Record") ?>&nbsp;<?php echo $CCEExamQuestions_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $CCEExamQuestions_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $CCEExamQuestions_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($CCEExamQuestions_list->sSrchWhere == "0=101") { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("EnterSearchCriteria") ?></span>
	<?php } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoRecord") ?></span>
	<?php } ?>
	<?php } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoPermission") ?></span>
	<?php } ?>
<?php } ?>
		</td>
	</tr>
</table>
</form>
<?php } ?>
<?php //if ($CCEExamQuestions_list->lTotalRecs > 0) { ?>
<span class="phpmaker">
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $CCEExamQuestions_list->AddUrl ?>"><?php echo $Language->Phrase("AddLink") ?></a>&nbsp;&nbsp;
<?php } ?>
</span>
<?php //} ?>
</div>
<?php } ?>
<?php } ?>
</td></tr></table>
<?php if ($CCEExamQuestions->Export == "" && $CCEExamQuestions->CurrentAction == "") { ?>
<script language="JavaScript" type="text/javascript">
<!--
ew_UpdateOpts([['x_Section_ID','x_Questionnaire_ID',false]]);

//-->
</script>
<?php } ?>
<?php if ($CCEExamQuestions->Export == "") { ?>
<script type="text/javascript">
<!--
ew_CreateEditor();  // Create DHTML editor(s)

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php } ?>
<?php include "footer.php" ?>
<?php
$CCEExamQuestions_list->Page_Terminate();
?>
<?php

//
// Page class
//
class cCCEExamQuestions_list {

	// Page ID
	var $PageID = 'list';

	// Table name
	var $TableName = 'CCEExamQuestions';

	// Page object name
	var $PageObjName = 'CCEExamQuestions_list';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $CCEExamQuestions;
		if ($CCEExamQuestions->UseTokenInUrl) $PageUrl .= "t=" . $CCEExamQuestions->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage);
		if ($sMessage <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm, $CCEExamQuestions;
		if ($CCEExamQuestions->UseTokenInUrl) {
			if ($objForm)
				return ($CCEExamQuestions->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($CCEExamQuestions->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function __construct() {
		global $conn, $Language;

		// Language object
		$Language = new cLanguage();

		// Table object (CCEExamQuestions)
		$GLOBALS["CCEExamQuestions"] = new cCCEExamQuestions();

		// Initialize URLs
		$this->ExportPrintUrl = $this->PageUrl() . "export=print";
		$this->ExportExcelUrl = $this->PageUrl() . "export=excel";
		$this->ExportWordUrl = $this->PageUrl() . "export=word";
		$this->ExportHtmlUrl = $this->PageUrl() . "export=html";
		$this->ExportXmlUrl = $this->PageUrl() . "export=xml";
		$this->ExportCsvUrl = $this->PageUrl() . "export=csv";
		$this->AddUrl = $GLOBALS["CCEExamQuestions"]->AddUrl();
		$this->InlineAddUrl = $this->PageUrl() . "a=add";
		$this->GridAddUrl = $this->PageUrl() . "a=gridadd";
		$this->GridEditUrl = $this->PageUrl() . "a=gridedit";
		$this->MultiDeleteUrl = "CCEExamQuestionsdelete.php";
		$this->MultiUpdateUrl = "CCEExamQuestionsupdate.php";

		// Table object (CCEUsers)
		$GLOBALS['CCEUsers'] = new cCCEUsers();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'list', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'CCEExamQuestions', TRUE);

		// Start timer
		$GLOBALS["gsTimer"] = new cTimer();

		// Open connection
		$conn = ew_Connect();

		// List options
		$this->ListOptions = new cListOptions();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
		global $CCEExamQuestions;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		$Security->TablePermission_Loading();
		$Security->LoadCurrentUserLevel($this->TableName);
		$Security->TablePermission_Loaded();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		if (!$Security->CanList()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}

		// Get export parameters
		if (@$_GET["export"] <> "") {
			$CCEExamQuestions->Export = $_GET["export"];
		} elseif (ew_IsHttpPost()) {
			if (@$_POST["exporttype"] <> "")
				$CCEExamQuestions->Export = $_POST["exporttype"];
		} else {
			$CCEExamQuestions->setExportReturnUrl(ew_CurrentUrl());
		}
		$gsExport = $CCEExamQuestions->Export; // Get export parameter, used in header
		$gsExportFile = $CCEExamQuestions->TableVar; // Get export file, used in header
		if ($CCEExamQuestions->Export == "excel") {
			header('Content-Type: application/vnd.ms-excel');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
		}
		if ($CCEExamQuestions->Export == "word") {
			header('Content-Type: application/vnd.ms-word');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.doc');
		}

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		$this->Page_Redirecting($url);
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}

	// Class variables
	var $ListOptions; // List options
	var $lDisplayRecs = 40;
	var $lStartRec;
	var $lStopRec;
	var $lTotalRecs = 0;
	var $lRecRange = 10;
	var $sSrchWhere = ""; // Search WHERE clause
	var $lRecCnt = 0; // Record count
	var $lEditRowCnt;
	var $lRowCnt;
	var $lRowIndex; // Row index
	var $lRecPerRow = 0;
	var $lColCnt = 0;
	var $sDbMasterFilter = ""; // Master filter
	var $sDbDetailFilter = ""; // Detail filter
	var $bMasterRecordExists;	
	var $sMultiSelectKey;
	var $RestoreSearch;

	//
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsSearchError, $Security, $CCEExamQuestions;

		// Search filters
		$sSrchAdvanced = ""; // Advanced search filter
		$sSrchBasic = ""; // Basic search filter
		$sFilter = "";
		if ($this->IsPageRequest()) { // Validate request

			// Handle reset command
			$this->ResetCmd();

			// Set up list options
			$this->SetupListOptions();

			// Get basic search values
			$this->LoadBasicSearchValues();

			// Get and validate search values for advanced search
			$this->LoadSearchValues(); // Get search values
			if (!$this->ValidateSearch())
				$this->setMessage($gsSearchError);

			// Restore search parms from Session
			$this->RestoreSearchParms();

			// Call Recordset SearchValidated event
			$CCEExamQuestions->Recordset_SearchValidated();

			// Set up sorting order
			$this->SetUpSortOrder();

			// Get basic search criteria
			if ($gsSearchError == "")
				$sSrchBasic = $this->BasicSearchWhere();

			// Get search criteria for advanced search
			if ($gsSearchError == "")
				$sSrchAdvanced = $this->AdvancedSearchWhere();
		}

		// Restore display records
		if ($CCEExamQuestions->getRecordsPerPage() <> "") {
			$this->lDisplayRecs = $CCEExamQuestions->getRecordsPerPage(); // Restore from Session
		} else {
			$this->lDisplayRecs = 40; // Load default
		}

		// Load Sorting Order
		$this->LoadSortOrder();

		// Build search criteria
		if ($sSrchAdvanced <> "")
			$this->sSrchWhere = ($this->sSrchWhere <> "") ? "(" . $this->sSrchWhere . ") AND (" . $sSrchAdvanced . ")" : $sSrchAdvanced;
		if ($sSrchBasic <> "")
			$this->sSrchWhere = ($this->sSrchWhere <> "") ? "(" . $this->sSrchWhere . ") AND (" . $sSrchBasic. ")" : $sSrchBasic;

		// Call Recordset_Searching event
		$CCEExamQuestions->Recordset_Searching($this->sSrchWhere);

		// Save search criteria
		if ($this->sSrchWhere <> "") {
			if ($sSrchBasic == "")
				$this->ResetBasicSearchParms();
			if ($sSrchAdvanced == "")
				$this->ResetAdvancedSearchParms();
			$CCEExamQuestions->setSearchWhere($this->sSrchWhere); // Save to Session
			if (!$this->RestoreSearch) {
				$this->lStartRec = 1; // Reset start record counter
				$CCEExamQuestions->setStartRecordNumber($this->lStartRec);
			}
		} else {
			$this->sSrchWhere = $CCEExamQuestions->getSearchWhere();
		}

		// Build filter
		$sFilter = "";
		if (!$Security->CanList())
			$sFilter = "(0=1)"; // Filter all records
		if ($this->sDbDetailFilter <> "")
			$sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (" . $this->sDbDetailFilter . ")" : $this->sDbDetailFilter;
		if ($this->sSrchWhere <> "")
			$sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (". $this->sSrchWhere . ")" : $this->sSrchWhere;

		// Set up filter in session
		$CCEExamQuestions->setSessionWhere($sFilter);
		$CCEExamQuestions->CurrentFilter = "";

		// Export data only
		if (in_array($CCEExamQuestions->Export, array("html","word","excel","xml","csv","email"))) {
			$this->ExportData();
			if ($CCEExamQuestions->Export <> "email")
				$this->Page_Terminate(); // Terminate response
			exit();
		}
	}

	// Advanced search WHERE clause based on QueryString
	function AdvancedSearchWhere() {
		global $Security, $CCEExamQuestions;
		$sWhere = "";
		if (!$Security->CanSearch()) return "";
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->Question_ID, FALSE); // Question_ID
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->Questionnaire_ID, FALSE); // Questionnaire_ID
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->Section_ID, FALSE); // Section_ID
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->Question, FALSE); // Question
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->Display_Order, FALSE); // Display_Order
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->IsMulti, FALSE); // IsMulti
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->IsOptional, FALSE); // IsOptional
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->Answer_Type, FALSE); // Answer_Type
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->Answer_Template, FALSE); // Answer_Template
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->Model_Answer, FALSE); // Model_Answer
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->ParentQuestionID, FALSE); // ParentQuestionID
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->RequireNumber, FALSE); // RequireNumber
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->MinNum, FALSE); // MinNum
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->MaxNum, FALSE); // MaxNum
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->RecallPrevAnswer, FALSE); // RecallPrevAnswer
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->QuestionTitle, FALSE); // QuestionTitle
		$this->BuildSearchSql($sWhere, $CCEExamQuestions->NumMarks, FALSE); // NumMarks

		// Set up search parm
		if ($sWhere <> "") {
			$this->SetSearchParm($CCEExamQuestions->Question_ID); // Question_ID
			$this->SetSearchParm($CCEExamQuestions->Questionnaire_ID); // Questionnaire_ID
			$this->SetSearchParm($CCEExamQuestions->Section_ID); // Section_ID
			$this->SetSearchParm($CCEExamQuestions->Question); // Question
			$this->SetSearchParm($CCEExamQuestions->Display_Order); // Display_Order
			$this->SetSearchParm($CCEExamQuestions->IsMulti); // IsMulti
			$this->SetSearchParm($CCEExamQuestions->IsOptional); // IsOptional
			$this->SetSearchParm($CCEExamQuestions->Answer_Type); // Answer_Type
			$this->SetSearchParm($CCEExamQuestions->Answer_Template); // Answer_Template
			$this->SetSearchParm($CCEExamQuestions->Model_Answer); // Model_Answer
			$this->SetSearchParm($CCEExamQuestions->ParentQuestionID); // ParentQuestionID
			$this->SetSearchParm($CCEExamQuestions->RequireNumber); // RequireNumber
			$this->SetSearchParm($CCEExamQuestions->MinNum); // MinNum
			$this->SetSearchParm($CCEExamQuestions->MaxNum); // MaxNum
			$this->SetSearchParm($CCEExamQuestions->RecallPrevAnswer); // RecallPrevAnswer
			$this->SetSearchParm($CCEExamQuestions->QuestionTitle); // QuestionTitle
			$this->SetSearchParm($CCEExamQuestions->NumMarks); // NumMarks
		}
		return $sWhere;
	}

	// Build search SQL
	function BuildSearchSql(&$Where, &$Fld, $MultiValue) {
		$FldParm = substr($Fld->FldVar, 2);		
		$FldVal = $Fld->AdvancedSearch->SearchValue; // @$_GET["x_$FldParm"]
		$FldOpr = $Fld->AdvancedSearch->SearchOperator; // @$_GET["z_$FldParm"]
		$FldCond = $Fld->AdvancedSearch->SearchCondition; // @$_GET["v_$FldParm"]
		$FldVal2 = $Fld->AdvancedSearch->SearchValue2; // @$_GET["y_$FldParm"]
		$FldOpr2 = $Fld->AdvancedSearch->SearchOperator2; // @$_GET["w_$FldParm"]
		$sWrk = "";

		//$FldVal = ew_StripSlashes($FldVal);
		if (is_array($FldVal)) $FldVal = implode(",", $FldVal);

		//$FldVal2 = ew_StripSlashes($FldVal2);
		if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
		$FldOpr = strtoupper(trim($FldOpr));
		if ($FldOpr == "") $FldOpr = "=";
		$FldOpr2 = strtoupper(trim($FldOpr2));
		if ($FldOpr2 == "") $FldOpr2 = "=";
		if (EW_SEARCH_MULTI_VALUE_OPTION == 1 || $FldOpr <> "LIKE" ||
			($FldOpr2 <> "LIKE" && $FldVal2 <> ""))
			$MultiValue = FALSE;
		if ($MultiValue) {
			$sWrk1 = ($FldVal <> "") ? ew_GetMultiSearchSql($Fld, $FldVal) : ""; // Field value 1
			$sWrk2 = ($FldVal2 <> "") ? ew_GetMultiSearchSql($Fld, $FldVal2) : ""; // Field value 2
			$sWrk = $sWrk1; // Build final SQL
			if ($sWrk2 <> "")
				$sWrk = ($sWrk <> "") ? "($sWrk) $FldCond ($sWrk2)" : $sWrk2;
		} else {
			$FldVal = $this->ConvertSearchValue($Fld, $FldVal);
			$FldVal2 = $this->ConvertSearchValue($Fld, $FldVal2);
			$sWrk = ew_GetSearchSql($Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2);
		}
		if ($sWrk <> "") {
			if ($Where <> "") $Where .= " AND ";
			$Where .= "(" . $sWrk . ")";
		}
	}

	// Set search parameters
	function SetSearchParm(&$Fld) {
		global $CCEExamQuestions;
		$FldParm = substr($Fld->FldVar, 2);
		$FldVal = $Fld->AdvancedSearch->SearchValue; // @$_GET["x_$FldParm"]
		$FldVal = ew_StripSlashes($FldVal);
		if (is_array($FldVal)) $FldVal = implode(",", $FldVal);
		$FldVal2 = $Fld->AdvancedSearch->SearchValue2; // @$_GET["y_$FldParm"]
		$FldVal2 = ew_StripSlashes($FldVal2);
		if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
		$CCEExamQuestions->setAdvancedSearch("x_$FldParm", $FldVal);
		$CCEExamQuestions->setAdvancedSearch("z_$FldParm", $Fld->AdvancedSearch->SearchOperator); // @$_GET["z_$FldParm"]
		$CCEExamQuestions->setAdvancedSearch("v_$FldParm", $Fld->AdvancedSearch->SearchCondition); // @$_GET["v_$FldParm"]
		$CCEExamQuestions->setAdvancedSearch("y_$FldParm", $FldVal2);
		$CCEExamQuestions->setAdvancedSearch("w_$FldParm", $Fld->AdvancedSearch->SearchOperator2); // @$_GET["w_$FldParm"]
	}

	// Get search parameters
	function GetSearchParm(&$Fld) {
		global $CCEExamQuestions;
		$FldParm = substr($Fld->FldVar, 2);
		$Fld->AdvancedSearch->SearchValue = $CCEExamQuestions->GetAdvancedSearch("x_$FldParm");
		$Fld->AdvancedSearch->SearchOperator = $CCEExamQuestions->GetAdvancedSearch("z_$FldParm");
		$Fld->AdvancedSearch->SearchCondition = $CCEExamQuestions->GetAdvancedSearch("v_$FldParm");
		$Fld->AdvancedSearch->SearchValue2 = $CCEExamQuestions->GetAdvancedSearch("y_$FldParm");
		$Fld->AdvancedSearch->SearchOperator2 = $CCEExamQuestions->GetAdvancedSearch("w_$FldParm");
	}

	// Convert search value
	function ConvertSearchValue(&$Fld, $FldVal) {
		$Value = $FldVal;
		if ($Fld->FldDataType == EW_DATATYPE_BOOLEAN) {
			if ($FldVal <> "") $Value = ($FldVal == "1") ? $Fld->TrueValue : $Fld->FalseValue;
		} elseif ($Fld->FldDataType == EW_DATATYPE_DATE) {
			if ($FldVal <> "") $Value = ew_UnFormatDateTime($FldVal, $Fld->FldDateTimeFormat);
		}
		return $Value;
	}

	// Return basic search SQL
	function BasicSearchSQL($Keyword) {
		global $CCEExamQuestions;
		$sKeyword = ew_AdjustSql($Keyword);
		$sWhere = "";
		if (is_numeric($Keyword)) $this->BuildBasicSearchSQL($sWhere, $CCEExamQuestions->Questionnaire_ID, $Keyword);
		if (is_numeric($Keyword)) $this->BuildBasicSearchSQL($sWhere, $CCEExamQuestions->Section_ID, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $CCEExamQuestions->Answer_Type, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $CCEExamQuestions->Model_Answer, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $CCEExamQuestions->QuestionTitle, $Keyword);
		return $sWhere;
	}

	// Build basic search SQL
	function BuildBasicSearchSql(&$Where, &$Fld, $Keyword) {
		$sFldExpression = ($Fld->FldVirtualExpression <> "") ? $Fld->FldVirtualExpression : $Fld->FldExpression;
		$lFldDataType = ($Fld->FldIsVirtual) ? EW_DATATYPE_STRING : $Fld->FldDataType;
		if ($lFldDataType == EW_DATATYPE_NUMBER) {
			$sWrk = $sFldExpression . " = " . ew_QuotedValue($Keyword, $lFldDataType);
		} else {
			$sWrk = $sFldExpression . " LIKE " . ew_QuotedValue("%" . $Keyword . "%", $lFldDataType);
		}
		if ($Where <> "") $Where .= " OR ";
		$Where .= $sWrk;
	}

	// Return basic search WHERE clause based on search keyword and type
	function BasicSearchWhere() {
		global $Security, $CCEExamQuestions;
		$sSearchStr = "";
		if (!$Security->CanSearch()) return "";
		$sSearchKeyword = $CCEExamQuestions->BasicSearchKeyword;
		$sSearchType = $CCEExamQuestions->BasicSearchType;
		if ($sSearchKeyword <> "") {
			$sSearch = trim($sSearchKeyword);
			if ($sSearchType <> "") {
				while (strpos($sSearch, "  ") !== FALSE)
					$sSearch = str_replace("  ", " ", $sSearch);
				$arKeyword = explode(" ", trim($sSearch));
				foreach ($arKeyword as $sKeyword) {
					if ($sSearchStr <> "") $sSearchStr .= " " . $sSearchType . " ";
					$sSearchStr .= "(" . $this->BasicSearchSQL($sKeyword) . ")";
				}
			} else {
				$sSearchStr = $this->BasicSearchSQL($sSearch);
			}
		}
		if ($sSearchKeyword <> "") {
			$CCEExamQuestions->setSessionBasicSearchKeyword($sSearchKeyword);
			$CCEExamQuestions->setSessionBasicSearchType($sSearchType);
		}
		return $sSearchStr;
	}

	// Clear all search parameters
	function ResetSearchParms() {
		global $CCEExamQuestions;

		// Clear search WHERE clause
		$this->sSrchWhere = "";
		$CCEExamQuestions->setSearchWhere($this->sSrchWhere);

		// Clear basic search parameters
		$this->ResetBasicSearchParms();

		// Clear advanced search parameters
		$this->ResetAdvancedSearchParms();
	}

	// Clear all basic search parameters
	function ResetBasicSearchParms() {
		global $CCEExamQuestions;
		$CCEExamQuestions->setSessionBasicSearchKeyword("");
		$CCEExamQuestions->setSessionBasicSearchType("");
	}

	// Clear all advanced search parameters
	function ResetAdvancedSearchParms() {
		global $CCEExamQuestions;
		$CCEExamQuestions->setAdvancedSearch("x_Question_ID", "");
		$CCEExamQuestions->setAdvancedSearch("x_Questionnaire_ID", "");
		$CCEExamQuestions->setAdvancedSearch("x_Section_ID", "");
		$CCEExamQuestions->setAdvancedSearch("x_Question", "");
		$CCEExamQuestions->setAdvancedSearch("x_Display_Order", "");
		$CCEExamQuestions->setAdvancedSearch("x_IsMulti", "");
		$CCEExamQuestions->setAdvancedSearch("x_IsOptional", "");
		$CCEExamQuestions->setAdvancedSearch("x_Answer_Type", "");
		$CCEExamQuestions->setAdvancedSearch("x_Answer_Template", "");
		$CCEExamQuestions->setAdvancedSearch("x_Model_Answer", "");
		$CCEExamQuestions->setAdvancedSearch("x_ParentQuestionID", "");
		$CCEExamQuestions->setAdvancedSearch("x_RequireNumber", "");
		$CCEExamQuestions->setAdvancedSearch("x_MinNum", "");
		$CCEExamQuestions->setAdvancedSearch("x_MaxNum", "");
		$CCEExamQuestions->setAdvancedSearch("x_RecallPrevAnswer", "");
		$CCEExamQuestions->setAdvancedSearch("x_QuestionTitle", "");
		$CCEExamQuestions->setAdvancedSearch("x_NumMarks", "");
	}

	// Restore all search parameters
	function RestoreSearchParms() {
		global $CCEExamQuestions;
		$bRestore = TRUE;
		if (@$_GET[EW_TABLE_BASIC_SEARCH] <> "") $bRestore = FALSE;
		if (@$_GET["x_Question_ID"] <> "") $bRestore = FALSE;
		if (@$_GET["x_Questionnaire_ID"] <> "") $bRestore = FALSE;
		if (@$_GET["x_Section_ID"] <> "") $bRestore = FALSE;
		if (@$_GET["x_Question"] <> "") $bRestore = FALSE;
		if (@$_GET["x_Display_Order"] <> "") $bRestore = FALSE;
		if (@$_GET["x_IsMulti"] <> "") $bRestore = FALSE;
		if (@$_GET["x_IsOptional"] <> "") $bRestore = FALSE;
		if (@$_GET["x_Answer_Type"] <> "") $bRestore = FALSE;
		if (@$_GET["x_Answer_Template"] <> "") $bRestore = FALSE;
		if (@$_GET["x_Model_Answer"] <> "") $bRestore = FALSE;
		if (@$_GET["x_ParentQuestionID"] <> "") $bRestore = FALSE;
		if (@$_GET["x_RequireNumber"] <> "") $bRestore = FALSE;
		if (@$_GET["x_MinNum"] <> "") $bRestore = FALSE;
		if (@$_GET["x_MaxNum"] <> "") $bRestore = FALSE;
		if (@$_GET["x_RecallPrevAnswer"] <> "") $bRestore = FALSE;
		if (@$_GET["x_QuestionTitle"] <> "") $bRestore = FALSE;
		if (@$_GET["x_NumMarks"] <> "") $bRestore = FALSE;
		$this->RestoreSearch = $bRestore;
		if ($bRestore) {

			// Restore basic search values
			$CCEExamQuestions->BasicSearchKeyword = $CCEExamQuestions->getSessionBasicSearchKeyword();
			$CCEExamQuestions->BasicSearchType = $CCEExamQuestions->getSessionBasicSearchType();

			// Restore advanced search values
			$this->GetSearchParm($CCEExamQuestions->Question_ID);
			$this->GetSearchParm($CCEExamQuestions->Questionnaire_ID);
			$this->GetSearchParm($CCEExamQuestions->Section_ID);
			$this->GetSearchParm($CCEExamQuestions->Question);
			$this->GetSearchParm($CCEExamQuestions->Display_Order);
			$this->GetSearchParm($CCEExamQuestions->IsMulti);
			$this->GetSearchParm($CCEExamQuestions->IsOptional);
			$this->GetSearchParm($CCEExamQuestions->Answer_Type);
			$this->GetSearchParm($CCEExamQuestions->Answer_Template);
			$this->GetSearchParm($CCEExamQuestions->Model_Answer);
			$this->GetSearchParm($CCEExamQuestions->ParentQuestionID);
			$this->GetSearchParm($CCEExamQuestions->RequireNumber);
			$this->GetSearchParm($CCEExamQuestions->MinNum);
			$this->GetSearchParm($CCEExamQuestions->MaxNum);
			$this->GetSearchParm($CCEExamQuestions->RecallPrevAnswer);
			$this->GetSearchParm($CCEExamQuestions->QuestionTitle);
			$this->GetSearchParm($CCEExamQuestions->NumMarks);
		}
	}

	// Set up sort parameters
	function SetUpSortOrder() {
		global $CCEExamQuestions;

		// Check for Ctrl pressed
		$bCtrl = (@$_GET["ctrl"] <> "");

		// Check for "order" parameter
		if (@$_GET["order"] <> "") {
			$CCEExamQuestions->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
			$CCEExamQuestions->CurrentOrderType = @$_GET["ordertype"];
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->Question_ID, $bCtrl); // Question_ID
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->Questionnaire_ID, $bCtrl); // Questionnaire_ID
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->Section_ID, $bCtrl); // Section_ID
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->Question, $bCtrl); // Question
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->Display_Order, $bCtrl); // Display_Order
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->IsMulti, $bCtrl); // IsMulti
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->IsOptional, $bCtrl); // IsOptional
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->Answer_Type, $bCtrl); // Answer_Type
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->Answer_Template, $bCtrl); // Answer_Template
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->Model_Answer, $bCtrl); // Model_Answer
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->ParentQuestionID, $bCtrl); // ParentQuestionID
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->RequireNumber, $bCtrl); // RequireNumber
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->MinNum, $bCtrl); // MinNum
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->MaxNum, $bCtrl); // MaxNum
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->RecallPrevAnswer, $bCtrl); // RecallPrevAnswer
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->QuestionTitle, $bCtrl); // QuestionTitle
			$CCEExamQuestions->UpdateSort($CCEExamQuestions->NumMarks, $bCtrl); // NumMarks
			$CCEExamQuestions->setStartRecordNumber(1); // Reset start position
		}
	}

	// Load sort order parameters
	function LoadSortOrder() {
		global $CCEExamQuestions;
		$sOrderBy = $CCEExamQuestions->getSessionOrderBy(); // Get ORDER BY from Session
		if ($sOrderBy == "") {
			if ($CCEExamQuestions->SqlOrderBy() <> "") {
				$sOrderBy = $CCEExamQuestions->SqlOrderBy();
				$CCEExamQuestions->setSessionOrderBy($sOrderBy);
				$CCEExamQuestions->Display_Order->setSort("ASC");
			}
		}
	}

	// Reset command
	// cmd=reset (Reset search parameters)
	// cmd=resetall (Reset search and master/detail parameters)
	// cmd=resetsort (Reset sort parameters)
	function ResetCmd() {
		global $CCEExamQuestions;

		// Get reset command
		if (@$_GET["cmd"] <> "") {
			$sCmd = $_GET["cmd"];

			// Reset search criteria
			if (strtolower($sCmd) == "reset" || strtolower($sCmd) == "resetall")
				$this->ResetSearchParms();

			// Reset sorting order
			if (strtolower($sCmd) == "resetsort") {
				$sOrderBy = "";
				$CCEExamQuestions->setSessionOrderBy($sOrderBy);
				$CCEExamQuestions->Question_ID->setSort("");
				$CCEExamQuestions->Questionnaire_ID->setSort("");
				$CCEExamQuestions->Section_ID->setSort("");
				$CCEExamQuestions->Question->setSort("");
				$CCEExamQuestions->Display_Order->setSort("");
				$CCEExamQuestions->IsMulti->setSort("");
				$CCEExamQuestions->IsOptional->setSort("");
				$CCEExamQuestions->Answer_Type->setSort("");
				$CCEExamQuestions->Answer_Template->setSort("");
				$CCEExamQuestions->Model_Answer->setSort("");
				$CCEExamQuestions->ParentQuestionID->setSort("");
				$CCEExamQuestions->RequireNumber->setSort("");
				$CCEExamQuestions->MinNum->setSort("");
				$CCEExamQuestions->MaxNum->setSort("");
				$CCEExamQuestions->RecallPrevAnswer->setSort("");
				$CCEExamQuestions->QuestionTitle->setSort("");
				$CCEExamQuestions->NumMarks->setSort("");
			}

			// Reset start position
			$this->lStartRec = 1;
			$CCEExamQuestions->setStartRecordNumber($this->lStartRec);
		}
	}

	// Set up list options
	function SetupListOptions() {
		global $Security, $CCEExamQuestions;

		// "view"
		$this->ListOptions->Add("view");
		$item =& $this->ListOptions->Items["view"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->CanView();
		$item->OnLeft = FALSE;

		// "edit"
		$this->ListOptions->Add("edit");
		$item =& $this->ListOptions->Items["edit"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->CanEdit();
		$item->OnLeft = FALSE;

		// "copy"
		$this->ListOptions->Add("copy");
		$item =& $this->ListOptions->Items["copy"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->CanAdd();
		$item->OnLeft = FALSE;

		// "delete"
		$this->ListOptions->Add("delete");
		$item =& $this->ListOptions->Items["delete"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->CanDelete();
		$item->OnLeft = FALSE;

		// "detail_CCEExamAnswers"
		$this->ListOptions->Add("detail_CCEExamAnswers");
		$item =& $this->ListOptions->Items["detail_CCEExamAnswers"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->AllowList('CCEExamAnswers');
		$item->OnLeft = FALSE;

		// Call ListOptions_Load event
		$this->ListOptions_Load();
		if ($CCEExamQuestions->Export <> "" ||
			$CCEExamQuestions->CurrentAction == "gridadd" ||
			$CCEExamQuestions->CurrentAction == "gridedit")
			$this->ListOptions->HideAllOptions();
	}

	// Render list options
	function RenderListOptions() {
		global $Security, $Language, $CCEExamQuestions;
		$this->ListOptions->LoadDefault();

		// "view"
		$oListOpt =& $this->ListOptions->Items["view"];
		if ($Security->CanView() && $oListOpt->Visible)
			$oListOpt->Body = "<a href=\"" . $this->ViewUrl . "\">" . "<img src=\"images/view.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ViewLink")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ViewLink")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>";

		// "edit"
		$oListOpt =& $this->ListOptions->Items["edit"];
		if ($Security->CanEdit() && $oListOpt->Visible) {
			$oListOpt->Body = "<a href=\"" . $this->EditUrl . "\">" . "<img src=\"images/edit.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("EditLink")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("EditLink")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>";
		}

		// "copy"
		$oListOpt =& $this->ListOptions->Items["copy"];
		if ($Security->CanAdd() && $oListOpt->Visible) {
			$oListOpt->Body = "<a href=\"" . $this->CopyUrl . "\">" . "<img src=\"images/copy.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("CopyLink")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("CopyLink")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>";
		}

		// "delete"
		$oListOpt =& $this->ListOptions->Items["delete"];
		if ($Security->CanDelete() && $oListOpt->Visible)
			$oListOpt->Body = "<a" . "" . " href=\"" . $this->DeleteUrl . "\">" . "<img src=\"images/delete.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("DeleteLink")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("DeleteLink")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>";

		// "detail_CCEExamAnswers"
		$oListOpt =& $this->ListOptions->Items["detail_CCEExamAnswers"];
		if ($Security->AllowList('CCEExamAnswers')) {
			$oListOpt->Body = "<img src=\"images/detail.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("DetailLink")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("DetailLink")) . "\" width=\"16\" height=\"16\" border=\"0\">" . $Language->TablePhrase("CCEExamAnswers", "TblCaption");
			$oListOpt->Body = "<a href=\"CCEExamAnswerslist.php?" . EW_TABLE_SHOW_MASTER . "=CCEExamQuestions&Question_ID=" . urlencode(strval($CCEExamQuestions->Question_ID->CurrentValue)) . "\">" . $oListOpt->Body . "</a>";
		}
		$this->RenderListOptionsExt();

		// Call ListOptions_Rendered event
		$this->ListOptions_Rendered();
	}

	function RenderListOptionsExt() {
		global $Security, $Language, $CCEExamQuestions;
	}

	// Set up starting record parameters
	function SetUpStartRec() {
		global $CCEExamQuestions;
		if ($this->lDisplayRecs == 0)
			return;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter
				$this->lStartRec = $_GET[EW_TABLE_START_REC];
				$CCEExamQuestions->setStartRecordNumber($this->lStartRec);
			} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
				$this->nPageNo = $_GET[EW_TABLE_PAGE_NO];
				if (is_numeric($this->nPageNo)) {
					$this->lStartRec = ($this->nPageNo-1)*$this->lDisplayRecs+1;
					if ($this->lStartRec <= 0) {
						$this->lStartRec = 1;
					} elseif ($this->lStartRec >= intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1) {
						$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1;
					}
					$CCEExamQuestions->setStartRecordNumber($this->lStartRec);
				}
			}
		}
		$this->lStartRec = $CCEExamQuestions->getStartRecordNumber();

		// Check if correct start record counter
		if (!is_numeric($this->lStartRec) || $this->lStartRec == "") { // Avoid invalid start record counter
			$this->lStartRec = 1; // Reset start record counter
			$CCEExamQuestions->setStartRecordNumber($this->lStartRec);
		} elseif (intval($this->lStartRec) > intval($this->lTotalRecs)) { // Avoid starting record > total records
			$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to last page first record
			$CCEExamQuestions->setStartRecordNumber($this->lStartRec);
		} elseif (($this->lStartRec-1) % $this->lDisplayRecs <> 0) {
			$this->lStartRec = intval(($this->lStartRec-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to page boundary
			$CCEExamQuestions->setStartRecordNumber($this->lStartRec);
		}
	}

	// Load basic search values
	function LoadBasicSearchValues() {
		global $CCEExamQuestions;
		$CCEExamQuestions->BasicSearchKeyword = @$_GET[EW_TABLE_BASIC_SEARCH];
		$CCEExamQuestions->BasicSearchType = @$_GET[EW_TABLE_BASIC_SEARCH_TYPE];
	}

	//  Load search values for validation
	function LoadSearchValues() {
		global $objForm, $CCEExamQuestions;

		// Load search values
		// Question_ID

		$CCEExamQuestions->Question_ID->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_Question_ID"]);
		$CCEExamQuestions->Question_ID->AdvancedSearch->SearchOperator = @$_GET["z_Question_ID"];

		// Questionnaire_ID
		$CCEExamQuestions->Questionnaire_ID->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_Questionnaire_ID"]);
		$CCEExamQuestions->Questionnaire_ID->AdvancedSearch->SearchOperator = @$_GET["z_Questionnaire_ID"];

		// Section_ID
		$CCEExamQuestions->Section_ID->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_Section_ID"]);
		$CCEExamQuestions->Section_ID->AdvancedSearch->SearchOperator = @$_GET["z_Section_ID"];

		// Question
		$CCEExamQuestions->Question->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_Question"]);
		$CCEExamQuestions->Question->AdvancedSearch->SearchOperator = @$_GET["z_Question"];

		// Display_Order
		$CCEExamQuestions->Display_Order->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_Display_Order"]);
		$CCEExamQuestions->Display_Order->AdvancedSearch->SearchOperator = @$_GET["z_Display_Order"];

		// IsMulti
		$CCEExamQuestions->IsMulti->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_IsMulti"]);
		$CCEExamQuestions->IsMulti->AdvancedSearch->SearchOperator = @$_GET["z_IsMulti"];

		// IsOptional
		$CCEExamQuestions->IsOptional->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_IsOptional"]);
		$CCEExamQuestions->IsOptional->AdvancedSearch->SearchOperator = @$_GET["z_IsOptional"];

		// Answer_Type
		$CCEExamQuestions->Answer_Type->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_Answer_Type"]);
		$CCEExamQuestions->Answer_Type->AdvancedSearch->SearchOperator = @$_GET["z_Answer_Type"];

		// Answer_Template
		$CCEExamQuestions->Answer_Template->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_Answer_Template"]);
		$CCEExamQuestions->Answer_Template->AdvancedSearch->SearchOperator = @$_GET["z_Answer_Template"];

		// Model_Answer
		$CCEExamQuestions->Model_Answer->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_Model_Answer"]);
		$CCEExamQuestions->Model_Answer->AdvancedSearch->SearchOperator = @$_GET["z_Model_Answer"];

		// ParentQuestionID
		$CCEExamQuestions->ParentQuestionID->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_ParentQuestionID"]);
		$CCEExamQuestions->ParentQuestionID->AdvancedSearch->SearchOperator = @$_GET["z_ParentQuestionID"];

		// RequireNumber
		$CCEExamQuestions->RequireNumber->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_RequireNumber"]);
		$CCEExamQuestions->RequireNumber->AdvancedSearch->SearchOperator = @$_GET["z_RequireNumber"];

		// MinNum
		$CCEExamQuestions->MinNum->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_MinNum"]);
		$CCEExamQuestions->MinNum->AdvancedSearch->SearchOperator = @$_GET["z_MinNum"];

		// MaxNum
		$CCEExamQuestions->MaxNum->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_MaxNum"]);
		$CCEExamQuestions->MaxNum->AdvancedSearch->SearchOperator = @$_GET["z_MaxNum"];

		// RecallPrevAnswer
		$CCEExamQuestions->RecallPrevAnswer->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_RecallPrevAnswer"]);
		$CCEExamQuestions->RecallPrevAnswer->AdvancedSearch->SearchOperator = @$_GET["z_RecallPrevAnswer"];

		// QuestionTitle
		$CCEExamQuestions->QuestionTitle->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_QuestionTitle"]);
		$CCEExamQuestions->QuestionTitle->AdvancedSearch->SearchOperator = @$_GET["z_QuestionTitle"];

		// NumMarks
		$CCEExamQuestions->NumMarks->AdvancedSearch->SearchValue = ew_StripSlashes(@$_GET["x_NumMarks"]);
		$CCEExamQuestions->NumMarks->AdvancedSearch->SearchOperator = @$_GET["z_NumMarks"];
	}

	// Load recordset
	function LoadRecordset($offset = -1, $rowcnt = -1) {
		global $conn, $CCEExamQuestions;

		// Call Recordset Selecting event
		$CCEExamQuestions->Recordset_Selecting($CCEExamQuestions->CurrentFilter);

		// Load List page SQL
		$sSql = $CCEExamQuestions->SelectSQL();
		if ($offset > -1 && $rowcnt > -1)
			$sSql .= " LIMIT $offset, $rowcnt";

		// Load recordset
		$rs = ew_LoadRecordset($sSql);

		// Call Recordset Selected event
		$CCEExamQuestions->Recordset_Selected($rs);
		return $rs;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $CCEExamQuestions;
		$sFilter = $CCEExamQuestions->KeyFilter();

		// Call Row Selecting event
		$CCEExamQuestions->Row_Selecting($sFilter);

		// Load SQL based on filter
		$CCEExamQuestions->CurrentFilter = $sFilter;
		$sSql = $CCEExamQuestions->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$CCEExamQuestions->Row_Selected($rs);
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $CCEExamQuestions;
		$CCEExamQuestions->Question_ID->setDbValue($rs->fields('Question_ID'));
		$CCEExamQuestions->Questionnaire_ID->setDbValue($rs->fields('Questionnaire_ID'));
		$CCEExamQuestions->Section_ID->setDbValue($rs->fields('Section_ID'));
		$CCEExamQuestions->Question->setDbValue($rs->fields('Question'));
		$CCEExamQuestions->Display_Order->setDbValue($rs->fields('Display_Order'));
		$CCEExamQuestions->IsMulti->setDbValue($rs->fields('IsMulti'));
		$CCEExamQuestions->IsOptional->setDbValue($rs->fields('IsOptional'));
		$CCEExamQuestions->Answer_Type->setDbValue($rs->fields('Answer_Type'));
		$CCEExamQuestions->Answer_Template->setDbValue($rs->fields('Answer_Template'));
		$CCEExamQuestions->Model_Answer->setDbValue($rs->fields('Model_Answer'));
		$CCEExamQuestions->ParentQuestionID->setDbValue($rs->fields('ParentQuestionID'));
		$CCEExamQuestions->RequireNumber->setDbValue($rs->fields('RequireNumber'));
		$CCEExamQuestions->MinNum->setDbValue($rs->fields('MinNum'));
		$CCEExamQuestions->MaxNum->setDbValue($rs->fields('MaxNum'));
		$CCEExamQuestions->RecallPrevAnswer->setDbValue($rs->fields('RecallPrevAnswer'));
		$CCEExamQuestions->QuestionTitle->setDbValue($rs->fields('QuestionTitle'));
		$CCEExamQuestions->NumMarks->setDbValue($rs->fields('NumMarks'));
		$CCEExamQuestions->DropDown->setDbValue($rs->fields('DropDown'));
		$CCEExamQuestions->InUse->setDbValue($rs->fields('InUse'));
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language, $CCEExamQuestions;

		// Initialize URLs
		$this->ViewUrl = $CCEExamQuestions->ViewUrl();
		$this->EditUrl = $CCEExamQuestions->EditUrl();
		$this->InlineEditUrl = $CCEExamQuestions->InlineEditUrl();
		$this->CopyUrl = $CCEExamQuestions->CopyUrl();
		$this->InlineCopyUrl = $CCEExamQuestions->InlineCopyUrl();
		$this->DeleteUrl = $CCEExamQuestions->DeleteUrl();

		// Call Row_Rendering event
		$CCEExamQuestions->Row_Rendering();

		// Common render codes for all row types
		// Question_ID

		$CCEExamQuestions->Question_ID->CellCssStyle = ""; $CCEExamQuestions->Question_ID->CellCssClass = "";
		$CCEExamQuestions->Question_ID->CellAttrs = array(); $CCEExamQuestions->Question_ID->ViewAttrs = array(); $CCEExamQuestions->Question_ID->EditAttrs = array();

		// Questionnaire_ID
		$CCEExamQuestions->Questionnaire_ID->CellCssStyle = ""; $CCEExamQuestions->Questionnaire_ID->CellCssClass = "";
		$CCEExamQuestions->Questionnaire_ID->CellAttrs = array(); $CCEExamQuestions->Questionnaire_ID->ViewAttrs = array(); $CCEExamQuestions->Questionnaire_ID->EditAttrs = array();

		// Section_ID
		$CCEExamQuestions->Section_ID->CellCssStyle = ""; $CCEExamQuestions->Section_ID->CellCssClass = "";
		$CCEExamQuestions->Section_ID->CellAttrs = array(); $CCEExamQuestions->Section_ID->ViewAttrs = array(); $CCEExamQuestions->Section_ID->EditAttrs = array();

		// Question
		$CCEExamQuestions->Question->CellCssStyle = ""; $CCEExamQuestions->Question->CellCssClass = "";
		$CCEExamQuestions->Question->CellAttrs = array(); $CCEExamQuestions->Question->ViewAttrs = array(); $CCEExamQuestions->Question->EditAttrs = array();

		// Display_Order
		$CCEExamQuestions->Display_Order->CellCssStyle = ""; $CCEExamQuestions->Display_Order->CellCssClass = "";
		$CCEExamQuestions->Display_Order->CellAttrs = array(); $CCEExamQuestions->Display_Order->ViewAttrs = array(); $CCEExamQuestions->Display_Order->EditAttrs = array();

		// IsMulti
		$CCEExamQuestions->IsMulti->CellCssStyle = ""; $CCEExamQuestions->IsMulti->CellCssClass = "";
		$CCEExamQuestions->IsMulti->CellAttrs = array(); $CCEExamQuestions->IsMulti->ViewAttrs = array(); $CCEExamQuestions->IsMulti->EditAttrs = array();

		// IsOptional
		$CCEExamQuestions->IsOptional->CellCssStyle = ""; $CCEExamQuestions->IsOptional->CellCssClass = "";
		$CCEExamQuestions->IsOptional->CellAttrs = array(); $CCEExamQuestions->IsOptional->ViewAttrs = array(); $CCEExamQuestions->IsOptional->EditAttrs = array();

		// Answer_Type
		$CCEExamQuestions->Answer_Type->CellCssStyle = ""; $CCEExamQuestions->Answer_Type->CellCssClass = "";
		$CCEExamQuestions->Answer_Type->CellAttrs = array(); $CCEExamQuestions->Answer_Type->ViewAttrs = array(); $CCEExamQuestions->Answer_Type->EditAttrs = array();

		// Answer_Template
		$CCEExamQuestions->Answer_Template->CellCssStyle = ""; $CCEExamQuestions->Answer_Template->CellCssClass = "";
		$CCEExamQuestions->Answer_Template->CellAttrs = array(); $CCEExamQuestions->Answer_Template->ViewAttrs = array(); $CCEExamQuestions->Answer_Template->EditAttrs = array();

		// Model_Answer
		$CCEExamQuestions->Model_Answer->CellCssStyle = ""; $CCEExamQuestions->Model_Answer->CellCssClass = "";
		$CCEExamQuestions->Model_Answer->CellAttrs = array(); $CCEExamQuestions->Model_Answer->ViewAttrs = array(); $CCEExamQuestions->Model_Answer->EditAttrs = array();

		// ParentQuestionID
		$CCEExamQuestions->ParentQuestionID->CellCssStyle = ""; $CCEExamQuestions->ParentQuestionID->CellCssClass = "";
		$CCEExamQuestions->ParentQuestionID->CellAttrs = array(); $CCEExamQuestions->ParentQuestionID->ViewAttrs = array(); $CCEExamQuestions->ParentQuestionID->EditAttrs = array();

		// RequireNumber
		$CCEExamQuestions->RequireNumber->CellCssStyle = ""; $CCEExamQuestions->RequireNumber->CellCssClass = "";
		$CCEExamQuestions->RequireNumber->CellAttrs = array(); $CCEExamQuestions->RequireNumber->ViewAttrs = array(); $CCEExamQuestions->RequireNumber->EditAttrs = array();

		// MinNum
		$CCEExamQuestions->MinNum->CellCssStyle = ""; $CCEExamQuestions->MinNum->CellCssClass = "";
		$CCEExamQuestions->MinNum->CellAttrs = array(); $CCEExamQuestions->MinNum->ViewAttrs = array(); $CCEExamQuestions->MinNum->EditAttrs = array();

		// MaxNum
		$CCEExamQuestions->MaxNum->CellCssStyle = ""; $CCEExamQuestions->MaxNum->CellCssClass = "";
		$CCEExamQuestions->MaxNum->CellAttrs = array(); $CCEExamQuestions->MaxNum->ViewAttrs = array(); $CCEExamQuestions->MaxNum->EditAttrs = array();

		// RecallPrevAnswer
		$CCEExamQuestions->RecallPrevAnswer->CellCssStyle = ""; $CCEExamQuestions->RecallPrevAnswer->CellCssClass = "";
		$CCEExamQuestions->RecallPrevAnswer->CellAttrs = array(); $CCEExamQuestions->RecallPrevAnswer->ViewAttrs = array(); $CCEExamQuestions->RecallPrevAnswer->EditAttrs = array();

		// QuestionTitle
		$CCEExamQuestions->QuestionTitle->CellCssStyle = ""; $CCEExamQuestions->QuestionTitle->CellCssClass = "";
		$CCEExamQuestions->QuestionTitle->CellAttrs = array(); $CCEExamQuestions->QuestionTitle->ViewAttrs = array(); $CCEExamQuestions->QuestionTitle->EditAttrs = array();

		// NumMarks
		$CCEExamQuestions->NumMarks->CellCssStyle = ""; $CCEExamQuestions->NumMarks->CellCssClass = "";
		$CCEExamQuestions->NumMarks->CellAttrs = array(); $CCEExamQuestions->NumMarks->ViewAttrs = array(); $CCEExamQuestions->NumMarks->EditAttrs = array();
		if ($CCEExamQuestions->RowType == EW_ROWTYPE_VIEW) { // View row

			// Question_ID
			$CCEExamQuestions->Question_ID->ViewValue = $CCEExamQuestions->Question_ID->CurrentValue;
			$CCEExamQuestions->Question_ID->CssStyle = "";
			$CCEExamQuestions->Question_ID->CssClass = "";
			$CCEExamQuestions->Question_ID->ViewCustomAttributes = "";

			// Questionnaire_ID
			if (strval($CCEExamQuestions->Questionnaire_ID->CurrentValue) <> "") {
				$sFilterWrk = "`Questionnaire_ID` = " . ew_AdjustSql($CCEExamQuestions->Questionnaire_ID->CurrentValue) . "";
			$sSqlWrk = "SELECT `Questionnaire_Name` FROM `CCEExams`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEExamQuestions->Questionnaire_ID->ViewValue = $rswrk->fields('Questionnaire_Name');
					$rswrk->Close();
				} else {
					$CCEExamQuestions->Questionnaire_ID->ViewValue = $CCEExamQuestions->Questionnaire_ID->CurrentValue;
				}
			} else {
				$CCEExamQuestions->Questionnaire_ID->ViewValue = NULL;
			}
			$CCEExamQuestions->Questionnaire_ID->CssStyle = "";
			$CCEExamQuestions->Questionnaire_ID->CssClass = "";
			$CCEExamQuestions->Questionnaire_ID->ViewCustomAttributes = "";

			// Section_ID
			if (strval($CCEExamQuestions->Section_ID->CurrentValue) <> "") {
				$sFilterWrk = "`Section_ID` = " . ew_AdjustSql($CCEExamQuestions->Section_ID->CurrentValue) . "";
			$sSqlWrk = "SELECT `Section_Name` FROM `CCEExamSections`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Display_Order` Asc";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEExamQuestions->Section_ID->ViewValue = $rswrk->fields('Section_Name');
					$rswrk->Close();
				} else {
					$CCEExamQuestions->Section_ID->ViewValue = $CCEExamQuestions->Section_ID->CurrentValue;
				}
			} else {
				$CCEExamQuestions->Section_ID->ViewValue = NULL;
			}
			$CCEExamQuestions->Section_ID->CssStyle = "";
			$CCEExamQuestions->Section_ID->CssClass = "";
			$CCEExamQuestions->Section_ID->ViewCustomAttributes = "";

			// Question
			$CCEExamQuestions->Question->ViewValue = $CCEExamQuestions->Question->CurrentValue;
			$CCEExamQuestions->Question->CssStyle = "";
			$CCEExamQuestions->Question->CssClass = "";
			$CCEExamQuestions->Question->ViewCustomAttributes = "";

			// Display_Order
			$CCEExamQuestions->Display_Order->ViewValue = $CCEExamQuestions->Display_Order->CurrentValue;
			$CCEExamQuestions->Display_Order->CssStyle = "";
			$CCEExamQuestions->Display_Order->CssClass = "";
			$CCEExamQuestions->Display_Order->ViewCustomAttributes = "";

			// IsMulti
			if (strval($CCEExamQuestions->IsMulti->CurrentValue) <> "") {
				switch ($CCEExamQuestions->IsMulti->CurrentValue) {
					case "1":
						$CCEExamQuestions->IsMulti->ViewValue = "Yes";
						break;
					case "0":
						$CCEExamQuestions->IsMulti->ViewValue = "No";
						break;
					default:
						$CCEExamQuestions->IsMulti->ViewValue = $CCEExamQuestions->IsMulti->CurrentValue;
				}
			} else {
				$CCEExamQuestions->IsMulti->ViewValue = NULL;
			}
			$CCEExamQuestions->IsMulti->CssStyle = "";
			$CCEExamQuestions->IsMulti->CssClass = "";
			$CCEExamQuestions->IsMulti->ViewCustomAttributes = "";

			// IsOptional
			if (strval($CCEExamQuestions->IsOptional->CurrentValue) <> "") {
				switch ($CCEExamQuestions->IsOptional->CurrentValue) {
					case "1":
						$CCEExamQuestions->IsOptional->ViewValue = "Yes";
						break;
					case "0":
						$CCEExamQuestions->IsOptional->ViewValue = "No";
						break;
					default:
						$CCEExamQuestions->IsOptional->ViewValue = $CCEExamQuestions->IsOptional->CurrentValue;
				}
			} else {
				$CCEExamQuestions->IsOptional->ViewValue = NULL;
			}
			$CCEExamQuestions->IsOptional->CssStyle = "";
			$CCEExamQuestions->IsOptional->CssClass = "";
			$CCEExamQuestions->IsOptional->ViewCustomAttributes = "";

			// Answer_Type
			if (strval($CCEExamQuestions->Answer_Type->CurrentValue) <> "") {
				switch ($CCEExamQuestions->Answer_Type->CurrentValue) {
					case "a":
						$CCEExamQuestions->Answer_Type->ViewValue = "Text Box";
						break;
					case "m":
						$CCEExamQuestions->Answer_Type->ViewValue = "Radio/ Check Box";
						break;
					case "s":
						$CCEExamQuestions->Answer_Type->ViewValue = "Select";
						break;
					case "f":
						$CCEExamQuestions->Answer_Type->ViewValue = "File";
						break;
					default:
						$CCEExamQuestions->Answer_Type->ViewValue = $CCEExamQuestions->Answer_Type->CurrentValue;
				}
			} else {
				$CCEExamQuestions->Answer_Type->ViewValue = NULL;
			}
			$CCEExamQuestions->Answer_Type->CssStyle = "";
			$CCEExamQuestions->Answer_Type->CssClass = "";
			$CCEExamQuestions->Answer_Type->ViewCustomAttributes = "";

			// Answer_Template
			$CCEExamQuestions->Answer_Template->ViewValue = $CCEExamQuestions->Answer_Template->CurrentValue;
			$CCEExamQuestions->Answer_Template->CssStyle = "";
			$CCEExamQuestions->Answer_Template->CssClass = "";
			$CCEExamQuestions->Answer_Template->ViewCustomAttributes = "";

			// Model_Answer
			$CCEExamQuestions->Model_Answer->ViewValue = $CCEExamQuestions->Model_Answer->CurrentValue;
			$CCEExamQuestions->Model_Answer->CssStyle = "";
			$CCEExamQuestions->Model_Answer->CssClass = "";
			$CCEExamQuestions->Model_Answer->ViewCustomAttributes = "";

			// ParentQuestionID
			if (strval($CCEExamQuestions->ParentQuestionID->CurrentValue) <> "") {
				$sFilterWrk = "`Question_ID` = " . ew_AdjustSql($CCEExamQuestions->ParentQuestionID->CurrentValue) . "";
			$sSqlWrk = "SELECT `QuestionTitle`, `Question` FROM `CCEExamQuestions`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Display_Order`";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEExamQuestions->ParentQuestionID->ViewValue = $rswrk->fields('QuestionTitle');
					$CCEExamQuestions->ParentQuestionID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('Question');
					$rswrk->Close();
				} else {
					$CCEExamQuestions->ParentQuestionID->ViewValue = $CCEExamQuestions->ParentQuestionID->CurrentValue;
				}
			} else {
				$CCEExamQuestions->ParentQuestionID->ViewValue = NULL;
			}
			$CCEExamQuestions->ParentQuestionID->CssStyle = "";
			$CCEExamQuestions->ParentQuestionID->CssClass = "";
			$CCEExamQuestions->ParentQuestionID->ViewCustomAttributes = "";

			// RequireNumber
			$CCEExamQuestions->RequireNumber->ViewValue = $CCEExamQuestions->RequireNumber->CurrentValue;
			$CCEExamQuestions->RequireNumber->CssStyle = "";
			$CCEExamQuestions->RequireNumber->CssClass = "";
			$CCEExamQuestions->RequireNumber->ViewCustomAttributes = "";

			// MinNum
			$CCEExamQuestions->MinNum->ViewValue = $CCEExamQuestions->MinNum->CurrentValue;
			$CCEExamQuestions->MinNum->CssStyle = "";
			$CCEExamQuestions->MinNum->CssClass = "";
			$CCEExamQuestions->MinNum->ViewCustomAttributes = "";

			// MaxNum
			$CCEExamQuestions->MaxNum->ViewValue = $CCEExamQuestions->MaxNum->CurrentValue;
			$CCEExamQuestions->MaxNum->CssStyle = "";
			$CCEExamQuestions->MaxNum->CssClass = "";
			$CCEExamQuestions->MaxNum->ViewCustomAttributes = "";

			// RecallPrevAnswer
			if (strval($CCEExamQuestions->RecallPrevAnswer->CurrentValue) <> "") {
				switch ($CCEExamQuestions->RecallPrevAnswer->CurrentValue) {
					case "1":
						$CCEExamQuestions->RecallPrevAnswer->ViewValue = "Yes";
						break;
					case "0":
						$CCEExamQuestions->RecallPrevAnswer->ViewValue = "No";
						break;
					default:
						$CCEExamQuestions->RecallPrevAnswer->ViewValue = $CCEExamQuestions->RecallPrevAnswer->CurrentValue;
				}
			} else {
				$CCEExamQuestions->RecallPrevAnswer->ViewValue = NULL;
			}
			$CCEExamQuestions->RecallPrevAnswer->CssStyle = "";
			$CCEExamQuestions->RecallPrevAnswer->CssClass = "";
			$CCEExamQuestions->RecallPrevAnswer->ViewCustomAttributes = "";

			// QuestionTitle
			$CCEExamQuestions->QuestionTitle->ViewValue = $CCEExamQuestions->QuestionTitle->CurrentValue;
			$CCEExamQuestions->QuestionTitle->CssStyle = "";
			$CCEExamQuestions->QuestionTitle->CssClass = "";
			$CCEExamQuestions->QuestionTitle->ViewCustomAttributes = "";

			// NumMarks
			$CCEExamQuestions->NumMarks->ViewValue = $CCEExamQuestions->NumMarks->CurrentValue;
			$CCEExamQuestions->NumMarks->CssStyle = "";
			$CCEExamQuestions->NumMarks->CssClass = "";
			$CCEExamQuestions->NumMarks->ViewCustomAttributes = "";

			// InUse
			if (strval($CCEExamQuestions->InUse->CurrentValue) <> "") {
				switch ($CCEExamQuestions->InUse->CurrentValue) {
					case "1":
						$CCEExamQuestions->InUse->ViewValue = "Yes";
						break;
					case "0":
						$CCEExamQuestions->InUse->ViewValue = "No";
						break;
					default:
						$CCEExamQuestions->InUse->ViewValue = $CCEExamQuestions->InUse->CurrentValue;
				}
			} else {
				$CCEExamQuestions->InUse->ViewValue = "No";
			}
			$CCEExamQuestions->InUse->CssStyle = "";
			$CCEExamQuestions->InUse->CssClass = "";
			$CCEExamQuestions->InUse->ViewCustomAttributes = "";

			// Question_ID
			$CCEExamQuestions->Question_ID->HrefValue = "";
			$CCEExamQuestions->Question_ID->TooltipValue = "";

			// Questionnaire_ID
			$CCEExamQuestions->Questionnaire_ID->HrefValue = "";
			$CCEExamQuestions->Questionnaire_ID->TooltipValue = "";

			// Section_ID
			$CCEExamQuestions->Section_ID->HrefValue = "";
			$CCEExamQuestions->Section_ID->TooltipValue = "";

			// Question
			$CCEExamQuestions->Question->HrefValue = "";
			$CCEExamQuestions->Question->TooltipValue = "";

			// Display_Order
			$CCEExamQuestions->Display_Order->HrefValue = "";
			$CCEExamQuestions->Display_Order->TooltipValue = "";

			// IsMulti
			$CCEExamQuestions->IsMulti->HrefValue = "";
			$CCEExamQuestions->IsMulti->TooltipValue = "";

			// IsOptional
			$CCEExamQuestions->IsOptional->HrefValue = "";
			$CCEExamQuestions->IsOptional->TooltipValue = "";

			// Answer_Type
			$CCEExamQuestions->Answer_Type->HrefValue = "";
			$CCEExamQuestions->Answer_Type->TooltipValue = "";

			// Answer_Template
			$CCEExamQuestions->Answer_Template->HrefValue = "";
			$CCEExamQuestions->Answer_Template->TooltipValue = "";

			// Model_Answer
			$CCEExamQuestions->Model_Answer->HrefValue = "";
			$CCEExamQuestions->Model_Answer->TooltipValue = "";

			// ParentQuestionID
			$CCEExamQuestions->ParentQuestionID->HrefValue = "";
			$CCEExamQuestions->ParentQuestionID->TooltipValue = "";

			// RequireNumber
			$CCEExamQuestions->RequireNumber->HrefValue = "";
			$CCEExamQuestions->RequireNumber->TooltipValue = "";

			// MinNum
			$CCEExamQuestions->MinNum->HrefValue = "";
			$CCEExamQuestions->MinNum->TooltipValue = "";

			// MaxNum
			$CCEExamQuestions->MaxNum->HrefValue = "";
			$CCEExamQuestions->MaxNum->TooltipValue = "";

			// RecallPrevAnswer
			$CCEExamQuestions->RecallPrevAnswer->HrefValue = "";
			$CCEExamQuestions->RecallPrevAnswer->TooltipValue = "";

			// QuestionTitle
			$CCEExamQuestions->QuestionTitle->HrefValue = "";
			$CCEExamQuestions->QuestionTitle->TooltipValue = "";

			// NumMarks
			$CCEExamQuestions->NumMarks->HrefValue = "";
			$CCEExamQuestions->NumMarks->TooltipValue = "";
		} elseif ($CCEExamQuestions->RowType == EW_ROWTYPE_SEARCH) { // Search row

			// Question_ID
			$CCEExamQuestions->Question_ID->EditCustomAttributes = "";
			$CCEExamQuestions->Question_ID->EditValue = ew_HtmlEncode($CCEExamQuestions->Question_ID->AdvancedSearch->SearchValue);

			// Questionnaire_ID
			$CCEExamQuestions->Questionnaire_ID->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `Questionnaire_ID`, `Questionnaire_Name`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `CCEExams`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$CCEExamQuestions->Questionnaire_ID->EditValue = $arwrk;

			// Section_ID
			$CCEExamQuestions->Section_ID->EditCustomAttributes = "";
			if (trim(strval($CCEExamQuestions->Section_ID->AdvancedSearch->SearchValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`Section_ID` = " . ew_AdjustSql($CCEExamQuestions->Section_ID->AdvancedSearch->SearchValue) . "";
			}
			$sSqlWrk = "SELECT `Section_ID`, `Section_Name`, '' AS Disp2Fld, `Questionnaire_ID` FROM `CCEExamSections`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Display_Order` Asc";
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), ""));
			$CCEExamQuestions->Section_ID->EditValue = $arwrk;

			// Question
			$CCEExamQuestions->Question->EditCustomAttributes = "";
			$CCEExamQuestions->Question->EditValue = ew_HtmlEncode($CCEExamQuestions->Question->AdvancedSearch->SearchValue);

			// Display_Order
			$CCEExamQuestions->Display_Order->EditCustomAttributes = "";
			$CCEExamQuestions->Display_Order->EditValue = ew_HtmlEncode($CCEExamQuestions->Display_Order->AdvancedSearch->SearchValue);

			// IsMulti
			$CCEExamQuestions->IsMulti->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("1", "Yes");
			$arwrk[] = array("0", "No");
			$CCEExamQuestions->IsMulti->EditValue = $arwrk;

			// IsOptional
			$CCEExamQuestions->IsOptional->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("1", "Yes");
			$arwrk[] = array("0", "No");
			$CCEExamQuestions->IsOptional->EditValue = $arwrk;

			// Answer_Type
			$CCEExamQuestions->Answer_Type->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("a", "Text Box");
			$arwrk[] = array("m", "Radio/ Check Box");
			$arwrk[] = array("s", "Select");
			$arwrk[] = array("f", "File");
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$CCEExamQuestions->Answer_Type->EditValue = $arwrk;

			// Answer_Template
			$CCEExamQuestions->Answer_Template->EditCustomAttributes = "";
			$CCEExamQuestions->Answer_Template->EditValue = ew_HtmlEncode($CCEExamQuestions->Answer_Template->AdvancedSearch->SearchValue);

			// Model_Answer
			$CCEExamQuestions->Model_Answer->EditCustomAttributes = "";
			$CCEExamQuestions->Model_Answer->EditValue = ew_HtmlEncode($CCEExamQuestions->Model_Answer->AdvancedSearch->SearchValue);

			// ParentQuestionID
			$CCEExamQuestions->ParentQuestionID->EditCustomAttributes = "";

			// RequireNumber
			$CCEExamQuestions->RequireNumber->EditCustomAttributes = "";
			$CCEExamQuestions->RequireNumber->EditValue = ew_HtmlEncode($CCEExamQuestions->RequireNumber->AdvancedSearch->SearchValue);

			// MinNum
			$CCEExamQuestions->MinNum->EditCustomAttributes = "";
			$CCEExamQuestions->MinNum->EditValue = ew_HtmlEncode($CCEExamQuestions->MinNum->AdvancedSearch->SearchValue);

			// MaxNum
			$CCEExamQuestions->MaxNum->EditCustomAttributes = "";
			$CCEExamQuestions->MaxNum->EditValue = ew_HtmlEncode($CCEExamQuestions->MaxNum->AdvancedSearch->SearchValue);

			// RecallPrevAnswer
			$CCEExamQuestions->RecallPrevAnswer->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("1", "Yes");
			$arwrk[] = array("0", "No");
			$CCEExamQuestions->RecallPrevAnswer->EditValue = $arwrk;

			// QuestionTitle
			$CCEExamQuestions->QuestionTitle->EditCustomAttributes = "";
			$CCEExamQuestions->QuestionTitle->EditValue = ew_HtmlEncode($CCEExamQuestions->QuestionTitle->AdvancedSearch->SearchValue);

			// NumMarks
			$CCEExamQuestions->NumMarks->EditCustomAttributes = "";
			$CCEExamQuestions->NumMarks->EditValue = ew_HtmlEncode($CCEExamQuestions->NumMarks->AdvancedSearch->SearchValue);
		}

		// Call Row Rendered event
		if ($CCEExamQuestions->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$CCEExamQuestions->Row_Rendered();
	}

	// Validate search
	function ValidateSearch() {
		global $gsSearchError, $CCEExamQuestions;

		// Initialize
		$gsSearchError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return TRUE;

		// Return validate result
		$ValidateSearch = ($gsSearchError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateSearch = $ValidateSearch && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			if ($gsSearchError <> "") $gsSearchError .= "<br>";
			$gsSearchError .= $sFormCustomError;
		}
		return $ValidateSearch;
	}

	// Load advanced search
	function LoadAdvancedSearch() {
		global $CCEExamQuestions;
		$CCEExamQuestions->Question_ID->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_Question_ID");
		$CCEExamQuestions->Questionnaire_ID->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_Questionnaire_ID");
		$CCEExamQuestions->Section_ID->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_Section_ID");
		$CCEExamQuestions->Question->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_Question");
		$CCEExamQuestions->Display_Order->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_Display_Order");
		$CCEExamQuestions->IsMulti->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_IsMulti");
		$CCEExamQuestions->IsOptional->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_IsOptional");
		$CCEExamQuestions->Answer_Type->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_Answer_Type");
		$CCEExamQuestions->Answer_Template->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_Answer_Template");
		$CCEExamQuestions->Model_Answer->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_Model_Answer");
		$CCEExamQuestions->ParentQuestionID->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_ParentQuestionID");
		$CCEExamQuestions->RequireNumber->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_RequireNumber");
		$CCEExamQuestions->MinNum->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_MinNum");
		$CCEExamQuestions->MaxNum->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_MaxNum");
		$CCEExamQuestions->RecallPrevAnswer->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_RecallPrevAnswer");
		$CCEExamQuestions->QuestionTitle->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_QuestionTitle");
		$CCEExamQuestions->NumMarks->AdvancedSearch->SearchValue = $CCEExamQuestions->getAdvancedSearch("x_NumMarks");
	}

	// Export data in HTML/CSV/Word/Excel/XML/Email format
	function ExportData() {
		global $CCEExamQuestions;
		$utf8 = FALSE;
		$bSelectLimit = EW_SELECT_LIMIT;

		// Load recordset
		if ($bSelectLimit) {
			$this->lTotalRecs = $CCEExamQuestions->SelectRecordCount();
		} else {
			if ($rs = $this->LoadRecordset())
				$this->lTotalRecs = $rs->RecordCount();
		}
		$this->lStartRec = 1;

		// Export all
		if ($CCEExamQuestions->ExportAll) {
			$this->lDisplayRecs = $this->lTotalRecs;
			$this->lStopRec = $this->lTotalRecs;
		} else { // Export one page only
			$this->SetUpStartRec(); // Set up start record position

			// Set the last record to display
			if ($this->lDisplayRecs < 0) {
				$this->lStopRec = $this->lTotalRecs;
			} else {
				$this->lStopRec = $this->lStartRec + $this->lDisplayRecs - 1;
			}
		}
		if ($bSelectLimit)
			$rs = $this->LoadRecordset($this->lStartRec-1, $this->lDisplayRecs);
		if (!$rs) {
			header("Content-Type:"); // Remove header
			header("Content-Disposition:");
			$this->ShowMessage();
			return;
		}
		if ($CCEExamQuestions->Export == "xml") {
			$XmlDoc = new cXMLDocument(EW_XML_ENCODING);
			$XmlDoc->AddRoot();
		} else {
			$ExportDoc = new cExportDocument($CCEExamQuestions, "h");
			$ExportDoc->ExportHeader();
			if ($ExportDoc->Horizontal) { // Horizontal format, write header
				$ExportDoc->BeginExportRow();
				$ExportDoc->ExportCaption($CCEExamQuestions->Question_ID);
				$ExportDoc->ExportCaption($CCEExamQuestions->Questionnaire_ID);
				$ExportDoc->ExportCaption($CCEExamQuestions->Section_ID);
				$ExportDoc->ExportCaption($CCEExamQuestions->Question);
				$ExportDoc->ExportCaption($CCEExamQuestions->Display_Order);
				$ExportDoc->ExportCaption($CCEExamQuestions->IsMulti);
				$ExportDoc->ExportCaption($CCEExamQuestions->IsOptional);
				$ExportDoc->ExportCaption($CCEExamQuestions->Answer_Type);
				$ExportDoc->ExportCaption($CCEExamQuestions->Answer_Template);
				$ExportDoc->ExportCaption($CCEExamQuestions->Model_Answer);
				$ExportDoc->ExportCaption($CCEExamQuestions->ParentQuestionID);
				$ExportDoc->ExportCaption($CCEExamQuestions->RequireNumber);
				$ExportDoc->ExportCaption($CCEExamQuestions->MinNum);
				$ExportDoc->ExportCaption($CCEExamQuestions->MaxNum);
				$ExportDoc->ExportCaption($CCEExamQuestions->RecallPrevAnswer);
				$ExportDoc->ExportCaption($CCEExamQuestions->QuestionTitle);
				$ExportDoc->ExportCaption($CCEExamQuestions->NumMarks);
				$ExportDoc->EndExportRow();
			}
		}

		// Move to first record
		$this->lRecCnt = $this->lStartRec - 1;
		if (!$rs->EOF) {
			$rs->MoveFirst();
			if (!$bSelectLimit && $this->lStartRec > 1)
				$rs->Move($this->lStartRec - 1);
		}
		while (!$rs->EOF && $this->lRecCnt < $this->lStopRec) {
			$this->lRecCnt++;
			if (intval($this->lRecCnt) >= intval($this->lStartRec)) {
				$this->LoadRowValues($rs);

				// Render row
				$CCEExamQuestions->CssClass = "";
				$CCEExamQuestions->CssStyle = "";
				$CCEExamQuestions->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->RenderRow();
				if ($CCEExamQuestions->Export == "xml") {
					$XmlDoc->AddRow();
					$XmlDoc->AddField('Question_ID', $CCEExamQuestions->Question_ID->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('Questionnaire_ID', $CCEExamQuestions->Questionnaire_ID->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('Section_ID', $CCEExamQuestions->Section_ID->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('Question', $CCEExamQuestions->Question->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('Display_Order', $CCEExamQuestions->Display_Order->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('IsMulti', $CCEExamQuestions->IsMulti->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('IsOptional', $CCEExamQuestions->IsOptional->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('Answer_Type', $CCEExamQuestions->Answer_Type->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('Answer_Template', $CCEExamQuestions->Answer_Template->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('Model_Answer', $CCEExamQuestions->Model_Answer->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('ParentQuestionID', $CCEExamQuestions->ParentQuestionID->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('RequireNumber', $CCEExamQuestions->RequireNumber->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('MinNum', $CCEExamQuestions->MinNum->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('MaxNum', $CCEExamQuestions->MaxNum->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('RecallPrevAnswer', $CCEExamQuestions->RecallPrevAnswer->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('QuestionTitle', $CCEExamQuestions->QuestionTitle->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
					$XmlDoc->AddField('NumMarks', $CCEExamQuestions->NumMarks->ExportValue($CCEExamQuestions->Export, $CCEExamQuestions->ExportOriginalValue));
				} else {
					$ExportDoc->BeginExportRow(TRUE); // Allow CSS styles if enabled
					$ExportDoc->ExportField($CCEExamQuestions->Question_ID);
					$ExportDoc->ExportField($CCEExamQuestions->Questionnaire_ID);
					$ExportDoc->ExportField($CCEExamQuestions->Section_ID);
					$ExportDoc->ExportField($CCEExamQuestions->Question);
					$ExportDoc->ExportField($CCEExamQuestions->Display_Order);
					$ExportDoc->ExportField($CCEExamQuestions->IsMulti);
					$ExportDoc->ExportField($CCEExamQuestions->IsOptional);
					$ExportDoc->ExportField($CCEExamQuestions->Answer_Type);
					$ExportDoc->ExportField($CCEExamQuestions->Answer_Template);
					$ExportDoc->ExportField($CCEExamQuestions->Model_Answer);
					$ExportDoc->ExportField($CCEExamQuestions->ParentQuestionID);
					$ExportDoc->ExportField($CCEExamQuestions->RequireNumber);
					$ExportDoc->ExportField($CCEExamQuestions->MinNum);
					$ExportDoc->ExportField($CCEExamQuestions->MaxNum);
					$ExportDoc->ExportField($CCEExamQuestions->RecallPrevAnswer);
					$ExportDoc->ExportField($CCEExamQuestions->QuestionTitle);
					$ExportDoc->ExportField($CCEExamQuestions->NumMarks);
					$ExportDoc->EndExportRow();
				}
			}
			$rs->MoveNext();
		}
		if ($CCEExamQuestions->Export <> "xml")
			$ExportDoc->ExportFooter();

		// Close recordset
		$rs->Close();

		// Clean output buffer
		if (!EW_DEBUG_ENABLED && ob_get_length())
			ob_end_clean();

		// Write BOM if utf-8
		if ($utf8 && !in_array($CCEExamQuestions->Export, array("email", "xml")))
			echo "\xEF\xBB\xBF";

		// Write debug message if enabled
		if (EW_DEBUG_ENABLED)
			echo ew_DebugMsg();

		// Output data
		if ($CCEExamQuestions->Export == "xml") {
			header("Content-Type: text/xml");
			echo $XmlDoc->XML();
		} elseif ($CCEExamQuestions->Export == "email") {
			$this->ExportEmail($ExportDoc->Text);
			$this->Page_Terminate($CCEExamQuestions->ExportReturnUrl());
		} else {
			echo $ExportDoc->Text;
		}
	}

	// Export email
	function ExportEmail($EmailContent) {
		global $Language, $CCEExamQuestions;
		$sSender = @$_GET["sender"];
		$sRecipient = @$_GET["recipient"];
		$sCc = @$_GET["cc"];
		$sBcc = @$_GET["bcc"];
		$sContentType = @$_GET["contenttype"];

		// Subject
		$sSubject = ew_StripSlashes(@$_GET["subject"]);
		$sEmailSubject = $sSubject;

		// Message
		$sContent = ew_StripSlashes(@$_GET["message"]);
		$sEmailMessage = $sContent;

		// Check sender
		if ($sSender == "") {
			$this->setMessage($Language->Phrase("EnterSenderEmail"));
			return;
		}
		if (!ew_CheckEmail($sSender)) {
			$this->setMessage($Language->Phrase("EnterProperSenderEmail"));
			return;
		}

		// Check recipient
		if (!ew_CheckEmailList($sRecipient, EW_MAX_EMAIL_RECIPIENT)) {
			$this->setMessage($Language->Phrase("EnterProperRecipientEmail"));
			return;
		}

		// Check cc
		if (!ew_CheckEmailList($sCc, EW_MAX_EMAIL_RECIPIENT)) {
			$this->setMessage($Language->Phrase("EnterProperCcEmail"));
			return;
		}

		// Check bcc
		if (!ew_CheckEmailList($sBcc, EW_MAX_EMAIL_RECIPIENT)) {
			$this->setMessage($Language->Phrase("EnterProperBccEmail"));
			return;
		}

		// Check email sent count
		if (!isset($_SESSION[EW_EXPORT_EMAIL_COUNTER]))
			$_SESSION[EW_EXPORT_EMAIL_COUNTER] = 0;
		if (intval($_SESSION[EW_EXPORT_EMAIL_COUNTER]) > EW_MAX_EMAIL_SENT_COUNT) {
			$this->setMessage($Language->Phrase("ExceedMaxEmailExport"));
			return;
		}
		if ($sEmailMessage <> "") {
			$sEmailMessage = ew_RemoveXSS($sEmailMessage);
			$sEmailMessage .= ($sContentType == "url") ? "\r\n\r\n" : "<br><br>";
		}
		if ($sContentType == "url") {
			$sUrl = ew_ConvertFullUrl(ew_CurrentPage() . "?" . $this->ExportQueryString());
			$sEmailMessage .= $sUrl; // send URL only
		} else {
			$sEmailMessage .= $EmailContent; // send HTML
		}

		// Send email
		$Email = new cEmail();
		$Email->Sender = $sSender; // Sender
		$Email->Recipient = $sRecipient; // Recipient
		$Email->Cc = $sCc; // Cc
		$Email->Bcc = $sBcc; // Bcc
		$Email->Subject = $sEmailSubject; // Subject
		$Email->Content = $sEmailMessage; // Content
		$Email->Format = ($sContentType == "url") ? "text" : "html";
		$Email->Charset = EW_EMAIL_CHARSET;
		$EventArgs = array();
		$bEmailSent = FALSE;
		if ($CCEExamQuestions->Email_Sending($Email, $EventArgs))
			$bEmailSent = $Email->Send();

		// Check email sent status
		if ($bEmailSent) {

			// Update email sent count
			$_SESSION[EW_EXPORT_EMAIL_COUNTER]++;

			// Sent email success
			$this->setMessage($Language->Phrase("SendEmailSuccess"));
		} else {

			// Sent email failure
			$this->setMessage($Email->SendErrDescription);
		}
	}

	// Export QueryString
	function ExportQueryString() {
		global $CCEExamQuestions;

		// Initialize
		$sQry = "export=html";

		// Build QueryString for search
		if ($CCEExamQuestions->getSessionBasicSearchKeyword() <> "") {
			$sQry .= "&" . EW_TABLE_BASIC_SEARCH . "=" . $CCEExamQuestions->getSessionBasicSearchKeyword() . "&" . EW_TABLE_BASIC_SEARCH_TYPE . "=" . $CCEExamQuestions->getSessionBasicSearchType();
		}
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->Question_ID); // Question_ID
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->Questionnaire_ID); // Questionnaire_ID
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->Section_ID); // Section_ID
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->Question); // Question
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->Display_Order); // Display_Order
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->IsMulti); // IsMulti
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->IsOptional); // IsOptional
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->Answer_Type); // Answer_Type
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->Answer_Template); // Answer_Template
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->Model_Answer); // Model_Answer
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->ParentQuestionID); // ParentQuestionID
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->RequireNumber); // RequireNumber
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->MinNum); // MinNum
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->MaxNum); // MaxNum
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->RecallPrevAnswer); // RecallPrevAnswer
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->QuestionTitle); // QuestionTitle
		$this->AddSearchQueryString($sQry, $CCEExamQuestions->NumMarks); // NumMarks

		// Build QueryString for pager
		$sQry .= "&" . EW_TABLE_REC_PER_PAGE . "=" . $CCEExamQuestions->getRecordsPerPage() . "&" . EW_TABLE_START_REC . "=" . $CCEExamQuestions->getStartRecordNumber();
		return $sQry;
	}

	// Add search QueryString
	function AddSearchQueryString(&$Qry, &$Fld) {
		global $CCEExamQuestions;
		$FldParm = substr($Fld->FldVar, 2);
		$FldSearchValue = $CCEExamQuestions->GetAdvancedSearch("x_" . $FldParm);
		if (strval($FldSearchValue) <> "") {
			$Qry .= "&x_" . $FldParm . "=" . FldSearchValue .
				"&z_" . $FldParm . "=" . $CCEExamQuestions->GetAdvancedSearch("z_" . $FldParm);
		}
		$FldSearchValue2 = $CCEExamQuestions->GetAdvancedSearch("y_" . $FldParm);
		if (strval($FldSearchValue2) <> "") {
			$Qry .= "&v_" . $FldParm . "=" . $CCEExamQuestions->GetAdvancedSearch("v_" . $FldParm) .
				"&y_" . $FldParm . "=" . $FldSearchValue2 .
				"&w_" . $FldParm . "=" . $CCEExamQuestions->GetAdvancedSearch("w_" . $FldParm);
		}
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	function Message_Showing(&$msg) {

		// Example:
		//$msg = "your new message";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}

	// ListOptions Load event
	function ListOptions_Load() {

		// Example: 
		//$this->ListOptions->Add("new");
		//$this->ListOptions->Items["new"]->OnLeft = TRUE; // Link on left
		//$this->ListOptions->MoveItem("new", 0); // Move to first column

	}

	// ListOptions Rendered event
	function ListOptions_Rendered() {

		// Example: 
		//$this->ListOptions->Items["new"]->Body = "xxx";

	}
}
?>