?>
                                        <input type="hidden" name="request_code" value="<?php 
                                        echo $code;
                                        ?>
" />
                                        <?php 
                                    }
                                    ?>
									<input type="hidden" name="step" value="2" />
									<?php 
                                    $query = "\tSELECT a.*, b.*, c.`questiontype_shortname`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `evaluation_form_questions` AS a\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN `evaluations_lu_questions` AS b\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tON a.`equestion_id` = b.`equestion_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN `evaluations_lu_questiontypes` AS c\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tON b.`questiontype_id` = c.`questiontype_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE a.`eform_id` = " . $db->qstr($evaluation_record["eform_id"]) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY a.`question_order` ASC";
                                    $questions = $db->GetAll($query);
                                    $total_questions = 0;
                                    if ($questions) {
                                        $total_questions = count($questions);
                                        echo Models_Evaluation::getQuestionAnswerControls($questions, $PROCESSED["eform_id"], false, true, $eprogress_id);
                                    } else {
                                        $ERROR++;
                                        $ERRORSTR[] = "There are no questions currently available for this evaluation. This problem has been reported to a system administrator; please try again later.";
                                        application_log("error", "Unable to locate any questions for evaluation [" . $evaluation_record["evaluation_id"] . "]. Database said: " . $db->ErrorMsg());
                                    }
                                    ?>
									<div class="space-above medium">
										<input type="button" class="btn" style="float: left; margin-right: 10px" onclick="window.location = '<?php 
                                    echo ENTRADA_URL;
                                    ?>
