<center> <form action='$scriptname?action=editlo&id={$item_id}' method='post'> <table> <tr> <td valign='top'> <li><label>Name: </label> <input type='hidden' value='{$item_id}' name='txtid' /> <input type='text' value=\"$row[name]\" size='50' name='txtname' /></li> <li><label>Description:</label><br /> <textarea cols='60' name='txtdesc'>$row[description]</textarea></li> </td> <tr> <td valign='top'> "; //get learning outcomes tree of the current learning outcomes and display it $tree = get_lo_subtree($item_id); $lo_output.="<ul class='mktree' id='lotree'>".display_lo_tree($tree)."</ul>"; $popupURL = "popup.php?action=new_lo_item&root_id=$item_id"; $lo_output.=" <center> <input type='button' value='Add item' onclick=\"window.open('$popupURL', 'Add new learning outcomes item', 'width=400, height=200'); return false;\"/> <input type='submit' value='Cancel' /> <input type='submit' value='Save'/> </form> <input type='button' value='Generate survey' onclick=\"location.href='admin.php?action=gen_raw_survey&loid=$item_id'\" />"; $hashID = hashLOID($item_id);
$loid = returnglobal('loid'); //print_r($loid); if(isset($loid)) { if (isset($saved) && $saved == "true") { //insert new question! $loid_list = returnglobal('loid_list'); $loid_list = explode("~", $loid_list); foreach($loid_list as $item) { $loid = $item; $question = returnglobal("txtQuestion_".$item); $questiontype = returnglobal("slQuestionType_".$item); $parent_id = ""; } } else { $lo_tree = get_lo_subtree($loid); //print_r($lo_tree); //$qt = GetAllQuestionType(); $qt = getqtypelist(); $lo_id_list = array(); $html = genRawQuestionOnInitialize($lo_tree, $qt, $lo_id_list); //print_r($qt); //print_r($lo_id_list); $rs_output .= $html; $rs_output .= "<input name='loid' type='hidden' value='$loid' />"; $lo_id_list = implode("~", $lo_id_list); $rs_output .= "<input name='loid_list' type='hidden' value='$lo_id_list' />";
function get_lo_subtree($item_id=-1, $level=1) { $query = "select * from ". db_table_name("cdio3_learningoutcomes"). "where parent_id='".db_quote($item_id)."' and status=1 order by ord ASC"; $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg()); $r = ""; if ($result->RecordCount() > 0) { $counter = 0; while($row = $result->FetchRow()) { $r[$counter]['id'] = $row['id']; $r[$counter]['parent_id'] = $row['parent_id']; $r[$counter]['name'] = $row['name']; $r[$counter]['description'] = $row['description']; $r[$counter]['ord'] = $row['ord']; $r[$counter]['status'] = $row['status']; $r[$counter]['level'] = $level; $r[$counter]['sub'] = get_lo_subtree($row['id'], $level+1); $counter+=1; } } return $r; }
function genNewLOItemForm($root_id) { $tree = get_lo_subtree($root_id); $html = ''; $html .= "<form method=POST action=\"popup.php?action=new_lo_item&saved=true\" />"; $html .= "<input type='hidden' name='root_id' value='$root_id' />"; $html .= "Parent item: <select name='slParent'><option value='$root_id'>Root</option>".genLOItemSelectOption($tree)."</select><br />"; $html .= "Order: ".getLOItemIndex($root_id).".<input type='text' name='txtOrder' /><br />"; $html .= "Name: <input type='text' name='txtName' /><br />"; $html .= "Description: <br /> <textarea name='txtDesc' ></textarea><br />"; $html .= "<input type='submit' value='Add' />"; $html .= "<input type='button' value='Close' onclick=\"window.close(); return false;\" />"; return $html; }