function event_objectives_in_list($objectives, $parent_id, $top_level_id, $edit_text = false, $parent_active = false, $importance = 1, $course = true, $top = true, $display_importance = "primary", $full_objective_list = false, $course_id = 0) { global $edit_ajax, $ENTRADA_USER; if (!$full_objective_list) { $full_objective_list = events_fetch_objectives_structure($parent_id, $objectives["used_ids"]); } $flat_objective_list = events_flatten_objectives($full_objective_list); $output = ""; $active = array("primary" => false, "secondary" => false, "tertiary" => false); if ($top) { if (!empty($objectives["primary_ids"])) { $active["primary"] = true; } elseif ($display_importance == "primary") { $display_importance == "secondary"; } if (!empty($objectives["secondary_ids"])) { $active["secondary"] = true; } elseif ($display_importance == "secondary") { $display_importance == "tertiary"; } if (!empty($objectives["tertiary_ids"])) { $active["tertiary"] = true; } $objectives = $objectives["objectives"]; } if (!is_array($edit_ajax)) { $edit_ajax = array(); } if (is_array($objectives) && ($total = count($objectives))) { $count = 0; if ($top) { $output = "\n<ul class=\"objective-list\" id=\"objective_" . $parent_id . "_list\"" . ($parent_id == $top_level_id ? " style=\"padding-left: 0; margin-top: 0\"" : "") . ">\n"; } $iterated = false; do { if ($iterated) { if ($display_importance == "primary" && $active["secondary"]) { $display_importance = "secondary"; } elseif (($display_importance == "secondary" || $display_importance == "primary") && $active["tertiary"]) { $display_importance = "tertiary"; } } if ($top) { $output .= "<h2" . ($iterated ? " class=\"collapsed\"" : "") . " title=\"" . ucwords($display_importance) . " Objectives\">" . ucwords($display_importance) . " Objectives</h2>\n"; $output .= "<div id=\"" . $display_importance . "-objectives\">\n"; } if ($flat_objective_list) { foreach ($flat_objective_list as $objective_id => $objective_activity) { $objective = $objectives[$objective_id]; $count++; if ($objective["parent"] == $parent_id && ($objective["objective_" . $display_importance . "_children"] || $objective[$display_importance] || $parent_active)) { $importance = $objective["primary"] ? 1 : ($objective["secondary"] ? 2 : ($objective["tertiary"] ? 3 : $importance)); if (($objective[$display_importance] || $parent_active) && count($objective["parent_ids"]) > 2) { $output .= "<li>\n"; if ($edit_text && !$course) { $output .= "<div id=\"objective_table_" . $objective_id . "\" class=\"content-small\" style=\"color: #000\">\n"; $output .= "\t<input type=\"checkbox\" name=\"checked_objectives[" . $objective_id . "]\" id=\"objective_checkbox_" . $objective_id . "\"" . ($course ? " disabled=\"true\" checked=\"checked\"" : " onclick=\"if (this.checked) { \$('objective_table_" . $objective_id . "_details').show(); \$('objective_text_" . $objective_id . "').focus(); } else { \$('objective_table_" . $objective_id . "_details').hide(); }\"" . ($objective["event_objective"] ? " checked=\"checked\"" : "")) . " style=\"float: left;\" value=\"1\" />\n"; $output .= "\t<div style=\"padding-left: 25px;\"><label for=\"objective_checkbox_" . $objective_id . "\">" . $objective["description"] . " <a class=\"external content-small\" href=\"" . ENTRADA_RELATIVE . "/courses/objectives?section=objective-details&oid=" . $objective_id . "\">" . $objective["name"] . "</a></label></div>\n"; $output .= "</div>\n"; $output .= "<div id=\"objective_table_" . $objective_id . "_details\" style=\"padding-left: 25px; margin-top: 5px" . ($objective["event_objective"] ? "" : "; display: none") . "\">\n"; $output .= "\t<label for=\"c_objective_" . $objective_id . "\" class=\"content-small\" id=\"objective_" . $objective_id . "_append\" style=\"vertical-align: middle;\">Provide your sessional free-text objective below as it relates to this curricular objective.</label>\n"; $output .= "\t<textarea name=\"objective_text[" . $objective_id . "]\" id=\"objective_text_" . $objective_id . "\" class=\"expandable\">" . (isset($objective["event_objective_details"]) ? html_encode($objective["event_objective_details"]) : "") . "</textarea>"; $output .= "</div>\n"; } elseif ($edit_text) { $edit_ajax[] = $objective_id; $output .= "<div id=\"objective_table_" . $objective_id . "\">\n"; $output .= "\t<label for=\"objective_checkbox_" . $objective_id . "\" class=\"heading\">" . $objective["name"] . "</label> ( <span id=\"edit_mode_" . $objective_id . "\" class=\"content-small\" style=\"cursor: pointer\">edit</span> )<span id=\"clear_objective_" . $objective_id . "\" style=\"margin-left: 10px;" . (isset($objective["objective_details"]) && $objective["objective_details"] ? "" : " display: none;") . "\">( <span id=\"revert_mode_" . $objective_id . "\" class=\"content-small\" onclick=\"new Ajax.Updater('objective_description_" . $objective_id . "', '" . ENTRADA_RELATIVE . "/api/objective-details.api.php', {parameters: { id: '" . $objective_id . "', cids: '" . $course_id . "', objective_details: '' }, onComplete: function() { jQuery('#clear_objective_" . $objective_id . "').hide(); }})\" style=\"cursor: pointer\">clear custom text</span> )</span>\n"; $output .= "\t<div class=\"content-small\" style=\"padding-left: 25px;\" id=\"objective_description_" . $objective_id . "\">" . (isset($objective["objective_details"]) && $objective["objective_details"] ? $objective["objective_details"] : $objective["description"]) . "</div>\n"; $output .= "</div>\n"; } else { $output .= "<input type=\"checkbox\" id=\"objective_checkbox_" . $objective_id . "\" name=\"course_objectives[" . $objective_id . "]\"" . (isset($objective["event_objective"]) && $objective["event_objective"] ? " checked=\"checked\"" : "") . " onclick=\"if (this.checked) { this.parentNode.addClassName('" . ($importance == 2 ? "secondary" : ($importance == 3 ? "tertiary" : "primary")) . "'); } else { this.parentNode.removeClassName('" . ($importance == 2 ? "secondary" : ($importance == 3 ? "tertiary" : "primary")) . "'); }\" style=\"float: left;\" value=\"1\" />\n"; $output .= "<label for=\"objective_checkbox_" . $objective_id . "\" class=\"heading\">" . $objective["name"] . "</label>\n"; $output .= "<div style=\"padding-left: 25px;\">\n"; $output .= $objective["description"] . "\n"; if (isset($objective["objective_details"]) && $objective["objective_details"]) { $output .= "<br /><br />\n"; $output .= "<em>" . $objective["objective_details"] . "</em>"; } $output .= "</div>\n"; } $output .= "</li>\n"; } else { $output .= event_objectives_in_list($objectives, $objective_id, $top_level_id, $edit_text, $objective[$display_importance] ? true : false, $importance, $course, false, $display_importance, $full_objective_list, $course_id); } } } } $iterated = true; if ($top) { $output .= "</div>\n"; } } while ($display_importance != "tertiary" && ($display_importance != "secondary" || $active["tertiary"]) && ($display_importance != "primary" || $active["secondary"] || $active["tertiary"]) && $top); if ($top) { $output .= "</ul>\n"; } } return $output; }
<?php } } ?> </ul> <?php } ?> <div class="clear_both"></div> <div id="objectives_list"> <h3>Curriculum Objectives</h3> <strong>The learner will be able to:</strong> <?php echo event_objectives_in_list($course_objectives, $top_level_id, $top_level_id, true, false, 1, true, true, "primary", false, $COURSE_ID); ?> </div> <div class="clearfix pull-right"> <input type="submit" value="Save" class="btn btn-primary" /> </div> </form> </div> <?php if (@is_array($edit_ajax) && @count($edit_ajax)) { echo "<script type=\"text/javascript\">\n"; foreach ($edit_ajax as $objective_id) { echo "var editor_" . $objective_id . " = new Ajax.InPlaceEditor('objective_description_" . $objective_id . "', '" . ENTRADA_RELATIVE . "/api/objective-details.api.php', { rows: 7, cols: 62, okText: \"Save Changes\", cancelText: \"Cancel Changes\", externalControl: \"edit_mode_" . $objective_id . "\", submitOnBlur: \"true\", callback: function(form, value) { jQuery('#clear_objective_" . $objective_id . "').toggle((value.length !== 0 && value.trim())); return 'id=" . $objective_id . "&cids=" . $COURSE_ID . "&objective_details='+escape(value) } });\n"; } echo "</script>\n"; }