/evaluations'" value="Exit Evaluation" />
										<input type="submit" class="btn btn-primary" style="float: right" value="Submit Evaluation" />
									</div>
									<div class="clear"></div>
									</form>
	<?php 
    if ($ENTRADA_ACL->amIAllowed("evaluation", "create", false)) {
        ?>
		<div style="float: right">
            <a href="<?php 
        echo ENTRADA_URL;
        ?>
/admin/<?php 
        echo $MODULE;
        ?>
?section=add"  class="btn btn-small btn-success pull-right cursor-pointer space-below"><i class="icon-plus-sign icon-white"></i> Add New Evaluation</a>
		</div>
		<div style="clear: both"></div>
		<?php 
    }
    $evaluations = Models_Evaluation::getAuthorEvaluations();
    if (count($evaluations)) {
        $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/jquery/jquery.dataTables.min.js\"></script>";
        $HEAD[] = "<script type=\"text/javascript\">\n\t\tjQuery(document).ready(function() {\n\t\t\tjQuery('#evaluations').dataTable(\n\t\t\t\t{\n\t\t\t\t\t'sPaginationType': 'full_numbers',\n\t\t\t\t\t'bInfo': false,\n\t\t\t\t\t'aoColumns': [\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t{'sType': 'alt-string'},\n\t\t\t\t\t\t{'sType': 'alt-string'},\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tnull\n\t\t\t\t\t],\n                    'bAutoWidth': false\n\t\t\t\t}\n\t\t\t);\n\t\t});\n\t\t</script>";
        if ($ENTRADA_ACL->amIAllowed("evaluation", "delete", false)) {
            ?>
            <form action="<?php 
            echo ENTRADA_URL;
            ?>
/admin/evaluations?section=delete" method="post">
            <?php 
        }
        ?>
		<table id="evaluations" class="tableList" cellspacing="0" cellpadding="1" summary="List of Evaluations">
			<colgroup>
				<col class="modified" />
                        <col class="date" />
	                </colgroup>
	                <thead>
                        <tr>
                            <td class="modified">&nbsp;</td>
                            <td class="title">Evaluator</td>
                            <td class="title">Evaluation Target</td>
                            <td class="date-small">Attempt Progress</td>
                            <td class="date">Last Updated</td>
                        </tr>
	                </thead>
	                <tbody>
	                <?php 
                foreach ($evaluation_evaluators as $evaluation_evaluator) {
                    if (array_search($evaluation_evaluator["proxy_id"], $ignore_list) === false) {
                        $evaluation_targets_list = Models_Evaluation::getTargetsArray($EVALUATION_ID, $evaluation_evaluator["eevaluator_id"], $evaluation_evaluator["proxy_id"]);
                        if ($evaluation_targets_list) {
                            $evaluation_targets_count = count($evaluation_targets_list);
                            if (array_search($evaluation_details["target_shortname"], array("preceptor", "rotation_core", "rotation_elective")) !== false && $evaluation_details["max_submittable"]) {
                                $evaluation_details["max_submittable"] = $evaluation_targets_count * (int) $evaluation_details["max_submittable"];
                            }
                            $target_name = fetch_evaluation_target_title($evaluation_targets_list[0], $evaluation_targets_count, $evaluation_details["target_shortname"]);
                            if ($evaluation_details["target_shortname"] == "peer" && $evaluation_details["max_submittable"] == 0) {
                                $evaluation_details["max_submittable"] = $evaluation_targets_count;
                            }
                        } else {
                            $target_name = "";
                        }
                        echo "<tr>\n";
                        echo "\t<td>&nbsp;</td>\n";
                        echo "\t<td>" . $evaluation_evaluator["fullname"] . "</td>\n";
    if (!isset($evaluations) || !$evaluations) {
        if ($review_evaluations) {
            $sidebar_html = "<ul class=\"menu\">\n";
            $sidebar_html .= "\t<li class=\"link\"><a href=\"" . ENTRADA_URL . "/evaluations?view=review\">View Completed Evaluations Available for Review</a></li>\n";
            $sidebar_html .= "</ul>\n";
            new_sidebar_item("Evaluations Review", $sidebar_html, "view-review", "open", "1.9");
        }
        ?>
		<div class="display-generic">
			There are no evaluations or assessments <strong>assigned to you</strong> in the system at this time.
		</div>
		<?php 
    }
}
$request_evaluations = array();
$target_evaluations = Models_Evaluation::getTargetEvaluations();
if ($target_evaluations) {
    foreach ($target_evaluations as $target_evaluation) {
        if (isset($target_evaluation["allow_target_request"]) && $target_evaluation["allow_target_request"]) {
            $request_evaluations[] = $target_evaluation;
        }
    }
}
$query = "SELECT * FROM `evaluation_requests` AS a\n            JOIN `evaluations` AS b\n            ON a.`evaluation_id` = b.`evaluation_id`\n            WHERE `target_proxy_id` = " . $db->qstr($ENTRADA_USER->getID()) . "\n            AND `request_code` IS NOT NULL\n            AND (\n                `request_expires` = 0\n                OR `request_expires` > " . $db->qstr(time()) . "\n            )";
$requested_evaluations = $db->GetAll($query);
if (isset($requested_evaluations) && count($requested_evaluations)) {
    $sidebar_html = "<form method=\"post\" action=\"" . ENTRADA_RELATIVE . "/evaluations?section=attempt\">\n";
    $sidebar_html .= "\t<label class=\"form-nrequired\" for=\"request_code\">Request Code: </label>";
    $sidebar_html .= "  <input type=\"text\" id=\"request_code\" name=\"request_code\">";
    $sidebar_html .= "\t<br /><br /><input type=\"submit\" class=\"btn btn-small btn-primary\" value=\"Submit\" />";
    $sidebar_html .= "</form>";
        if (!$notification_user) {
            $notification_user = NotificationUser::add($proxy_id, "evaluation", $evaluation_id, $proxy_id);
        }
        $query = "SELECT * FROM `notifications` \n                    WHERE `nuser_id` = " . $db->qstr($notification_user->getID()) . " \n                    AND `proxy_id` = " . $db->qstr($proxy_id) . "\n                    AND (`sent_date` = 0 OR `sent_date` >= " . $db->qstr(strtotime("-7 days")) . ")";
        $recent_notifications = $db->GetAll($query);
        if (!isset($recent_notifications) || !$recent_notifications) {
            Notification::add($notification_user->getID(), $proxy_id, $evaluation_id, isset($pending_evaluation["event_id"]) && $pending_evaluation["event_id"] ? $pending_evaluation["event_id"] : $pending_evaluation["event_id"]);
        }
    }
}
//queue notifications for each user with the evaluations which have closed for them in the last 24 hours.
$query = "SELECT *, '0' AS `event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND a.`evaluation_finish` >= " . $db->qstr(strtotime("-10 weeks")) . "\n\t\t\tAND a.`evaluation_finish` <= " . $db->qstr(time()) . "\n\t\t\tAND c.`target_shortname` NOT IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\t\n\t\t\tUNION\n\t\t\t\n\t\t\tSELECT a.*, b.*, c.*, e.`event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tAND c.`target_shortname` IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\tJOIN `evaluation_targets` AS d\n\t\t\tON a.`evaluation_id` = d.`evaluation_id`\n\t\t\tAND d.`target_type` = 'rotation_id'\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`events` AS e\n\t\t\tON d.`target_value` = e.`rotation_id`\n\t\t\tAND a.`evaluation_start` <= e.`event_finish`\n\t\t\tAND a.`evaluation_finish` >= e.`event_finish`\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`event_contacts` AS f\n\t\t\tON e.`event_id` = f.`event_id`\n\t\t\tJOIN `evaluation_evaluators` AS g\n\t\t\tON a.`evaluation_id` = g.`evaluation_id`\n\t\t\tAND g.`evaluator_type` = 'cohort'\n\t\t\tJOIN `group_members` AS h\n\t\t\tON g.`evaluator_value` = h.`group_id`\n\t\t\tAND h.`proxy_id` = f.`etype_id`\n\t\t\tAND h.`member_active`\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND e.`event_finish` >= " . $db->qstr(time() - CLERKSHIP_EVALUATION_LOCKOUT) . "\n\t\t\tAND e.`event_finish` <= " . $db->qstr(time() - CLERKSHIP_EVALUATION_TIMEOUT) . "\n\t\t\t\n\t\t\tUNION\n\t\t\t\n\t\t\tSELECT a.*, b.*, c.*, e.`event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tAND c.`target_shortname` IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\tJOIN `evaluation_targets` AS d\n\t\t\tON a.`evaluation_id` = d.`evaluation_id`\n\t\t\tAND d.`target_type` = 'rotation_id'\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`events` AS e\n\t\t\tON d.`target_value` = e.`rotation_id`\n\t\t\tAND a.`evaluation_start` <= e.`event_finish`\n\t\t\tAND a.`evaluation_finish` >= e.`event_finish`\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`event_contacts` AS f\n\t\t\tON e.`event_id` = f.`event_id`\n\t\t\tJOIN `evaluation_evaluators` AS g\n\t\t\tON a.`evaluation_id` = g.`evaluation_id`\n\t\t\tAND g.`evaluator_type` = 'cgroup_id'\n\t\t\tJOIN `course_group_audience` AS h\n\t\t\tON g.`evaluator_value` = h.`cgroup_id`\n\t\t\tAND h.`proxy_id` = f.`etype_id`\n\t\t\tAND h.`active` = 1\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND e.`event_finish` >= " . $db->qstr(time() - CLERKSHIP_EVALUATION_LOCKOUT) . "\n\t\t\tAND e.`event_finish` <= " . $db->qstr(time() - CLERKSHIP_EVALUATION_TIMEOUT) . "\n\t\t\t\n\t\t\tUNION\n\t\t\t\n\t\t\tSELECT a.*, b.*, c.*, e.`event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tAND c.`target_shortname` IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\tJOIN `evaluation_targets` AS d\n\t\t\tON a.`evaluation_id` = d.`evaluation_id`\n\t\t\tAND d.`target_type` = 'rotation_id'\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`events` AS e\n\t\t\tON d.`target_value` = e.`rotation_id`\n\t\t\tAND a.`evaluation_start` <= e.`event_finish`\n\t\t\tAND a.`evaluation_finish` >= e.`event_finish`\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`event_contacts` AS f\n\t\t\tON e.`event_id` = f.`event_id`\n\t\t\tJOIN `evaluation_evaluators` AS g\n\t\t\tON a.`evaluation_id` = g.`evaluation_id`\n\t\t\tAND g.`evaluator_type` = 'proxy_id'\n\t\t\tAND g.`evaluator_value` = f.`etype_id`\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND e.`event_finish` >= " . $db->qstr(time() - CLERKSHIP_EVALUATION_LOCKOUT) . "\n\t\t\tAND e.`event_finish` <= " . $db->qstr(time() - CLERKSHIP_EVALUATION_TIMEOUT);
$ended_evaluations = $db->GetAll($query);
if ($ended_evaluations) {
    foreach ($ended_evaluations as $evaluation) {
        $overdue_evaluations[$evaluation["evaluation_id"] . (isset($evaluation["event_id"]) && $evaluation["event_id"] ? "-" . $evaluation["event_id"] : "")] = Models_Evaluation::getOverdueEvaluations($evaluation);
    }
}
foreach ($overdue_evaluations as $overdue_evaluation_users) {
    foreach ($overdue_evaluation_users as $overdue_evaluation) {
        $evaluation_id = $overdue_evaluation["evaluation_id"];
        require_once "Models/notifications/NotificationUser.class.php";
        require_once "Models/notifications/Notification.class.php";
        $proxy_id = $overdue_evaluation["user"]["id"];
        $notification_user = NotificationUser::get($proxy_id, "evaluation_overdue", $evaluation_id, $proxy_id);
        if (!$notification_user) {
            $notification_user = NotificationUser::add($proxy_id, "evaluation_overdue", $evaluation_id, $proxy_id);
        }
        $query = "SELECT * FROM `notifications` \n                    WHERE `nuser_id` = " . $db->qstr($notification_user->getID()) . " \n                    AND `proxy_id` = " . $db->qstr($proxy_id) . "\n                    AND (`sent_date` = 0 OR `sent_date` >= " . $db->qstr(strtotime("-7 days")) . ")";
        $recent_notifications = $db->GetAll($query);
        if (!isset($recent_notifications) || !$recent_notifications) {
							<?php 
            $query = "SELECT * FROM `evaluations_lu_questiontypes`\n\t\t\t\t\t\t\t\t\t\t\tWHERE `questiontype_active` = 1";
            $questiontypes = $db->GetAll($query);
            if ($questiontypes) {
                foreach ($questiontypes as $questiontype) {
                    echo "<option " . (isset($PROCESSED["questiontype_id"]) && $PROCESSED["questiontype_id"] == $questiontype["questiontype_id"] || (!isset($PROCESSED["questiontype_id"]) || !$PROCESSED["questiontype_id"]) && $questiontype["questiontype_id"] == 1 ? "selected=\"selected\" " : "") . "value=\"" . $questiontype["questiontype_id"] . "\">" . $questiontype["questiontype_title"] . "</option>\n";
                }
            }
            ?>
						</select>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						&nbsp;
					</td>
				</tr>
				<?php 
            echo Models_Evaluation::getEditQuestionControls($PROCESSED);
            ?>
			</tbody>
			</table>
			</form>
            <?php 
            if (in_array($questiontype["questiontype_shortname"], array("rubric", "selectbox", "matrix_single", "vertical_matrix"))) {
            }
            ?>
			<?php 
            break;
    }
}
										<ul class="page-action">
											<li><a href="<?php 
                        echo ENTRADA_URL;
                        ?>
/admin/evaluations/questions?form_id=<?php 
                        echo $FORM_ID;
                        ?>
">Attach Evaluation Questions</a></li>
										</ul>
									</div>
									<?php 
                    }
                    $query = "SELECT a.*, b.*\n\t\t\t\t\t\t\t\t\t\t\tFROM `evaluation_form_questions` AS a\n\t\t\t\t\t\t\t\t\t\t\tJOIN `evaluations_lu_questions` AS b\n\t\t\t\t\t\t\t\t\t\t\tON a.`equestion_id` = b.`equestion_id`\n\t\t\t\t\t\t\t\t\t\t\tWHERE a.`eform_id` = " . $db->qstr($FORM_ID) . "\n\t\t\t\t\t\t\t\t\t\t\tORDER BY a.`question_order` ASC";
                    $questions = $db->GetAll($query);
                    if ($questions) {
                        Models_Evaluation::getQuestionAnswerControls($questions, $FORM_ID, $ALLOW_QUESTION_MODIFICATIONS);
                    } else {
                        $ONLOAD[] = "\$('display-no-question-message').show()";
                    }
                    ?>
								<div id="display-no-question-message" class="display-generic" style="display: none">
									There are currently <strong>no questions</strong> associated with this evaluation form.<br /><br />To create questions in this form click the <strong>Attach Evaluation Questions</strong> link above.
								</div>
							</td>
						</tr>
					</tbody>
					</table>
					<div id="disable-form-confirmation-box" class="modal-confirmation">
						<form action="<?php 
                    echo ENTRADA_URL;
                    ?>
                    $used_ids[] = $used_question["equestion_id"];
                }
                $temp_results = $results;
                $results = array();
                foreach ($temp_results as $temp_result) {
                    if (array_search($temp_result["equestion_id"], $used_ids) === false) {
                        $results[] = $temp_result;
                    }
                }
                add_notice("To attach evaluation questions to the selected form [" . $form_title . "], you may either click the 'paperclip' image to add one question, or select the checkboxes on the line of each question that you wish to add, then press the 'Attach Selected' button at the bottom of the page.");
                echo display_notice();
            } else {
                $FORM_ID = false;
            }
        }
        $question_controls = Models_Evaluation::getQuestionControlsArray($results);
        $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/jquery/jquery.dataTables.min.js\"></script>";
        $HEAD[] = "<script type=\"text/javascript\">\n\t\tvar question_controls = " . json_encode($question_controls) . ";\n\t\tvar modalDialog;\n\t\tvar oTable;\n\t\tjQuery(document).ready(function() {\n\t\t\tmodalDialog = new Control.Modal(\$('false-link'), {\n\t\t\t\tposition:\t\t'center',\n\t\t\t\toverlayOpacity:\t0.75,\n\t\t\t\tcloseOnClick:\t'overlay',\n\t\t\t\tclassName:\t\t'default-tooltip',\n\t\t\t\tfade:\t\t\ttrue,\n\t\t\t\tfadeDuration:\t0.30,\n\t\t\t\twidth: 755\n\t\t\t});\n\t\t\toTable = jQuery('#evaluationquestions').dataTable(\n\t\t\t\t{    \n\t\t\t\t\t'sPaginationType': 'full_numbers',\n\t\t\t\t\t'bInfo': false,\n                    'bAutoWidth': false\n\t\t\t\t}\n\t\t\t);\n\t\t});\n\n\t\tfunction openDialog (equestion_id) {\n\t\t\tif (equestion_id) {\n\t\t\t\tmodalDialog.container.update('<div id=\"form-questions-list\">'+question_controls[equestion_id]+'</div>');\n\t\t\t\tmodalDialog.open();\n\t\t\t} else {\n\t\t\t\tmodalDialog.open();\n\t\t\t}\n\t\t}\n\t\t</script>";
        ?>
		<form action="<?php 
        echo ENTRADA_URL;
        ?>
