Ejemplo n.º 1
0
 * @version 3.0
 * @copyright Copyright 2006 Queen's University, MEdTech Unit
 *
 * $Id: calendars.php 1103 2010-04-05 15:20:37Z simpson $
*/
@set_time_limit(0);
@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";
require_once "Entrada/icalendar/class.ical.inc.php";
$tmp_org_id = $_GET["org"];
$PROCESSED["org_id"] = clean_input($tmp_org_id, "int");
if ($PROCESSED["org_id"]) {
    $cohorts = groups_get_active_cohorts($PROCESSED["org_id"]);
    foreach ($cohorts as $cohort) {
        $query = "\n\t\t\t\t\tSELECT a.*, c.`proxy_id`, CONCAT_WS(' ', d.`firstname`, d.`lastname`) AS `fullname`, d.`email`\n\t\t\t\t\tFROM `events` AS a\n\t\t\t\t\tLEFT JOIN `event_audience` AS b\n\t\t\t\t\tON b.`event_id` = a.`event_id`\n\t\t\t\t\tLEFT JOIN `event_contacts` AS c\n\t\t\t\t\tON c.`event_id` = a.`event_id`\n\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_data` AS d\n\t\t\t\t\tON d.`id` = c.`proxy_id`\n\t\t\t\t\tWHERE b.`audience_type` = 'cohort'\n\t\t\t\t\tAND b.`audience_value` = " . $db->qstr($cohort["group_id"]) . "\n\t\t\t\t\tAND (c.`contact_order` IS NULL OR c.`contact_order` = '0')\n\t\t\t\t\tORDER BY a.`event_start` ASC";
        $results = $db->GetAll($query);
        if ($results) {
            $ical = new iCal("-//" . html_encode($_SERVER["HTTP_HOST"]) . "//iCal" . ($cohort["group_name"] ? html_encode($cohort["group_name"]) : "") . " Learning Events Calendar MIMEDIR//EN", 1, ENTRADA_ABSOLUTE . "/calendars/", $cohort ? clean_input($cohort["group_name"], "numeric") : "all_cohorts");
            // (ProgrammID, Method (1 = Publish | 0 = Request), Download Directory)
            foreach ($results as $result) {
                $ical->addEvent(array($result["fullname"] != "" ? $result["fullname"] : "", $result["email"] ? $result["email"] : ""), (int) $result["event_start"], (int) $result["event_finish"], $result["event_location"], 1, array("Phase " . $result["event_phase"], html_encode($cohort["group_name"])), strip_tags($result["event_message"]), strip_tags($result["event_title"]), 1, array(), 5, 0, 0, 0, array(), 1, "", 0, 1, str_replace("http://", "https://", ENTRADA_URL) . "/events?id=" . (int) $result["event_id"], "en", md5((int) $result["event_id"]));
            }
            $ical->writeFile();
        }
    }
} else {
    echo "When running the calender generation cron job an invalid org_id was provided, or no org_id was provided.";
}
Ejemplo n.º 2
0
				<div style="text-align: right">
					<a href="javascript: showYear(1)">1st Year</a> |
					<a href="javascript: showYear(2)">2nd Year</a> |
					<a href="javascript: showYear(3)">3rd Year</a> |
					<a href="javascript: showYear(4)">4th Year</a>
				</div>

				<?php 
                if ($SEARCH_CLASS) {
                    echo "<div style=\"border: 1px #CCCCCC solid; margin-bottom: 1px\">\n";
                    echo "\t<img src=\"" . ENTRADA_URL . "/images/dynamic/14/314/5/90/" . rawurlencode(groups_get_name($SEARCH_CLASS)) . "/jpg\" width=\"25\" height=\"325\" align=\"left\" alt=\"" . html_encode(groups_get_name($SEARCH_CLASS)) . "\" title=\"" . html_encode(groups_get_name($SEARCH_CLASS)) . "\" />\n";
                    echo "\t<div id=\"search-timeline-" . preg_replace("/[^0-9]/", "", groups_get_name($SEARCH_CLASS)) . "\" style=\"height: 325px\"></div>\n";
                    echo "</div>\n";
                } else {
                    $cohorts_list = groups_get_active_cohorts($ENTRADA_USER->getActiveOrganisation());
                    foreach ($cohorts_list as $cohort) {
                        echo "<div style=\"border: 1px #CCCCCC solid; margin-bottom: 1px\">\n";
                        echo "\t<img src=\"" . ENTRADA_URL . "/images/dynamic/14/314/5/90/" . rawurlencode($cohort["group_name"]) . "/jpg\" width=\"25\" height=\"325\" align=\"left\" alt=\"" . html_encode($cohort["group_name"]) . "\" title=\"" . html_encode($cohort["group_name"]) . "\" />\n";
                        echo "\t<div id=\"search-timeline-" . preg_replace("/[^0-9]/", "", $cohort["group_name"]) . "\" style=\"height: 325px\"></div>\n";
                        echo "</div>\n";
                    }
                }
                new_sidebar_item("Class Result Totals", "<div id=\"class-result-totals\"></div>", "result-totals", "open");
                break;
            case "standard":
            default:
                if ($SEARCH_MODE != "timeline" && $TOTAL_PAGES > 1) {
                    echo "<form action=\"" . ENTRADA_RELATIVE . "/curriculum/searchbeta\" method=\"get\" id=\"pageSelector\">\n";
                    echo "<div style=\"margin-top: 10px; margin-bottom: 5px; text-align: right; white-space: nowrap\">\n";
                    echo "<span style=\"width: 20px; vertical-align: middle; margin-right: 3px; text-align: left\">\n";
Ejemplo n.º 3
0
    public static function getTargetControls($target_data, $options_for = "", $form_id = 0)
    {
        global $ENTRADA_USER, $ENTRADA_ACL, $db, $use_ajax;
        if ($form_id) {
            $query = "\tSELECT b.*\n\t\t\t\t\t\tFROM `evaluation_forms` AS a\n\t\t\t\t\t\tLEFT JOIN `evaluations_lu_targets` AS b\n\t\t\t\t\t\tON b.`target_id` = a.`target_id`\n\t\t\t\t\t\tWHERE a.`form_active` = '1'\n\t\t\t\t\t\tAND b.`target_active` = '1'\n\t\t\t\t\t\tAND a.`eform_id` = " . $db->qstr($form_id);
            $target_details = $db->GetRow($query);
            if ($target_details) {
                switch ($target_details["target_shortname"]) {
                    case "course":
                        $courses_list = array();
                        $query = "\tSELECT `course_id`, `organisation_id`, `course_code`, `course_name`\n\t\t\t\t\t\t\t\t\tFROM `courses`\n\t\t\t\t\t\t\t\t\tWHERE `organisation_id`=" . $ENTRADA_USER->getActiveOrganisation() . "\n\t\t\t\t\t\t\t\t\tAND `course_active` = '1'\n\t\t\t\t\t\t\t\t\tORDER BY `course_code` ASC, `course_name` ASC";
                        $results = $db->GetAll($query);
                        if ($results) {
                            foreach ($results as $result) {
                                if ($ENTRADA_ACL->amIAllowed(new CourseResource($result["course_id"], $result["organisation_id"]), "read")) {
                                    $courses_list[$result["course_id"]] = $result["course_code"] . " - " . $result["course_name"];
                                }
                            }
                        }
                        ?>
						<tr>
							<td></td>
							<td style="vertical-align: top">
								<label for="PickList" class="form-required">Select Courses</label>
								<div class="content-small"><strong>Hint:</strong> Select the course or courses you would like to have evaluated.</div>
							</td>
							<td style="vertical-align: top">
								<select class="multi-picklist" id="PickList" name="course_ids[]" multiple="multiple" size="4" style="width: 100%; margin-bottom: 5px">
								<?php 
                        if (is_array($target_data["evaluation_targets"]) && !empty($target_data["evaluation_targets"])) {
                            foreach ($target_data["evaluation_targets"] as $target) {
                                echo "<option value=\"" . (int) $target["target_value"] . "\">" . html_encode($courses_list[$target["target_value"]]) . "</option>\n";
                            }
                        }
                        ?>
								</select>
								<div style="float: left; display: inline">
									<input type="button" id="courses_list_state_btn" class="btn" value="Show List" onclick="toggle_list('courses_list')" />
								</div>
								<div style="float: right; display: inline">
									<input type="button" id="courses_list_remove_btn" class="btn btn-danger" onclick="delIt()" value="Remove" />
									<input type="button" id="courses_list_add_btn" class="btn btn-success" onclick="addIt()" style="display: none" value="Add" />
								</div>
								<div id="courses_list" style="clear: both; padding-top: 3px; display: none">
									<h2>Course List</h2>
									<select class="multi-picklist" id="SelectList" name="other_courses_list" multiple="multiple" size="15" style="width: 100%">
									<?php 
                        foreach ($courses_list as $course_id => $course_name) {
                            if (!in_array($course_id, $target_data["evaluation_targets"])) {
                                echo "<option value=\"" . (int) $course_id . "\">" . html_encode($course_name) . "</option>\n";
                            }
                        }
                        ?>
									</select>
								</div>
							</td>
						</tr>
						<?php 
                        break;
                    case "teacher":
                        $teachers_list = array();
                        $query = "\tSELECT a.`id` AS `proxy_id`, CONCAT_WS(', ', a.`lastname`, a.`firstname`) AS `fullname`\n\t\t\t\t\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\t\t\t\t\tON b.`user_id` = a.`id`\n\t\t\t\t\t\t\t\t\tLEFT JOIN `event_contacts` AS c\n\t\t\t\t\t\t\t\t\tON c.`proxy_id` = a.`id`\n\t\t\t\t\t\t\t\t\tLEFT JOIN `events` AS d\n\t\t\t\t\t\t\t\t\tON d.`event_id` = c.`event_id`\n\t\t\t\t\t\t\t\t\tWHERE b.`app_id` = " . $db->qstr(AUTH_APP_ID) . "\n\t\t\t\t\t\t\t\t\tAND (b.`group` = 'faculty' OR\n\t\t\t\t\t\t\t\t\t\t(b.`group` = 'resident' AND b.`role` = 'lecturer')\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tAND d.`event_finish` >= " . $db->qstr(strtotime("-12 months")) . "\n\t\t\t\t\t\t\t\t\tGROUP BY a.`id`\n\t\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) {
                                $teachers_list[$result["proxy_id"]] = $result["fullname"];
                            }
                        }
                        $target_ids = array();
                        foreach ($target_data["evaluation_targets"] as $temp_target) {
                            if ($temp_target["target_type"] == "proxy_id") {
                                $target_ids[] = $temp_target["target_value"];
                            }
                        }
                        ?>
						<tr>
							<td></td>
							<td style="vertical-align: top">
								<label for="PickList" class="form-required">Select Teachers</label>
								<div class="content-small"><strong>Hint:</strong> Select the teacher or teachers you would like to have evaluated.</div>
							</td>
							<td style="vertical-align: top">
								<select class="multi-picklist" id="PickList" name="teacher_ids[]" multiple="multiple" size="4" style="width: 100%; margin-bottom: 5px">
								<?php 
                        if (is_array($target_data["evaluation_targets"]) && !empty($target_data["evaluation_targets"])) {
                            foreach ($teachers_list as $proxy_id => $teacher_name) {
                                if (in_array($proxy_id, $target_ids)) {
                                    echo "<option value=\"" . (int) $proxy_id . "\">" . html_encode($teacher_name) . "</option>\n";
                                }
                            }
                        }
                        ?>
								</select>
								<div style="float: left; display: inline">
									<input type="button" id="teachers_list_state_btn" class="btn" value="Show List" onclick="toggle_list('teachers_list')" />
								</div>
								<div style="float: right; display: inline">
									<input type="button" id="teachers_list_remove_btn" class="btn btn-danger" onclick="delIt()" value="Remove" />
									<input type="button" id="teachers_list_add_btn" class="btn btn-success" onclick="addIt()" style="display: none" value="Add" />
								</div>
								<div id="teachers_list" style="clear: both; padding-top: 3px; display: none">
									<h2>Course List</h2>
									<select class="multi-picklist" id="SelectList" name="other_teachers_list" multiple="multiple" size="15" style="width: 100%">
									<?php 
                        foreach ($teachers_list as $proxy_id => $teacher_name) {
                            if (!isset($target_data["evaluation_targets"]) || !is_array($target_data["evaluation_targets"]) || !in_array($proxy_id, $target_data["evaluation_targets"])) {
                                echo "<option value=\"" . (int) $proxy_id . "\">" . html_encode($teacher_name) . "</option>\n";
                            }
                        }
                        ?>
									</select>
								</div>
							</td>
						</tr>
						<?php 
                        break;
                    case "resident":
                        $residents_list = array();
                        $query = "\tSELECT a.`id` AS `proxy_id`, CONCAT_WS(', ', a.`lastname`, a.`firstname`) AS `fullname`\n\t\t\t\t\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\t\t\t\t\tON b.`user_id` = a.`id`\n\t\t\t\t\t\t\t\t\tWHERE b.`app_id` = " . $db->qstr(AUTH_APP_ID) . "\n\t\t\t\t\t\t\t\t\tAND b.`group` = 'student'\n\t\t\t\t\t\t\t\t\tGROUP BY a.`id`\n\t\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) {
                                $residents_list[$result["proxy_id"]] = $result["fullname"];
                            }
                        }
                        $target_ids = array();
                        if (isset($target_data["evaluation_targets"]) && @count($target_data["evaluation_targets"])) {
                            foreach ($target_data["evaluation_targets"] as $temp_target) {
                                if ($temp_target["target_type"] == "proxy_id") {
                                    $target_ids[] = $temp_target["target_value"];
                                }
                            }
                        }
                        ?>
						<tr>
							<td></td>
							<td style="vertical-align: top">
								<label for="PickList" class="form-required">Select Learners</label>
								<div class="content-small"><strong>Hint:</strong> Select the learner(s) you would like to have evaluated.</div>
							</td>
							<td style="vertical-align: top">
								<select class="multi-picklist" id="PickList" name="resident_ids[]" multiple="multiple" size="4" style="width: 100%; margin-bottom: 5px">
								<?php 
                        if (is_array($target_data["evaluation_targets"]) && !empty($target_data["evaluation_targets"])) {
                            foreach ($residents_list as $proxy_id => $resident_name) {
                                if (in_array($proxy_id, $target_ids)) {
                                    echo "<option value=\"" . (int) $proxy_id . "\">" . html_encode($resident_name) . "</option>\n";
                                }
                            }
                        }
                        ?>
								</select>
								<div style="float: left; display: inline">
									<input type="button" id="residents_list_state_btn" class="btn" value="Show List" onclick="toggle_list('residents_list')" />
								</div>
								<div style="float: right; display: inline">
									<input type="button" id="residents_list_remove_btn" class="btn btn-danger" onclick="delIt()" value="Remove" />
									<input type="button" id="residents_list_add_btn" class="btn btn-success" onclick="addIt()" style="display: none" value="Add" />
								</div>
								<div id="residents_list" style="clear: both; padding-top: 3px; display: none">
									<h2>Learner List</h2>
									<select class="multi-picklist" id="SelectList" name="other_residents_list" multiple="multiple" size="15" style="width: 100%">
									<?php 
                        foreach ($residents_list as $proxy_id => $resident_name) {
                            if (!isset($target_data["evaluation_targets"]) || !is_array($target_data["evaluation_targets"]) || !in_array($proxy_id, $target_data["evaluation_targets"])) {
                                echo "<option value=\"" . (int) $proxy_id . "\">" . html_encode($resident_name) . "</option>\n";
                            }
                        }
                        ?>
									</select>
								</div>
							</td>
						</tr>
						<?php 
                        break;
                    case "student":
                    case "peer":
                        $query = "SELECT * FROM `course_groups` AS a\n\t\t\t\t\t\t\t\t\tJOIN `courses` AS b\n\t\t\t\t\t\t\t\t\tON a.`course_id` = b.`course_id`\n\t\t\t\t\t\t\t\t\tORDER BY b.`course_name`,\n\t\t\t\t\t\t\t\t\t\tLENGTH(a.`group_name`),\n\t\t\t\t\t\t\t\t\t\ta.`group_name` ASC";
                        $temp_course_groups = $db->GetAll($query);
                        $course_groups = array();
                        if ($temp_course_groups) {
                            foreach ($temp_course_groups as $temp_course_group) {
                                $course_groups[$temp_course_group["cgroup_id"]] = $temp_course_group;
                            }
                        }
                        if (!isset($target_data["associated_cgroup_ids"]) && !isset($target_data["associated_cohort_ids"]) && !isset($target_data["associated_proxy_ids"])) {
                            if (isset($target_data["evaluation_targets"]) && is_array($target_data["evaluation_targets"])) {
                                foreach ($target_data["evaluation_targets"] as $target) {
                                    if ($target["target_type"] == "cgroup_id") {
                                        $target_data["associated_cgroup_ids"][] = $target["target_value"];
                                    } elseif ($target["target_type"] == "cohort") {
                                        $target_data["associated_cohort_ids"][] = $target["target_value"];
                                    } elseif ($target["target_type"] == "proxy_id") {
                                        $target_data["associated_proxy_ids"][] = $target["target_value"];
                                    }
                                }
                            }
                        }
                        unset($temp_course_groups);
                        ?>
						<tr>
							<td>&nbsp;</td>
							<td style="vertical-align: top"><label for="faculty_name" class="form-nrequired">Evaluation Targets</label></td>
							<td>
								<table>
									<tbody>
										<tr>
											<td style="vertical-align: top"><input type="radio" name="target_type" id="target_type_custom" value="custom" onclick="selectEvaluationTargetOption('custom')" style="vertical-align: middle" checked="checked" /></td>
											<td colspan="2" style="padding-bottom: 15px">
												<label for="target_type_custom" class="radio-group-title">Custom Evaluation Targets</label>
												<div class="content-small">This evaluation is intended for a custom selection of evaluation targets.</div>

												<div id="evaluation_target_type_custom_options" style="position: relative; margin-top: 10px;">
													<select id="target_type" onchange="showMultiSelect();" style="width: 275px;">
														<option value="">-- Select an target type --</option>
														<option value="cohorts">Cohorts of learners</option>
															<?php 
                        if ($course_groups) {
                            ?>
															<option value="course_groups">Course specific small groups</option>
															<?php 
                        }
                        ?>
														<option value="students">Individual learners</option>
													</select>

													<span id="options_loading" style="display:none; vertical-align: middle"><img src="<?php 
                        echo ENTRADA_RELATIVE;
                        ?>
/images/indicator.gif" width="16" height="16" alt="Please Wait" title="" style="vertical-align: middle" /> Loading ... </span>
													<span id="options_container"></span>
													<?php 
                        /**
                         * Compiles the list of groups from groups table (known as Cohorts).
                         */
                        $COHORT_LIST = array();
                        $results = groups_get_active_cohorts($ENTRADA_USER->getActiveOrganisation());
                        if ($results) {
                            foreach ($results as $result) {
                                $COHORT_LIST[$result["group_id"]] = $result;
                            }
                        }
                        $GROUP_LIST = $course_groups;
                        /**
                         * Compiles the list of students.
                         */
                        $STUDENT_LIST = array();
                        $query = "\tSELECT a.`id` AS `proxy_id`, b.`role`, CONCAT_WS(' ', a.`firstname`, a.`lastname`) AS `fullname`, a.`organisation_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tON a.`id` = b.`user_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE b.`app_id` = " . $db->qstr(AUTH_APP_ID) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b.`account_active` = 'true'\n\t\t\t\t\t\t\t\t\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\t\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\t\t\t\t\t\t\t\t\tAND b.`group` = 'student'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND a.`grad_year` >= '" . (date("Y") - (date("m") < 7 ? 2 : 1)) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY a.`grad_year` ASC, a.`lastname` ASC, a.`firstname` ASC";
                        $results = $db->GetAll($query);
                        if ($results) {
                            foreach ($results as $result) {
                                $STUDENT_LIST[$result["proxy_id"]] = array("proxy_id" => $result["proxy_id"], "fullname" => $result["fullname"], "organisation_id" => $result["organisation_id"]);
                            }
                        }
                        $target_data["form_id"] = $form_id;
                        if (!isset($target_data["associated_cohort_ids"]) && !isset($target_data["associated_cgroup_ids"]) && !isset($target_data["associated_proxy_ids"]) && isset($target_data["evaluation_id"])) {
                            $query = "SELECT * FROM `evaluation_targets` WHERE `evaluation_id` = " . $db->qstr($target_data["evaluation_id"]);
                            $results = $db->GetAll($query);
                            if ($results) {
                                $target_data["target_type"] = "custom";
                                foreach ($results as $result) {
                                    switch ($result["target_type"]) {
                                        case "cohort":
                                            $target_data["associated_cohort_ids"][] = (int) $result["target_value"];
                                            break;
                                        case "cgroup_id":
                                            $target_data["associated_cgroup_ids"][] = (int) $result["target_value"];
                                            break;
                                        case "proxy_id":
                                            $target_data["associated_proxy_ids"][] = (int) $result["target_value"];
                                            break;
                                    }
                                }
                            }
                        }
                        $cohort_ids_string = "";
                        $cgroup_ids_string = "";
                        $student_ids_string = "";
                        if (isset($target_data["associated_course_ids"]) && $target_data["associated_course_ids"]) {
                            $course_target_included = true;
                        } else {
                            $course_target_included = false;
                        }
                        if (isset($target_data["associated_cohort_ids"]) && is_array($target_data["associated_cohort_ids"])) {
                            foreach ($target_data["associated_cohort_ids"] as $group_id) {
                                if ($cohort_ids_string) {
                                    $cohort_ids_string .= ",group_" . $group_id;
                                } else {
                                    $cohort_ids_string = "group_" . $group_id;
                                }
                            }
                        }
                        if (isset($target_data["associated_cgroup_ids"]) && is_array($target_data["associated_cgroup_ids"])) {
                            foreach ($target_data["associated_cgroup_ids"] as $group_id) {
                                if ($cgroup_ids_string) {
                                    $cgroup_ids_string .= ",cgroup_" . $group_id;
                                } else {
                                    $cgroup_ids_string = "cgroup_" . $group_id;
                                }
                            }
                        }
                        if (isset($target_data["associated_proxy_ids"]) && is_array($target_data["associated_proxy_ids"])) {
                            foreach ($target_data["associated_proxy_ids"] as $proxy_id) {
                                if ($student_ids_string) {
                                    $student_ids_string .= ",student_" . $proxy_id;
                                } else {
                                    $student_ids_string = "student_" . $proxy_id;
                                }
                            }
                        }
                        ?>
													<input type="hidden" id="evaluation_target_cohorts" name="evaluation_target_cohorts" value="<?php 
                        echo $cohort_ids_string;
                        ?>
" />
													<input type="hidden" id="evaluation_target_course_groups" name="evaluation_target_course_groups" value="<?php 
                        echo $cgroup_ids_string;
                        ?>
" />
													<input type="hidden" id="evaluation_target_students" name="evaluation_target_students" value="<?php 
                        echo $student_ids_string;
                        ?>
" />
													<input type="hidden" id="evaluation_target_course" name="evaluation_target_course" value="<?php 
                        echo $course_target_included ? "1" : "0";
                        ?>
" />

													<ul class="menu multiselect" id="target_list" style="margin-top: 5px">
													<?php 
                        if (isset($target_data["associated_cohort_ids"]) && count($target_data["associated_cohort_ids"])) {
                            foreach ($target_data["associated_cohort_ids"] as $group) {
                                if (array_key_exists($group, $COHORT_LIST) && is_array($COHORT_LIST[$group])) {
                                    ?>
																<li class="group" id="target_group_<?php 
                                    echo $COHORT_LIST[$group]["group_id"];
                                    ?>
" style="cursor: move;"><?php 
                                    echo $COHORT_LIST[$group]["group_name"];
                                    ?>
<img src="<?php 
                                    echo ENTRADA_URL;
                                    ?>
/images/action-delete.gif" onclick="removeTarget('group_<?php 
                                    echo $COHORT_LIST[$group]["group_id"];
                                    ?>
', 'cohorts');" class="list-cancel-image" /></li>
																<?php 
                                }
                            }
                        }
                        if (isset($target_data["associated_cgroup_ids"]) && count($target_data["associated_cgroup_ids"])) {
                            foreach ($target_data["associated_cgroup_ids"] as $group) {
                                if (array_key_exists($group, $GROUP_LIST) && is_array($GROUP_LIST[$group])) {
                                    ?>
																<li class="group" id="target_cgroup_<?php 
                                    echo $GROUP_LIST[$group]["cgroup_id"];
                                    ?>
" style="cursor: move;"><?php 
                                    echo $GROUP_LIST[$group]["group_name"] . " - " . $GROUP_LIST[$group]["course_code"];
                                    ?>
<img src="<?php 
                                    echo ENTRADA_URL;
                                    ?>
/images/action-delete.gif" onclick="removeTarget('cgroup_<?php 
                                    echo $GROUP_LIST[$group]["cgroup_id"];
                                    ?>
', 'course_groups');" class="list-cancel-image" /></li>
																<?php 
                                }
                            }
                        }
                        if (isset($target_data["associated_proxy_ids"]) && count($target_data["associated_proxy_ids"])) {
                            foreach ($target_data["associated_proxy_ids"] as $student) {
                                if (array_key_exists($student, $STUDENT_LIST) && is_array($STUDENT_LIST[$student])) {
                                    ?>
																<li class="user" id="target_student_<?php 
                                    echo $STUDENT_LIST[$student]["proxy_id"];
                                    ?>
" style="cursor: move;"><?php 
                                    echo $STUDENT_LIST[$student]["fullname"];
                                    ?>
<img src="<?php 
                                    echo ENTRADA_URL;
                                    ?>
/images/action-delete.gif" onclick="removeTarget('student_<?php 
                                    echo $STUDENT_LIST[$student]["proxy_id"];
                                    ?>
', 'students');" class="list-cancel-image" /></li>
																<?php 
                                }
                            }
                        }
                        ?>
													</ul>
												</div>
											</td>
										</tr>
									</tbody>
								</table>
							</td>
						</tr>
						<?php 
                        if ($target_details["target_shortname"] == "peer") {
                            ?>
							<tr>
								<td colspan="2">&nbsp;</td>
								<td>
									<?php 
                            echo display_notice("When creating peer assessments, learners will be able to assess any others within the same cohort, course group, or custom list of students, depending on which evaluation targets you include. <br /><br />Additionally, they will not be able to view results of evaluations done on themselves until they have filled out all of the required evaluations available to them, or the evaluation period ends, whichever comes first.");
                            ?>
								</td>
							</tr>
							<?php 
                        }
                        break;
                    case "rotation_core":
                        $target_data["form_id"] = $form_id;
                        if (!isset($target_data["associated_rotation_ids"])) {
                            foreach ($target_data["evaluation_targets"] as $target) {
                                if ($target["target_type"] == "rotation_id") {
                                    $target_data["associated_rotation_ids"][] = $target["target_value"];
                                }
                            }
                        }
                        ?>
						<tr>
							<td>&nbsp;</td>
							<td style="vertical-align: top"><label for="faculty_name" class="form-nrequired">Evaluation Targets</label></td>
							<td>
								<table>
									<tbody>
										<tr>
											<td style="vertical-align: top"><input type="radio" name="target_type" id="target_type_rotations" value="rotations" onclick="selectEvaluationTargetOption('rotations')" style="vertical-align: middle"  checked="checked" /></td>
											<td colspan="2" style="padding-bottom: 15px">
												<label for="target_type_rotations" class="radio-group-title">Each Service in the selected Core Rotation</label>
												<div class="content-small">This evaluation is intended for all events associated with a custom selection of Core Rotations.</div>
												<?php 
                        $ROTATION_LIST = array();
                        $rotations[0] = array("text" => "All Core Rotations", "value" => "all", "category" => true);
                        $query = "SELECT * FROM `" . CLERKSHIP_DATABASE . "`.`global_lu_rotations`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `rotation_id` != " . $db->qstr(MAX_ROTATION);
                        $rotation_results = $db->CacheGetAll(LONG_CACHE_TIMEOUT, $query);
                        if ($rotation_results) {
                            foreach ($rotation_results as $rotation) {
                                $ROTATION_LIST[$rotation["rotation_id"]] = $rotation;
                                if (isset($target_data["associated_rotation_ids"]) && is_array($target_data["associated_rotation_ids"]) && in_array($rotation["rotation_id"], $target_data["associated_rotation_ids"])) {
                                    $checked = "checked=\"checked\"";
                                } else {
                                    $checked = "";
                                }
                                $rotations[0]["options"][] = array("text" => $rotation["rotation_title"], "class" => "cat_enabled", "value" => "rotation_" . $rotation["rotation_id"], "checked" => $checked);
                            }
                            echo lp_multiple_select_inline("rotations", $rotations, array("title" => "Select Core Rotations:", "hidden" => false, "class" => "select_multiple_area_container", "category_check_all" => true, "submit" => false));
                        } else {
                            echo display_notice("There are no core rotations available.");
                        }
                        if (isset($target_data["associated_rotation_ids"]) && is_array($target_data["associated_rotation_ids"])) {
                            foreach ($target_data["associated_rotation_ids"] as $rotation_id) {
                                if ($rotation_ids_string) {
                                    $rotation_ids_string .= ",rotation_" . $rotation_id;
                                } else {
                                    $rotation_ids_string = "rotation_" . $rotation_id;
                                }
                            }
                        }
                        ?>
												<input type="hidden" id="evaluation_target_rotations" name="evaluation_target_rotations" value="<?php 
                        echo $rotation_ids_string;
                        ?>
" />
												<ul class="menu multiselect" id="target_list" style="margin-top: 5px;">
													<?php 
                        if (is_array($target_data["associated_rotation_ids"]) && count($target_data["associated_rotation_ids"])) {
                            foreach ($target_data["associated_rotation_ids"] as $rotation) {
                                if (array_key_exists($rotation, $ROTATION_LIST) && is_array($ROTATION_LIST[$rotation])) {
                                    ?>
																<li class="group" id="target_rotation_<?php 
                                    echo $ROTATION_LIST[$rotation]["rotation_id"];
                                    ?>
" style="cursor: move;"><?php 
                                    echo $ROTATION_LIST[$rotation]["rotation_title"];
                                    ?>
<img src="<?php 
                                    echo ENTRADA_URL;
                                    ?>
/images/action-delete.gif" onclick="removeTarget('rotation_<?php 
                                    echo $ROTATION_LIST[$rotation]["rotation_id"];
                                    ?>
', 'rotations');" class="list-cancel-image" style="position: relative; float: right;" /></li>
																<?php 
                                }
                            }
                        }
                        ?>
												</ul>
											</td>
										</tr>
									</tbody>
								</table>
							</td>
						</tr>
						<tr>
							<td colspan="2">&nbsp;</td>
							<td>
								<?php 
                        echo display_notice("When creating core rotation evaluations, the list of <strong>Core Rotations</strong>, <strong>Evaluators</strong>, the <strong>Evaluation Start</strong>, and the <strong>Evaluation Finish</strong> determine which electives will be targeted for evaluation. <br /><br />Each of the services in one of selected <strong>Core Rotations</strong> which ends between the <strong>Evaluation Start</strong> and the <strong>Evaluation Finish</strong> for learners in the <strong>Evaluators</strong> list will require/allow an evaluation to be completed on it.");
                        ?>
							</td>
						</tr>
						<?php 
                        break;
                    case "rotation_elective":
                        ?>
						<tr>
							<td colspan="2">&nbsp;</td>
							<td>
								<?php 
                        echo display_notice("When creating clerkship elective evaluations, the list of <strong>Evaluators</strong>, the <strong>Evaluation Start</strong>, and the <strong>Evaluation Finish</strong> determine which electives will be targeted for evaluation. <br /><br />Each elective which ends between the <strong>Evaluation Start</strong> and the <strong>Evaluation Finish</strong> for learners in the <strong>Evaluators</strong> list will require/allow an evaluation to be completed on it.");
                        ?>
							</td>
						</tr>
						<?php 
                        break;
                    case "preceptor":
                        $target_data["form_id"] = $form_id;
                        if (!isset($target_data["associated_rotation_ids"])) {
                            foreach ($target_data["evaluation_targets"] as $target) {
                                if ($target["target_type"] == "rotation_id") {
                                    $target_data["associated_rotation_ids"][] = $target["target_value"];
                                }
                            }
                        }
                        ?>
						<tr>
							<td>&nbsp;</td>
							<td style="vertical-align: top"><label for="faculty_name" class="form-nrequired">Evaluation Targets</label></td>
							<td>
								<table>
									<tbody>
										<tr>
											<td style="vertical-align: top"><input type="hidden" name="target_subtype" value="preceptor" /><input type="radio" name="target_type" id="target_type_rotations" value="rotations" onclick="selectEvaluationTargetOption('rotations')" style="vertical-align: middle"  checked="checked" /></td>
											<td colspan="2" style="padding-bottom: 15px">
												<label for="target_type_rotations" class="radio-group-title">Each Service in the selected Clerkship Rotation</label>
												<div class="content-small">This evaluation is intended for all events associated with a custom selection of Clerkship Rotations.</div>
												<?php 
                        $ROTATION_LIST = array();
                        $rotations[0] = array("text" => "All Clerkship Rotations", "value" => "all", "category" => true);
                        $query = "\tSELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . CLERKSHIP_DATABASE . "`.`global_lu_rotations`";
                        $rotation_results = $db->CacheGetAll(LONG_CACHE_TIMEOUT, $query);
                        if ($rotation_results) {
                            foreach ($rotation_results as $rotation) {
                                $ROTATION_LIST[$rotation["rotation_id"]] = $rotation;
                                if (isset($target_data["associated_rotation_ids"]) && is_array($target_data["associated_rotation_ids"]) && in_array($rotation["rotation_id"], $target_data["associated_rotation_ids"])) {
                                    $checked = "checked=\"checked\"";
                                } else {
                                    $checked = "";
                                }
                                $rotations[0]["options"][] = array("text" => $rotation["rotation_title"], "value" => "rotation_" . $rotation["rotation_id"], "class" => "cat_enabled", "checked" => $checked);
                            }
                            echo lp_multiple_select_inline("rotations", $rotations, array("title" => "Select Clerkship Rotations:", "hidden" => false, "class" => "select_multiple_area_container", "category_check_all" => true, "submit" => false));
                        } else {
                            echo display_notice("There are no clerkship rotations available.");
                        }
                        if (isset($target_data["associated_rotation_ids"]) && is_array($target_data["associated_rotation_ids"])) {
                            foreach ($target_data["associated_rotation_ids"] as $rotation_id) {
                                if ($rotation_ids_string) {
                                    $rotation_ids_string .= ",rotation_" . $rotation_id;
                                } else {
                                    $rotation_ids_string = "rotation_" . $rotation_id;
                                }
                            }
                        }
                        ?>
												<input type="hidden" id="evaluation_target_rotations" name="evaluation_target_rotations" value="<?php 
                        echo $rotation_ids_string;
                        ?>
" />
												<ul class="menu multiselect" id="target_list" style="margin-top: 5px;">
													<?php 
                        if (is_array($target_data["associated_rotation_ids"]) && count($target_data["associated_rotation_ids"])) {
                            foreach ($target_data["associated_rotation_ids"] as $rotation) {
                                if (array_key_exists($rotation, $ROTATION_LIST) && is_array($ROTATION_LIST[$rotation])) {
                                    ?>
																<li class="group" id="target_rotation_<?php 
                                    echo $ROTATION_LIST[$rotation]["rotation_id"];
                                    ?>
" style="cursor: move;"><?php 
                                    echo $ROTATION_LIST[$rotation]["rotation_title"];
                                    ?>
<img src="<?php 
                                    echo ENTRADA_URL;
                                    ?>
/images/action-delete.gif" onclick="removeTarget('rotation_<?php 
                                    echo $ROTATION_LIST[$rotation]["rotation_id"];
                                    ?>
', 'rotations');" class="list-cancel-image" style="position: relative; float: right;" /></li>
																<?php 
                                }
                            }
                        }
                        ?>
												</ul>
											</td>
										</tr>
									</tbody>
								</table>
							</td>
						</tr>
						<tr>
							<td colspan="2">&nbsp;</td>
							<td>
								<?php 
                        echo display_notice("When creating clerkship preceptor evaluations, the list of <strong>Rotations</strong>, <strong>Evaluators</strong>, the <strong>Evaluation Start</strong>, and the <strong>Evaluation Finish</strong> determine which electives will be targeted for evaluation. <br /><br />Each preceptor for services in one of the selected <strong>Rotations</strong> which ends between the <strong>Evaluation Start</strong> and the <strong>Evaluation Finish</strong> for learners in the <strong>Evaluators</strong> list will require/allow an evaluation to be completed on it.");
                        ?>
							</td>
						</tr>
						<?php 
                        break;
                    case "self":
                        ?>
						<tr>
							<td colspan="2">&nbsp;</td>
							<td>
								<?php 
                        echo display_notice("When creating self evaluations, the list of evaluators also acts as the target, as learners can only evaluate themselves.");
                        ?>
							</td>
						</tr>
						<?php 
                        break;
                    default:
                        ?>
						<tr>
							<td colspan="2">&nbsp;</td>
							<td>
								<?php 
                        echo display_notice("The target that you have selected is not currently available.");
                        ?>
							</td>
						</tr>
						<?php 
                        application_log("error", "Unaccounted for target_shortname [" . $target_details["target_shortname"] . "] encountered. An update to api-targets.inc.php is required.");
                        break;
                }
                if ($target_details["target_shortname"] != "peer" && $target_details["target_shortname"] != "student" && $target_details["target_shortname"] != "resident") {
                    ?>
					<tr>
						<td colspan="3">&nbsp;</td>
					</tr>
					<tr>
						<td></td>
						<td style="vertical-align: top">
							<label for="PickList" class="form-required">Select Students</label>
							<div class="content-small"><strong>Hint:</strong> Select the student or students you would like to evaluate the teachers above.</div>
						</td>
						<td style="vertical-align: top">
							<table style="width: 100%" cellspacing="0" cellpadding="0">
								<colgroup>
									<col style="width: 4%" />
									<col style="width: 96%" />
								</colgroup>
								<tbody>
									<tr>
										<td style="vertical-align: top"><input<?php 
                    echo isset($target_data["evaluation_evaluators"][0]["evaluator_type"]) && $target_data["evaluation_evaluators"][0]["evaluator_type"] == "cohort" ? " checked=\"checked\"" : "";
                    ?>
 type="radio" name="target_group_type" id="target_group_type_cohort" value="cohort" onclick="selectTargetGroupOption(this.value)" style="vertical-align: middle" /></td>
										<td style="padding-bottom: 15px">
											<label for="target_group_type_cohort" class="radio-group-title">Entire class must complete this evaluation</label>
											<div class="content-small">This evaluation must be completed by everyone in the selected class.</div>
										</td>
									</tr>
									<tr class="target_group cohort_target">
										<td></td>
										<td style="vertical-align: middle" class="content-small">
											<label for="cohort" class="form-required">All students in</label>
											<select id="cohort" name="cohort" style="width: 203px; vertical-align: middle">
												<?php 
                    $active_cohorts = groups_get_active_cohorts($ENTRADA_USER->getActiveOrganisation());
                    if (isset($active_cohorts) && !empty($active_cohorts)) {
                        foreach ($active_cohorts as $cohort) {
                            echo "<option value=\"" . $cohort["group_id"] . "\"" . ($target_data["evaluation_evaluators"][0]["evaluator_type"] == "cohort" && $target_data["evaluation_evaluators"][0]["evaluator_value"] == $cohort["group_id"] ? " selected=\"selected\"" : "") . ">" . html_encode($cohort["group_name"]) . "</option>\n";
                        }
                    }
                    ?>
											</select>
										</td>
									</tr>
									<tr>
										<td colspan="2">&nbsp;</td>
									</tr>
									<tr>
										<td style="vertical-align: top"><input type="radio" name="target_group_type" id="target_group_type_percentage" value="percentage" onclick="selectTargetGroupOption(this.value)" style="vertical-align: middle" /></td>
										<td style="padding-bottom: 15px">
											<label for="target_group_type_percentage" class="radio-group-title">Percentage of class must complete this evaluation</label>
											<div class="content-small">This evaluation must be completed by certain percentage of students in the selected class.</div>
										</td>
									</tr>
									<tr class="target_group percentage_target">
										<td>&nbsp;</td>
										<td style="vertical-align: middle" class="content-small">
											<input type="text" class="percentage" id="percentage_percent" name="percentage_percent" style="width: 30px; vertical-align: middle" maxlength="3" value="100" /> <label for="percentage_cohort" class="form-required">of the</label>
											<select id="percentage_cohort" name="percentage_cohort" style="width: 203px; vertical-align: middle">
											<?php 
                    $active_cohorts = groups_get_active_cohorts($ENTRADA_USER->getActiveOrganisation());
                    if (isset($active_cohorts) && !empty($active_cohorts)) {
                        foreach ($active_cohorts as $cohort) {
                            echo "<option value=\"" . $cohort["group_id"] . "\">" . html_encode($cohort["group_name"]) . "</option>\n";
                        }
                    }
                    ?>
											</select>
										</td>
									</tr>
									<tr>
										<td colspan="2">&nbsp;</td>
									</tr>
									<tr>
										<td style="vertical-align: top"><input<?php 
                    echo isset($target_data["evaluation_evaluators"][0]["evaluator_type"]) && $target_data["evaluation_evaluators"][0]["evaluator_type"] == "cgroup_id" ? " checked=\"checked\"" : "";
                    ?>
 type="radio" name="target_group_type" id="target_group_type_cgroup_id" value="cgroup_id" onclick="selectTargetGroupOption(this.value)" style="vertical-align: middle" /></td>
										<td style="padding-bottom: 15px">
											<label for="target_group_type_cgroup_id" class="radio-group-title">Selected course groups must complete this evaluation</label>
											<div class="content-small">This evaluation must be completed by everyone in the selected course groups.</div>
										</td>
									</tr>
									<tr class="target_group cgroup_id_target">
										<td></td>
										<td style="vertical-align: middle" class="content-small">
											<label for="cgroup_ids" class="form-required">All students in</label>
											<select multiple="multiple" id="cgroup_ids" name="cgroup_ids[]" style="width: 450px; height: 200px; vertical-align: top;"><?php 
                    $query = "SELECT * FROM `course_groups` AS a\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN `courses` AS b\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tON a.`course_id` = b.`course_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE b.`course_active` = 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND a.`active` = 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b.`organisation_id` = " . $ENTRADA_USER->getActiveOrganisation() . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY b.`course_name`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLENGTH(a.`group_name`),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ta.`group_name` ASC";
                    $temp_course_groups = $db->GetAll($query);
                    $course_groups = array();
                    if ($temp_course_groups) {
                        foreach ($temp_course_groups as $temp_course_group) {
                            $course_groups[$temp_course_group["cgroup_id"]] = $temp_course_group;
                        }
                    }
                    $evaluator_cgroup_ids = array();
                    foreach ($target_data["evaluation_evaluators"] as $evaluator) {
                        if ($evaluator["evaluator_type"] == "cgroup_id") {
                            $evaluator_cgroup_ids[] = $evaluator["evaluator_value"];
                        }
                    }
                    if (isset($course_groups) && !empty($course_groups)) {
                        $last_course_name = false;
                        foreach ($course_groups as $course_group) {
                            if ($course_group["course_name"] && $last_course_name != $course_group["course_name"]) {
                                if ($last_course_name) {
                                    echo "</optgroup>\n";
                                }
                                $last_course_name = $course_group["course_name"];
                                echo "<optgroup label=\"" . $course_group["course_name"] . ($course_group["course_code"] ? " - " . $course_group["course_code"] : "") . "\">\n";
                            }
                            echo "<option value=\"" . $course_group["cgroup_id"] . "\"" . (in_array($course_group["cgroup_id"], $evaluator_cgroup_ids) ? " selected=\"selected\"" : "") . ">" . html_encode($course_group["group_name"]) . "</option>\n";
                        }
                        if ($last_course_name) {
                            echo "</optgroup>\n";
                        }
                    }
                    ?>
											</select>
										</td>
									</tr>
									<tr>
										<td colspan="2">&nbsp;</td>
									</tr>
									<tr >
										<td style="vertical-align: top"><input<?php 
                    echo isset($target_data["evaluation_evaluators"][0]["evaluator_type"]) && $target_data["evaluation_evaluators"][0]["evaluator_type"] == "proxy_id" ? " checked=\"checked\"" : "";
                    ?>
 type="radio" name="target_group_type" id="target_group_type_proxy_id" value="proxy_id" onclick="selectTargetGroupOption(this.value)" style="vertical-align: middle" /></td>
										<td style="padding-bottom: 15px">
											<label for="target_group_type_proxy_id" class="radio-group-title">Selected students must complete this evaluation</label>
											<div class="content-small">This evaluation must be completed only by the selected individuals.</div>
										</td>
									</tr>
									<tr class="target_group proxy_id_target">
										<td>&nbsp;</td>
										<td style="vertical-align: middle" class="content-small">
											<label for="student_name" class="form-required">Student Name</label>

											<input type="text" id="student_name" name="fullname" size="30" autocomplete="off" style="width: 203px; vertical-align: middle" />
											<div class="autocomplete" id="student_name_auto_complete"></div>

											<input type="hidden" id="associated_student" name="associated_student" />
											<input type="button" class="btn btn-small" id="add_associated_student" value="Add" style="vertical-align: middle" />
											<span class="content-small" style="margin-left: 3px; padding-top: 5px"><strong>e.g.</strong> <?php 
                    echo html_encode($_SESSION["details"]["lastname"] . ", " . $_SESSION["details"]["firstname"]);
                    ?>
</span>
											<ul id="student_list" class="menu" style="margin-top: 15px">
												<?php 
                    if ($target_data["evaluation_evaluators"][0]["evaluator_type"] == "proxy_id" && is_array($target_data["evaluation_evaluators"]) && !empty($target_data["evaluation_evaluators"])) {
                        foreach ($target_data["evaluation_evaluators"] as $evaluator) {
                            $proxy_id = (int) $evaluator["evaluator_value"];
                            ?>
														<li class="community" id="student_<?php 
                            echo $proxy_id;
                            ?>
" style="cursor: move;"><?php 
                            echo get_account_data("fullname", $proxy_id);
                            ?>
<img src="<?php 
                            echo ENTRADA_URL;
                            ?>
/images/action-delete.gif" onclick="student_list.removeItem('<?php 
                            echo $proxy_id;
                            ?>
');" class="list-cancel-image" /></li>
														<?php 
                        }
                    }
                    ?>
											</ul>
											<input type="hidden" id="student_ref" name="student_ref" value="" />
											<input type="hidden" id="student_id" name="student_id" value="" />
										</td>
									</tr>
								</tbody>
							</table>
							<div id="scripts-on-open" style="display: none;">
								$('submittable_notice').update('&nbsp;');
								selectTargetGroupOption('<?php 
                    echo isset($target_data["evaluation_evaluators"][0]["evaluator_type"]) ? $target_data["evaluation_evaluators"][0]["evaluator_type"] : 'cohort';
                    ?>
');
								student_list = new AutoCompleteList({ type: 'student', url: '<?php 
                    echo ENTRADA_RELATIVE;
                    ?>
/api/personnel.api.php?type=student', remove_image: '<?php 
                    echo ENTRADA_RELATIVE;
                    ?>
/images/action-delete.gif' });
								<?php 
                    if (in_array($target_details["target_shortname"], array("course", "rotation_core", "preceptor"))) {
                        ?>
									$('directors_select').show();
									$('pcoordinators_select').show();
									$('tutors_select').hide();
									<?php 
                    } elseif ($target_details["target_shortname"] == "self") {
                        ?>
									$('tutors_select').show();
									$('directors_select').hide();
									$('pcoordinators_select').hide();
									<?php 
                    }
                    ?>
							</div>
						</td>
					</tr>
					<?php 
                } elseif ($target_details["target_shortname"] == "peer") {
                    ?>
					<tr>
						<td colspan="3">
							<div id="scripts-on-open" style="display: none;">
								$('tutors_select').show();
								$('submittable_notice').update('<div class="display-notice"><ul><li>If you set the Min or Max Submittable for a Peer Evaluation to 0, the value will default to the number of targets available to evaluate.</li></ul></div>');
							</div>
						</td>
					</tr
					<?php 
                } elseif ($target_details["target_shortname"] == "student" || $target_details["target_shortname"] == "resident") {
                    ?>
					<tr>
						<td colspan="3">&nbsp;</td>
					</tr
					<tr>
						<td></td>
						<td style="vertical-align: top"><label for="evalfaculty_name" class="form-required">Faculty Evaluators</label></td>
						<td>
							<input type="hidden" name="target_group_type" id="target_group_type_faculty" value="faculty" style="vertical-align: middle" />
							<div id="scripts-on-open" style="display: none;">
								faculty_list = new AutoCompleteList(
									{
										type: 'evalfaculty',
										url: '<?php 
                    echo ENTRADA_RELATIVE;
                    ?>
/api/personnel.api.php?type=evalfaculty',
										remove_image: '<?php 
                    echo ENTRADA_RELATIVE;
                    ?>
/images/action-delete.gif'
									});
								$('tutors_select').show();
								$('directors_select').hide();
								$('pcoordinators_select').hide();
								$('submittable_notice').update('&nbsp;');
							</div>
							<input type="text" id="evalfaculty_name" name="fullname" size="30" autocomplete="off" style="width: 203px; vertical-align: middle" />
							<div class="autocomplete" id="evalfaculty_name_auto_complete"></div>
							<input type="hidden" id="associated_evalfaculty" name="associated_evalfaculty" />
							<input type="button" class="btn btn-small" id="add_associated_evalfaculty" value="Add" style="vertical-align: middle" />
							<span class="content-small">(<strong>Example:</strong> <?php 
                    echo html_encode($_SESSION["details"]["lastname"] . ", " . $_SESSION["details"]["firstname"]);
                    ?>
)</span>
							<ul id="evalfaculty_list" class="menu" style="margin-top: 15px">
								<?php 
                    if ($target_data["evaluation_evaluators"][0]["evaluator_type"] == "proxy_id" && is_array($target_data["evaluation_evaluators"]) && !empty($target_data["evaluation_evaluators"])) {
                        foreach ($target_data["evaluation_evaluators"] as $evaluator) {
                            $proxy_id = (int) $evaluator["evaluator_value"];
                            ?>
										<li class="community" id="evalfaculty_<?php 
                            echo $proxy_id;
                            ?>
" style="cursor: move;"><?php 
                            echo get_account_data("fullname", $proxy_id);
                            ?>
<img src="<?php 
                            echo ENTRADA_URL;
                            ?>
/images/action-delete.gif" onclick="faculty_list.removeItem('<?php 
                            echo $proxy_id;
                            ?>
');" class="list-cancel-image" /></li>
										<?php 
                        }
                    }
                    ?>
							</ul>
							<input type="hidden" id="evalfaculty_ref" name="evalfaculty_ref" value="" />
							<input type="hidden" id="evalfaculty_id" name="evalfaculty_id" value="" />
						</td>
					</tr>
					<?php 
                }
            }
        } else {
            $organisation[$ENTRADA_USER->getActiveOrganisation()] = array("text" => fetch_organisation_title($ENTRADA_USER->getActiveOrganisation()), "value" => "organisation_" . $ENTRADA_USER->getActiveOrganisation(), "category" => true);
            switch ($options_for) {
                case "cohorts":
                    // Classes
                    /**
                     * Cohorts.
                     */
                    if (isset($target_data["evaluation_target_cohorts"])) {
                        $associated_targets = explode(',', $target_data["evaluation_target_cohorts"]);
                        if (isset($associated_targets) && is_array($associated_targets) && count($associated_targets)) {
                            foreach ($associated_targets as $target_id) {
                                if (strpos($target_id, "group") !== false) {
                                    if ($group_id = clean_input(preg_replace("/[a-z_]/", "", $target_id), array("trim", "int"))) {
                                        $query = "\tSELECT * FROM `groups`\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `group_id` = " . $db->qstr($group_id) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND `group_active` = 1";
                                        $result = $db->GetRow($query);
                                        if ($result) {
                                            $target_data["associated_cohort_ids"][] = $group_id;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    $groups = $organisation;
                    $groups_results = groups_get_active_cohorts($ENTRADA_USER->getActiveOrganisation());
                    if ($groups_results) {
                        foreach ($groups_results as $group) {
                            if (isset($target_data["associated_cohort_ids"]) && is_array($target_data["associated_cohort_ids"]) && in_array($group["group_id"], $target_data["associated_cohort_ids"])) {
                                $checked = "checked=\"checked\"";
                            } else {
                                $checked = "";
                            }
                            $groups[$ENTRADA_USER->getActiveOrganisation()]["options"][] = array("text" => $group["group_name"], "value" => "group_" . $group["group_id"], "checked" => $checked);
                        }
                        echo lp_multiple_select_popup("cohorts", $groups, array("title" => "Select Cohorts of Learners:", "submit_text" => "Close", "submit" => true));
                    } else {
                        echo display_notice("There are no cohorts of learners available.");
                    }
                    break;
                case "course_groups":
                    /**
                     * Course Groups
                     */
                    if (isset($target_data["evaluation_target_course_groups"])) {
                        $associated_targets = explode(',', $target_data["evaluation_target_course_groups"]);
                        if (isset($associated_targets) && is_array($associated_targets) && count($associated_targets)) {
                            foreach ($associated_targets as $target_id) {
                                if (strpos($target_id, "cgroup") !== false) {
                                    if ($cgroup_id = clean_input(preg_replace("/[a-z_]/", "", $target_id), array("trim", "int"))) {
                                        $query = "\tSELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `course_groups`\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `cgroup_id` = " . $db->qstr($cgroup_id) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND (`active` = '1')";
                                        $result = $db->GetRow($query);
                                        if ($result) {
                                            $target_data["associated_cgroup_ids"][] = $cgroup_id;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    $groups = $organisation;
                    $query = "SELECT a.*, b.`course_name`, b.`course_code` FROM `course_groups` AS a\n\t\t\t\t\t\t\t\tJOIN `courses` AS b\n\t\t\t\t\t\t\t\tON a.`course_id` = b.`course_id`\n\t\t\t\t\t\t\t\tWHERE b.`organisation_id` = " . $db->qstr($ENTRADA_USER->getActiveOrganisation()) . "\n\t\t\t\t\t\t\t\tORDER BY b.`course_name`,\n\t\t\t\t\t\t\t\t\tLENGTH(a.`group_name`),\n\t\t\t\t\t\t\t\t\ta.`group_name` ASC";
                    $groups_results = $db->CacheGetAll(LONG_CACHE_TIMEOUT, $query);
                    if ($groups_results) {
                        $last_course_category = "";
                        foreach ($groups_results as $group) {
                            if ($last_course_category != $group["course_name"]) {
                                $last_course_category = $group["course_name"];
                                $groups[$group["course_id"]] = array("text" => $group["course_name"], "value" => "course_" . $group["course_id"], "category" => true);
                            }
                            if (isset($target_data["associated_cgroup_ids"]) && is_array($target_data["associated_cgroup_ids"]) && in_array($group["cgroup_id"], $target_data["associated_cgroup_ids"])) {
                                $checked = "checked=\"checked\"";
                            } else {
                                $checked = "";
                            }
                            $groups[$group["course_id"]]["options"][] = array("text" => $group["group_name"] . ($group["course_code"] ? " - " . $group["course_code"] : ""), "value" => "cgroup_" . $group["cgroup_id"], "checked" => $checked);
                        }
                        echo lp_multiple_select_popup("course_groups", $groups, array("title" => "Select Course Specific Small Groups:", "submit_text" => "Close", "submit" => true));
                    } else {
                        //echo display_notice("There are no small groups in the course you have selected.");
                    }
                    break;
                case "students":
                    // Students
                    /**
                     * Learners
                     */
                    if (isset($target_data["evaluation_target_students"])) {
                        $associated_targets = explode(',', $target_data["evaluation_target_students"]);
                        if (isset($associated_targets) && is_array($associated_targets) && count($associated_targets)) {
                            foreach ($associated_targets as $target_id) {
                                if (strpos($target_id, "student") !== false) {
                                    if ($proxy_id = clean_input(preg_replace("/[a-z_]/", "", $target_id), array("trim", "int"))) {
                                        $query = "\tSELECT a.*\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\t\t\t\t\t\t\t\t\tON a.`id` = b.`user_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE a.`id` = " . $db->qstr($proxy_id) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b.`app_id` = " . $db->qstr(AUTH_APP_ID) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b.`account_active` = 'true'\n\t\t\t\t\t\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\t\t\t\t\t\tAND (b.`access_expires` = '0' OR b.`access_expires` > " . $db->qstr(time()) . ")";
                                        $result = $db->GetRow($query);
                                        if ($result) {
                                            $target_data["associated_proxy_ids"][] = $proxy_id;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    $students = $organisation;
                    $query = "\tSELECT a.`id` AS `proxy_id`, a.`organisation_id`, b.`role`, CONCAT_WS(', ', a.`lastname`, a.`firstname`) AS `fullname`\n\t\t\t\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\t\t\t\tJOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\t\t\t\tON a.`id` = b.`user_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 a.`organisation_id` = " . $db->qstr($ENTRADA_USER->getActiveOrganisation()) . "\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 b.`group` = 'student'\n\t\t\t\t\t\t\t\tAND a.`grad_year` >= " . $db->qstr(fetch_first_year() - 4) . ($ENTRADA_USER->getGroup() == "student" ? " AND a.`id` = " . $db->qstr($ENTRADA_USER->getID()) : "") . "\n\t\t\t\t\t\t\t\tGROUP BY a.`id`\n\t\t\t\t\t\t\t\tORDER BY a.`grad_year` DESC, a.`lastname` ASC, a.`firstname` ASC";
                    $student_results = $db->CacheGetAll(LONG_CACHE_TIMEOUT, $query);
                    if ($student_results) {
                        foreach ($student_results as $student) {
                            if (isset($target_data["associated_proxy_ids"]) && is_array($target_data["associated_proxy_ids"]) && in_array($student["proxy_id"], $target_data["associated_proxy_ids"])) {
                                $checked = "checked=\"checked\"";
                            } else {
                                $checked = "";
                            }
                            $students[$ENTRADA_USER->getActiveOrganisation()]["options"][] = array("text" => $student["fullname"], "value" => "student_" . $student["proxy_id"], "checked" => $checked);
                        }
                        echo lp_multiple_select_popup("students", $students, array("title" => "Select Individual Learners:", "submit_text" => "Close", "submit" => true));
                    } else {
                        echo display_notice("There are no students available.");
                    }
                    break;
                case "residents":
                    // Residents
                    if (isset($target_data["evaluation_target_residents"])) {
                        $associated_targets = explode(',', $target_data["evaluation_target_residents"]);
                        if (isset($associated_targets) && is_array($associated_targets) && count($associated_targets)) {
                            foreach ($associated_targets as $target_id) {
                                if (strpos($target_id, "resident") !== false) {
                                    if ($proxy_id = clean_input(preg_replace("/[a-z_]/", "", $target_id), array("trim", "int"))) {
                                        $query = "\tSELECT a.*\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\t\t\t\t\t\t\t\t\tON a.`id` = b.`user_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE a.`id` = " . $db->qstr($proxy_id) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b.`app_id` = " . $db->qstr(AUTH_APP_ID) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b.`account_active` = 'true'\n\t\t\t\t\t\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\t\t\t\t\t\tAND (b.`access_expires` = '0' OR b.`access_expires` > " . $db->qstr(time()) . ")";
                                        $result = $db->GetRow($query);
                                        if ($result) {
                                            $target_data["associated_proxy_ids"][] = $proxy_id;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    $residents = $organisation;
                    $query = "\tSELECT a.`id` AS `proxy_id`, a.`organisation_id`, b.`role`, CONCAT_WS(', ', a.`lastname`, a.`firstname`) AS `fullname`\n\t\t\t\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\t\t\t\tJOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\t\t\t\tON a.`id` = b.`user_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 a.`organisation_id` = " . $db->qstr($ENTRADA_USER->getActiveOrganisation()) . "\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 b.`group` = 'student'\n\t\t\t\t\t\t\t\tGROUP BY a.`id`\n\t\t\t\t\t\t\t\tORDER BY a.`grad_year` DESC, a.`lastname` ASC, a.`firstname` ASC";
                    $resident_results = $db->CacheGetAll(LONG_CACHE_TIMEOUT, $query);
                    if ($resident_results) {
                        foreach ($resident_results as $resident) {
                            if (isset($target_data["associated_proxy_ids"]) && is_array($target_data["associated_proxy_ids"]) && in_array($resident["proxy_id"], $target_data["associated_proxy_ids"])) {
                                $checked = "checked=\"checked\"";
                            } else {
                                $checked = "";
                            }
                            $residents[$ENTRADA_USER->getActiveOrganisation()]["options"][] = array("text" => $resident["fullname"], "value" => "resident_" . $g["proxy_id"], "checked" => $checked);
                        }
                        echo lp_multiple_select_popup("residents", $residents, array("title" => "Select Individual Learners:", "submit_text" => "Close", "submit" => true));
                    } else {
                        echo display_notice("There are no residents available.");
                    }
                    break;
                default:
                    application_log("notice", "Unknown evaluation target filter type [" . $options_for . "] provided to evaluation targets API.");
                    break;
            }
        }
    }