/admin/evaluations/questions?<?php 
        echo replace_query(array("section" => "attach"));
        ?>
" method="post">
		<table class="tableList" id="evaluationquestions" cellspacing="0" summary="List of Evaluation Questions">
		<colgroup>
			<col class="modified" />
            <col class="actions" />
			<col class="title" />
     $preceptor_evaluation = false;
 }
 if ((isset($etarget_id) && $etarget_id || isset($proxy_id) && $proxy_id) && isset($eevaluator_id) && $eevaluator_id) {
     $evaluation_targets = Models_Evaluation::getTargetsArray($RECORD_ID, $eevaluator_id, $ENTRADA_USER->getID(), false, true, false, $erequest_id);
     foreach ($evaluation_targets as $evaluation_target) {
         if (!isset($preceptor_evaluation) || !$preceptor_evaluation) {
             if (isset($proxy_id) && $proxy_id && isset($evaluation_target["proxy_id"]) && $evaluation_target["proxy_id"] == $proxy_id) {
                 $found = true;
                 break;
             } elseif (isset($etarget_id) && $etarget_id && isset($evaluation_target["etarget_id"]) && $evaluation_target["etarget_id"] == $etarget_id) {
                 $proxy_id = $evaluation_target["proxy_id"];
                 $found = true;
                 break;
             }
         } elseif ($preceptor_evaluation == $evaluation_target["event_id"]) {
             $preceptors = Models_Evaluation::getPreceptorArray($RECORD_ID, $preceptor_evaluation, $ENTRADA_USER->getID());
             foreach ($preceptors as $preceptor) {
                 if ($preceptor["proxy_id"] == $proxy_id) {
                     $found = true;
                     break;
                 }
             }
             break;
         }
     }
     if (isset($found) && $found) {
         $query_profile = "\n\t\t\t\t\t\t\t\tSELECT a.*, b.`group`, b.`role`, b.`organisation_id`\n\t\t\t\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\t\t\t\tON b.`user_id` = a.`id`\n\t\t\t\t\t\t\t\tWHERE  b.`app_id` IN (" . AUTH_APP_IDS_STRING . ")\n\t\t\t\t\t\t\t\tAND b.`account_active` = 'true'\n\t\t\t\t\t\t\t\tAND (b.`access_starts` = '0' OR b.`access_starts` < " . $db->qstr(time()) . ")\n\t\t\t\t\t\t\t\tAND (b.`access_expires` = '0' OR b.`access_expires` >= " . $db->qstr(time()) . ")\n\t\t\t\t\t\t\t\tAND a.`id` = " . $db->qstr((int) $proxy_id) . "\n\t\t\t\t\t\t\t\tAND b.`organisation_id` = " . $db->qstr($ENTRADA_USER->getActiveOrganisation()) . "\n\t\t\t\t\t\t\t\tGROUP BY a.`id`";
         $user = $db->GetRow($query_profile);
         if ($user) {
             echo "<div id=\"result-" . $proxy_id . "\" class=\"media ps-media-padding\" style=\"overflow: visible;" . ($key % 2 == 1 ? " background-color: rgb(238, 238, 238);" : "") . "\">\n";
             $offical_file_active = false;
 public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
 {
     global $db;
     //If asserting is off then return true right away
     if (isset($resource->assert) && $resource->assert == false || isset($acl->_entrada_last_query) && isset($acl->_entrada_last_query->assert) && $acl->_entrada_last_query->assert == false) {
         return true;
     }
     if (isset($resource->eform_id)) {
         $eform_id = $resource->eform_id;
     } else {
         if (isset($acl->_entrada_last_query->eform_id)) {
             $eform_id = $acl->_entrada_last_query->eform_id;
         } else {
             //Parse out the user ID and course ID
             $resource_id = $resource->getResourceId();
             $resource_type = preg_replace('/[0-9]+/', "", $resource_id);
             if ($resource_type !== "evaluationform") {
                 //This only asserts for users authoring evaluation forms.
                 return false;
             }
             $eform_id = preg_replace('/[^0-9]+/', "", $resource_id);
         }
     }
     $role_id = $role->getRoleId();
     $access_id = preg_replace('/[^0-9]+/', "", $role_id);
     $query = "SELECT `user_id` FROM `" . AUTH_DATABASE . "`.`user_access`\n\t\t\t\t\tWHERE `id` = " . $db->qstr($access_id);
     $user_id = $db->GetOne($query);
     if (!isset($user_id) || !$user_id) {
         $role_id = $acl->_entrada_last_query_role->getRoleId();
         $access_id = preg_replace('/[^0-9]+/', "", $role_id);
         $query = "SELECT `user_id` FROM `" . AUTH_DATABASE . "`.`user_access`\n\t\t\t\t\t\tWHERE `id` = " . $db->qstr($access_id);
         $user_id = $db->GetOne($query);
     }
     $permissions = Models_Evaluation::getFormAuthorPermissions($eform_id);
     if ($permissions) {
         return true;
     } else {
         return false;
     }
 }
 if ($report["type"] == "Course") {
     echo "<td><h3>Course code:</h3></td><td>[{$type['code']}]</td></tr>";
 } else {
     echo "<td colspan=\"2\" /></tr>";
 }
 echo "\t<tr>\n";
 echo "\t\t<td><h3> Evaluation period:</h3></td>\n";
 echo "\t\t<td>" . date("M jS", $report["evaluation_start"]) . "  -  " . date("M jS Y", $report["evaluation_finish"]) . "</td>";
 if ((int) $report["release_date"]) {
     echo "\t<td><h3>Released:</h3></td>\n";
     echo "\t<td>" . date("M jS Y", $report["release_date"]) . "</td>";
 } else {
     echo "\t<td colspan=\"2\">&nbsp;</td>";
 }
 echo "\t</tr>\n";
 $evaluators_list = Models_Evaluation::getEvaluators($report["evaluation"]);
 $evaluators = count($evaluators_list);
 if ($STUDENTS) {
     $query = "\tSELECT COUNT(DISTINCT(a.`proxy_id`)) `total`,  b.`group_name`\n\t\t\t\t\t\tFROM `group_members` a, `evaluation_evaluators` ev\n\t\t\t\t\t\tJOIN `groups` AS b\n\t\t\t\t\t\tON a.`group_id` = b.`group_id`\n\t\t\t\t\t\tWHERE ev.`evaluator_type` = 'cohort'\n\t\t\t\t\t\tAND ev.`evaluator_value` = a.`group_id`\n\t\t\t\t\t\tAND a.`member_active` = '1'\n\t\t\t\t\t\tAND ev.`evaluation_id` = " . $db->qstr($report["evaluation"]);
     $class = $db->GetRow($query);
 }
 $updated = $db->GetOne("SELECT MAX(`updated_date`) FROM `evaluation_progress`\n\t\t\t\t\t\t\t\tWHERE `etarget_id` = " . $db->qstr($target) . " AND `progress_value` <> 'cancelled'");
 $cancelled = $db->GetOne("\tSELECT COUNT(`eprogress_id`) FROM `evaluation_progress`\n\t\t\t\t\t\t\t\t\tWHERE `etarget_id` = " . $db->qstr($target) . " AND `progress_value` = 'cancelled'");
 $progress = $db->GetOne("\tSELECT COUNT(`eprogress_id`) FROM `evaluation_progress`\n\t\t\t\t\t\t\t\t\tWHERE `etarget_id` = " . $db->qstr($target) . " AND `progress_value` = 'inprogress'");
 $completed = $db->GetOne("\tSELECT COUNT(`eprogress_id`) FROM `evaluation_progress`\n\t\t\t\t\t\t\t\t\tWHERE `etarget_id` = " . $db->qstr($target) . " AND `progress_value` = 'complete'");
 echo "<tr><td><h3>Evaluators:</h3></td>";
 /**
  * Calculate number of evaluators, the class, and extra indviduals not in the class.
  */
 if ($STUDENTS && $class["total"] > 0) {
     $indies = $evaluators - $class["total"];
/**
 * Entrada [ http://www.entrada-project.org ]
 *
 * Serves the categories list up in a select box.
 *
 * @author Organisation: Queen's University
 * @author Unit: School of Medicine
 * @author Developer: Matt Simpson <*****@*****.**>
 * @copyright Copyright 2010 Queen's University. All Rights Reserved.
 *
*/
@set_include_path(implode(PATH_SEPARATOR, array(dirname(__FILE__) . "/../core", dirname(__FILE__) . "/../core/includes", dirname(__FILE__) . "/../core/library", get_include_path())));
/**
 * Include the Entrada init code.
 */
require_once "init.inc.php";
if (isset($_POST["response_text"]) && $_POST["response_text"]) {
    $question_data = json_decode($_POST["response_text"], true);
}
if (isset($_GET["responses"]) && $_GET["responses"]) {
    $responses = (int) $_GET["responses"];
}
if (isset($_POST["questiontype"]) && $_POST["questiontype"]) {
    $questiontype = (int) $_POST["questiontype"];
    $query = "SELECT `questiontype_shortname` FROM `evaluations_lu_questiontypes` WHERE `questiontype_id` = " . $db->qstr($questiontype);
    $questiontype = $db->GetOne($query);
}
$question_data["responses_count"] = $responses;
echo Models_Evaluation::getQuestionResponseList($question_data, $questiontype);
    add_error("Your account does not have the permissions required to use this feature of this module.<br /><br />If you believe you are receiving this message in error please contact <a href=\"mailto:" . html_encode($AGENT_CONTACTS["administrator"]["email"]) . "\">" . html_encode($AGENT_CONTACTS["administrator"]["name"]) . "</a> for assistance.");
    echo display_error();
    application_log("error", "Group [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"] . "] and role [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["role"] . "] does not have access to this module [" . $MODULE . "]");
} else {
    ?>
	<h1>Manage Evaluation Forms</h1>

    <div style="float: right">
        <a href="<?php 
    echo ENTRADA_URL;
    ?>
/admin/evaluations/forms?section=add"  class="btn btn-small btn-success pull-right cursor-pointer space-below"><i class="icon-plus-sign icon-white"></i> Create New Evaluation Form</a>
    </div>
	<div class="clear"></div>
	<?php 
    $results = Models_Evaluation::getAuthorEvaluationForms();
    if ($results) {
        $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/jquery/jquery.dataTables.min.js\"></script>";
        $HEAD[] = "<script type=\"text/javascript\">\n\t\tjQuery(document).ready(function() {\n\t\t\tjQuery('#evaluationforms').dataTable(\n\t\t\t\t{\n\t\t\t\t\t'sPaginationType': 'full_numbers',\n\t\t\t\t\t'bInfo': false,\n                    'bAutoWidth': false\n\t\t\t\t}\n\t\t\t);\n\t\t});\n\t\t</script>";
        ?>
		<form action="<?php 
        echo ENTRADA_URL;
        ?>
/admin/evaluations/forms?section=delete" method="post">
		<table class="tableList" id="evaluationforms" cellspacing="0" summary="List of Evaluation Forms">
		<colgroup>
			<col class="modified" />
			<col class="general" />
			<col class="title" />
		</colgroup>
		<thead>
Exemple #14
0
                             $PROCESSED["evaluation_evaluators"][] = array("evaluator_type" => "proxy_id", "evaluator_value" => $result["proxy_id"]);
                         }
                     }
                 }
             } else {
                 add_error("You must select at least one individual to act as an evaluator.");
             }
             break;
     }
     if (empty($PROCESSED["evaluation_evaluators"])) {
         add_error("Please select an appropriate type of evaluator (i.e. entire class, percentage, etc).");
     }
 } elseif ($evaluation_target_type != "peer") {
     add_error("Please select an appropriate type of evaluator (i.e. entire class, percentage, etc).");
 }
 $PROCESSED = Models_Evaluation::processTargets($_POST, $PROCESSED);
 /**
  * Non-required field "associated_reviewer" / Associated Reviewers (array of proxy ids).
  * This is actually accomplished after the event is inserted below.
  */
 if (isset($_POST["associated_reviewer"])) {
     $associated_reviewers = explode(",", $_POST["associated_reviewer"]);
     foreach ($associated_reviewers as $contact_order => $proxy_id) {
         if ($proxy_id = clean_input($proxy_id, array("trim", "int"))) {
             $PROCESSED["associated_reviewers"][(int) $contact_order] = $proxy_id;
         }
     }
 }
 /**
  * Processing for evaluation_evaluators table.
  */
         * Clears all open buffers so we can return a plain response for the Javascript.
         */
        ob_clear_open_buffers();
        if (isset($_POST["form_id"]) && ($form_id = clean_input($_POST["form_id"], "int"))) {
            $PROCESSED["form_id"] = $form_id;
        }
        if (isset($_POST["evaluation_id"]) && ($evaluation_id = clean_input($_POST["evaluation_id"], "int"))) {
            $PROCESSED["evaluation_id"] = $evaluation_id;
        }
        if (isset($PROCESSED["evaluation_id"])) {
            $query = "SELECT * FROM `evaluation_evaluators` WHERE `evaluation_id` = " . $db->qstr($PROCESSED["evaluation_id"]);
            $evaluators = $db->GetAll();
            $PROCESSED["evaluation_evaluators"] = $evaluators;
            $query = "SELECT * FROM `evaluation_targets` WHERE `evaluation_id` = " . $db->qstr($PROCESSED["evaluation_id"]);
            $targets = $db->GetAll();
            $PROCESSED["evaluation_targets"] = $targets;
        }
        if (isset($_POST["options_for"]) && ($tmp_input = clean_input($_POST["options_for"], array("trim")))) {
            $options_for = $tmp_input;
        } else {
            $options_for = false;
        }
    }
    $form_id = 0;
    if ((!$use_ajax || $options_for) && $ENTRADA_USER->getActiveOrganisation()) {
        Models_Evaluation::getTargetControls($PROCESSED, $options_for);
    }
    if ($use_ajax) {
        exit;
    }
}
 public static function getQuestionParents($equestion_id)
 {
     global $db;
     $question_parents = array();
     $query = "SELECT * FROM `evaluations_lu_questions` WHERE `equestion_id` = " . $db->qstr($equestion_id);
     $evaluation_questions = $db->GetAll($query);
     foreach ($evaluation_questions as $evaluation_question) {
         $question_parents[$evaluation_question["equestion_id"]] = $evaluation_question;
         $question_grandparents = Models_Evaluation::getQuestionParents($evaluation_question["question_parent_id"]);
         foreach ($question_grandparents as $question_grandparent) {
             $question_parents[$question_grandparent["equestion_id"]] = $question_grandparent;
         }
     }
     return $question_parents;
 }
<?php

/**
 * Entrada [ http://www.entrada-project.org ]
 *
 * Serves the categories list up in a select box.
 *
 * @author Organisation: Queen's University
 * @author Unit: School of Medicine
 * @author Developer: Matt Simpson <*****@*****.**>
 * @copyright Copyright 2010 Queen's University. All Rights Reserved.
 *
*/
@set_include_path(implode(PATH_SEPARATOR, array(dirname(__FILE__) . "/../core", dirname(__FILE__) . "/../core/includes", dirname(__FILE__) . "/../core/library", get_include_path())));
/**
 * Include the Entrada init code.
 */
require_once "init.inc.php";
if (isset($_POST["response_text"]) && $_POST["response_text"]) {
    $question_data = json_decode($_POST["response_text"], true);
}
if (isset($_GET["columns"]) && $_GET["columns"]) {
    $columns = (int) $_GET["columns"];
}
if (isset($_GET["categories"]) && $_GET["categories"]) {
    $categories = (int) $_GET["categories"];
}
$question_data["categories_count"] = $categories;
$question_data["columns_count"] = $columns;
echo Models_Evaluation::getRubricCategoryList($question_data);
                     $ERROR++;
                     application_log("error", "Unable to insert a new clinical presentation to the database when editing an evaluation form question. Database said: " . $db->ErrorMsg());
                 }
             }
         }
     }
     header("Location: " . ENTRADA_URL . "/admin/evaluations/forms?section=edit&id=" . $FORM_ID . "&success=" . ($ERROR ? "false" : "true"));
     break;
 case 1:
 default:
     /**
      * Fetch the Clinical Presentation details.
      */
     $clinical_presentations_list = array();
     $clinical_presentations = array();
     $results = Models_Evaluation::getClinicalPresentations();
     if ($results) {
         foreach ($results as $result) {
             $clinical_presentations_list[$result["objective_id"]] = $result["objective_name"];
         }
     }
     if (isset($_POST["clinical_presentations_submit"]) && $_POST["clinical_presentations_submit"]) {
         if (isset($_POST["clinical_presentations"]) && is_array($_POST["clinical_presentations"]) && count($_POST["clinical_presentations"])) {
             foreach ($_POST["clinical_presentations"] as $objective_id) {
                 if ($objective_id = clean_input($objective_id, array("trim", "int"))) {
                     $query = "SELECT a.`objective_id`\n\t\t\t\t\t\t\t\t\t\t\tFROM `global_lu_objectives` AS a\n\t\t\t\t\t\t\t\t\t\t\tJOIN `evaluation_form_question_objectives` AS b\n\t\t\t\t\t\t\t\t\t\t\tON b.`efquestion_id` = " . $db->qstr($EFQUESTION_ID) . "\n\t\t\t\t\t\t\t\t\t\t\tAND a.`objective_id` = b.`objective_id`\n\t\t\t\t\t\t\t\t\t\t\tJOIN `objective_organisation` AS c\n\t\t\t\t\t\t\t\t\t\t\tON a.`objective_id` = c.`objective_id`\n\t\t\t\t\t\t\t\t\t\t\tWHERE a.`objective_id` = " . $db->qstr($objective_id) . "\n\t\t\t\t\t\t\t\t\t\t\tAND c.`organisation_id` = " . $db->qstr($ENTRADA_USER->getActiveOrganisation()) . "\n\t\t\t\t\t\t\t\t\t\t\tAND b.`objective_type` = 'event'\n\t\t\t\t\t\t\t\t\t\t\tAND a.`objective_active` = '1'";
                     $result = $db->GetRow($query);
                     if ($result) {
                         $clinical_presentations[$objective_id] = $clinical_presentations_list[$objective_id];
                     }
                 }
<?php

/**
 * Entrada [ http://www.entrada-project.org ]
 *
 * Serves the categories list up in a select box.
 *
 * @author Organisation: Queen's University
 * @author Unit: School of Medicine
 * @author Developer: Matt Simpson <*****@*****.**>
 * @copyright Copyright 2010 Queen's University. All Rights Reserved.
 *
*/
@set_include_path(implode(PATH_SEPARATOR, array(dirname(__FILE__) . "/../core", dirname(__FILE__) . "/../core/includes", dirname(__FILE__) . "/../core/library", get_include_path())));
/**
 * Include the Entrada init code.
 */
require_once "init.inc.php";
if (isset($_POST["response_text"]) && $_POST["response_text"]) {
    $question_data = json_decode($_POST["response_text"], true);
}
if (isset($_GET["columns"]) && $_GET["columns"]) {
    $columns = (int) $_GET["columns"];
}
if (isset($_GET["categories"]) && $_GET["categories"]) {
    $categories = (int) $_GET["categories"];
}
$question_data["categories_count"] = $categories;
$question_data["columns_count"] = $columns;
echo Models_Evaluation::getRubricColumnList($question_data);
 * @version $Id: save-response.inc.php 1170 2010-05-01 14:35:01Z simpson $
 *
*/
if (!defined("PARENT_INCLUDED") || !defined("IN_PUBLIC_EVALUATIONS")) {
    /**
     * @exception 0: Unable to start processing request.
     */
    echo 0;
    exit;
} elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) {
    /**
     * @exception 0: Unable to start processing request.
     */
    echo 0;
    exit;
}
ob_clear_open_buffers();
if ($RECORD_ID) {
    if (isset($_POST["event_id"]) && ($event_id = clean_input($_POST["event_id"], "int"))) {
        if (isset($_POST["preceptor_proxy_id"]) && ($tmp_input = clean_input($_POST["preceptor_proxy_id"], "int"))) {
            $preceptor_proxy_id = $tmp_input;
        }
        $output = Models_Evaluation::getPreceptorSelect($RECORD_ID, $event_id, $ENTRADA_USER->getID(), isset($preceptor_proxy_id) && $preceptor_proxy_id ? $preceptor_proxy_id : 0);
        if ($output) {
            echo "<br /><div class=\"content-small\">Please choose a clerkship preceptor to evaluate: \n";
            echo $output;
            echo "</div>\n";
        }
    }
}
exit;
                    $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/AutoCompleteList.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>";
                    $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/picklist.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>\n";
                    $HEAD[] = "<script src=\"" . ENTRADA_URL . "/javascript/elementresizer.js\" type=\"text/javascript\"></script>\n";
                    /**
                     * Compiles the full list of reviewers.
                     */
                    $REVIEWER_LIST = array();
                    $query = "\tSELECT a.`id` AS `proxy_id`, CONCAT_WS(', ', a.`lastname`, a.`firstname`) AS `fullname`, a.`organisation_id`\n\t\t\t\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\t\t\t\tON b.`user_id` = a.`id`\n\t\t\t\t\t\t\t\tWHERE b.`app_id` = '" . AUTH_APP_ID . "'\n\t\t\t\t\t\t\t\tAND (b.`group` = 'faculty' OR (b.`group` = 'resident' AND b.`role` = 'lecturer') OR b.`group` = 'staff' OR b.`group` = 'medtech')\n\t\t\t\t\t\t\t\tORDER BY a.`lastname` ASC, a.`firstname` ASC";
                    $results = $db->GetAll($query);
                    if ($results) {
                        foreach ($results as $result) {
                            $REVIEWER_LIST[$result["proxy_id"]] = array('proxy_id' => $result["proxy_id"], 'fullname' => $result["fullname"], 'organisation_id' => $result['organisation_id']);
                        }
                    }
                    $EVALUATOR_LIST = array();
                    $evaluators = Models_Evaluation::getEvaluators($EVALUATION_ID);
                    if ($evaluators) {
                        foreach ($evaluators as $evaluator) {
                            $EVALUATOR_LIST[$evaluator["proxy_id"]] = array("proxy_id" => $evaluator["proxy_id"], "fullname" => $evaluator["fullname"], "organisation_id" => $evaluator["organisation_id"]);
                        }
                    }
                    if (has_error() || has_notice()) {
                        echo display_status_messages();
                    }
                    $ONLOAD[] = "initFormOptions()";
                    ?>
					<script type="text/javascript">
					function initFormOptions() {
						if ($('target_type_rotations') != undefined) {
							var target_type = 'rotations';
							if ($(target_type + '_options') != undefined) {
 if ($question_responses) {
     $evaluation_question["question_responses"] = array();
     foreach ($question_responses as $question_response) {
         $query = "SELECT * FROM `evaluation_responses` \n                                            WHERE `eqresponse_id` = " . $db->qstr($question_response["eqresponse_id"]) . "\n                                            AND `eprogress_id` IN (" . $evaluation_question["eprogress_ids"] . ")";
         $responses = $db->GetAll($query);
         if ($responses) {
             $question_response["chosen"] = count($responses);
         } else {
             $question_response["chosen"] = 0;
         }
         $evaluation_question["flat_responses"][$question_response["response_order"]] = $responses ? count($responses) : 0;
         $evaluation_question["question_responses"][$question_response["eqresponse_id"]] = $question_response;
     }
     $evaluation_question["question_parents"] = Models_Evaluation::getQuestionParents($evaluation_question["question_parent_id"]);
     $evaluation_question["question_parent_ids"] = array_keys($evaluation_question["question_parents"]);
     $evaluation_question["question_objectives"] = Models_Evaluation::getQuestionObjectives($evaluation_question["equestion_id"]);
     $evaluation_question["question_objective_ids"] = array_keys($evaluation_question["question_objectives"]);
     if (@count($evaluation_question["question_objectives"])) {
         $hidden_question_ids[] = $evaluation_question["equestion_id"];
         foreach ($evaluation_question["question_objectives"] as $objective) {
             if (!array_key_exists($objective["top_parent"]["objective_id"], $top_level_objectives)) {
                 $top_level_objectives[$objective["top_parent"]["objective_id"]] = $objective["top_parent"];
                 $top_level_objectives[$objective["top_parent"]["objective_id"]]["evaluation_question_ids"] = array($evaluation_question["equestion_id"]);
                 $top_level_objectives[$objective["top_parent"]["objective_id"]]["evaluation_dates"] = $evaluation_question["evaluation_dates"];
             } elseif (!in_array($evaluation_question["equestion_id"], $top_level_objectives[$objective["top_parent"]["objective_id"]]["evaluation_question_ids"])) {
                 if ($objective["objective_id"] == $objective["top_parent"]["objective_id"] && isset($objective["equestion_ids"]) && @count($objective["equestion_ids"])) {
                     if (!isset($top_level_objectives[$objective["top_parent"]["objective_id"]]["equestion_ids"])) {
                         $top_level_objectives[$objective["top_parent"]["objective_id"]]["equestion_ids"] = array();
                     }
                     foreach ($objective["equestion_ids"] as $question_id) {
                         $top_level_objectives[$objective["top_parent"]["objective_id"]]["equestion_ids"][] = $question_id;
} elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) {
    header("Location: " . ENTRADA_URL);
    exit;
} elseif (!$ENTRADA_ACL->amIAllowed("evaluation", "create", false)) {
    add_error("You do not have the permissions required to use this module.<br /><br />If you believe you are receiving this message in error please contact <a href=\"mailto:" . html_encode($AGENT_CONTACTS["administrator"]["email"]) . "\">" . html_encode($AGENT_CONTACTS["administrator"]["name"]) . "</a> for assistance.");
    echo display_error();
    application_log("error", "Group [" . $GROUP . "] and role [" . $ROLE . "] do not have access to this module [" . $MODULE . "]");
} else {
    if (isset($_POST["ajax"]) && $_POST["ajax"] == 1) {
        $use_ajax = true;
    } else {
        $use_ajax = false;
    }
    if ($use_ajax) {
        /**
         * Clears all open buffers so we can return a plain response for the Javascript.
         */
        ob_clear_open_buffers();
        $PROCESSED = Models_Evaluation::processTargets($_POST);
    }
    if ($PROCESSED["eform_id"]) {
        Models_Evaluation::getTargetControls($PROCESSED, "", $PROCESSED["eform_id"]);
    }
    /**
     * If we are return this via Javascript,
     * exit now so we don't get the entire page.
     */
    if ($use_ajax) {
        exit;
    }
}
     case "clerk":
         $query .= "\tAND b.`group` = 'student' AND b.`role` >= '" . (date("Y") - (date("m") < 7 ? 2 : 1)) . "'";
         break;
     case "learners":
         $query .= "\tAND (b.`group` = 'resident' OR (b.`group` = 'student' AND b.`role` >= '" . (date("Y") - (date("m") < 7 ? 2 : 1)) . "'))";
         break;
     case "director":
         $query .= "\tAND b.`group` = 'faculty' AND (b.`role` = 'director' OR b.`role` = 'admin')";
         break;
     case "coordinator":
         $query .= "\tAND b.`group` = 'staff' AND b.`role` = 'admin'";
         break;
     case "evaluators":
         $evaluator_ids_string = "";
         if (isset($_GET["id"]) && ($evaluation_id = clean_input($_GET["id"], "int"))) {
             $evaluators = Models_Evaluation::getEvaluators($evaluation_id);
             if ($evaluators) {
                 foreach ($evaluators as $evaluator) {
                     $evaluator_ids_string .= ($evaluator_ids_string ? ", " : "") . $db->qstr($evaluator["proxy_id"]);
                 }
             }
         }
         $query .= " AND a.`id` IN (" . $evaluator_ids_string . ")";
         break;
 }
 $query .= "\tAND b.`app_id` = " . $db->qstr(AUTH_APP_ID) . "\n\t\t\t\t\tAND b.`account_active` = 'true'\n\t\t\t\t\tAND (b.`access_starts`='0' OR b.`access_starts` <= " . $db->qstr(time()) . ")\n\t\t\t\t\tAND (b.`access_expires`='0' OR b.`access_expires` >= " . $db->qstr(time()) . ")\n\t\t\t\t\tGROUP BY a.`id`\n\t\t\t\t\tORDER BY `fullname` ASC";
 echo "<ul>\n";
 $results = $db->GetAll($query);
 if ($results) {
     foreach ($results as $result) {
         echo "\t<li id=\"" . (int) $result["proxy_id"] . "\">" . html_encode($result["fullname"]) . "<span class=\"informal content-small\"><br />" . html_encode($result["organisation_title"]) . " - " . html_encode(ucfirst($result["group"])) . "<br />" . html_encode($result["email"]) . "</span></li>\n";
                     $evaluation_question["response_ids"][] = $evaluation_question_response["eqresponse_id"];
                 }
             }
             $evaluation_question["selections"] = 0;
             $questions[$evaluation_question["equestion_id"]] = $evaluation_question;
         }
     }
 }
 if ($evaluation && $ENTRADA_ACL->amIAllowed(new EvaluationResource(null, null, true), 'update')) {
     array_unshift($permissions, array("contact_type" => "reviewer"));
 }
 if ($evaluation && isset($permissions) && $permissions) {
     $available_target_ids = array();
     $available_targets = array();
     $target_attempts = array();
     $completed_attempts = Models_Evaluation::getProgressRecordsByPermissions($RECORD_ID, $permissions, true, $evaluation["target_shortname"]);
     foreach ($completed_attempts as $completed_attempt) {
         if (!isset($progress_id) || !$progress_id || $completed_attempt["eprogress_id"] == $progress_id) {
             if (isset($completed_attempt["preceptor_proxy_id"]) && $completed_attempt["preceptor_proxy_id"]) {
                 $target_id = $completed_attempt["preceptor_proxy_id"];
             } elseif (isset($completed_attempt["event_id"]) && (int) $completed_attempt["event_id"]) {
                 $target_id = (int) $completed_attempt["event_id"];
             } elseif (isset($completed_attempt["target_record_id"]) && (int) $completed_attempt["target_record_id"]) {
                 $target_id = (int) $completed_attempt["target_record_id"];
             } else {
                 $target_id = (int) $completed_attempt["target_value"];
             }
             if (!array_search($target_id, $available_target_ids)) {
                 $available_target_ids[] = $target_id;
             }
             if (!isset($target_attempts[$target_id])) {
</span>
                                        <br />
                                        <a href="<?php 
    echo ENTRADA_RELATIVE;
    ?>
/profile">My Profile</a> |
                                        <a href="<?php 
    echo ENTRADA_RELATIVE;
    ?>
/evaluations">My Evaluations</a>
                                        <?php 
    /**
     * Cache any outstanding evaluations.
     */
    if (!isset($ENTRADA_CACHE) || !$ENTRADA_CACHE->test("evaluations_outstanding_" . AUTH_APP_ID . "_" . $ENTRADA_USER->getID())) {
        $evaluations_outstanding = Models_Evaluation::getOutstandingEvaluations($ENTRADA_USER->getID(), $ENTRADA_USER->getActiveOrganisation(), true);
        if (isset($ENTRADA_CACHE)) {
            $ENTRADA_CACHE->save($evaluations_outstanding, "evaluations_outstanding_" . AUTH_APP_ID . "_" . $ENTRADA_USER->getID());
        }
    } else {
        $evaluations_outstanding = $ENTRADA_CACHE->load("evaluations_outstanding_" . AUTH_APP_ID . "_" . $ENTRADA_USER->getID());
    }
    if ($evaluations_outstanding) {
        echo "<span class=\"badge badge-success\"><small>" . $evaluations_outstanding . "</small></span>";
    }
    ?>
                                    </div>
                                </div>
                            </div>
                            <div class="span2">
                                <a href="<?php 
 $content["evaluation_attempt"] .= "        <li><strong>Warning Unsaved Response:</strong><br />Your response to the question indicated by a yellow background was not automatically saved.</li>\n";
 $content["evaluation_attempt"] .= "    </ul>\n";
 $content["evaluation_attempt"] .= "</div>\n";
 if ($ERROR) {
     $content["evaluation_attempt"] .= display_error();
 }
 if ($NOTICE) {
     $content["evaluation_attempt"] .= display_notice();
 }
 $content["evaluation_attempt"] .= "<input type=\"hidden\" name=\"step\" value=\"2\" />\n";
 $query = "\tSELECT a.*, b.*, c.`questiontype_shortname`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `evaluation_form_questions` AS a\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN `evaluations_lu_questions` AS b\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tON a.`equestion_id` = b.`equestion_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN `evaluations_lu_questiontypes` AS c\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tON b.`questiontype_id` = c.`questiontype_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE a.`eform_id` = " . $db->qstr($evaluation_record["eform_id"]) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY a.`question_order` ASC";
 $questions = $db->GetAll($query);
 $total_questions = 0;
 if ($questions) {
     $total_questions = count($questions);
     $content["evaluation_attempt"] .= Models_Evaluation::getMobileQuestionAnswerControls($questions, $PROCESSED["eform_id"], $eprogress_id);
 } else {
     $ERROR++;
     $ERRORSTR[] = "There are no questions currently available for this evaluation. This problem has been reported to a system administrator; please try again later.";
     application_log("error", "Unable to locate any questions for evaluation [" . $evaluation_record["evaluation_id"] . "]. Database said: " . $db->ErrorMsg());
 }
 $content["evaluation_attempt"] .= "<div style=\"border-top: 2px #CCCCCC solid; margin-top: 10px; padding-top: 10px\">\n";
 $content["evaluation_attempt"] .= "    <input type=\"button\" id=\"evaluation-submit\" value=\"Submit Evaluation\" />\n";
 $content["evaluation_attempt"] .= "</div>\n";
 $content["evaluation_attempt"] .= "<div class=\"clear\"></div>\n";
 $content["evaluation_attempt"] .= "</form>\n";
 $content["evaluation_attempt"] .= "<script type=\"text/javascript\">\n";
 $content["evaluation_attempt"] .= "function loadPreceptors(event_id) {\n";
 $content["evaluation_attempt"] .= "    var preceptor_proxy_id = 0;\n";
 $content["evaluation_attempt"] .= "    if (\$('preceptor_proxy_id') && \$('preceptor_proxy_id').selectedIndex > 0) {\n";
 $content["evaluation_attempt"] .= "        preceptor_proxy_id = \$('preceptor_proxy_id').options[\$('preceptor_proxy_id').selectedIndex].value;\n";