public function WPCB_register_meta_box_cb() { global $item; $item = new EAL_ItemMC(); $item->load(); parent::WPCB_register_meta_box_cb(); }
public static function save($post_id, $post) { if ($_POST["post_type"] != "itemmc") { return; } $item = new EAL_ItemMC(); $item->init($post_id, $post); $item->save2DB(); }
public static function load_items_callback() { // global $wpdb; // this is how you get access to the database $items = array(); $itemids = get_user_meta(get_current_user_id(), 'itembasket', true); if ($itemids == null) { $itemids = array(); } foreach ($itemids as $item_id) { $post = get_post($item_id); if ($post == null) { continue; } $row = array('ID' => $item_id); if ($post->post_type == 'itemsc') { $item = new EAL_ItemSC(); } if ($post->post_type == 'itemmc') { $item = new EAL_ItemMC(); } $row['terms'] = array(); foreach (wp_get_post_terms($item_id, 'topic') as $term) { $termhier = array($term->name); $parentId = $term->parent; while ($parentId > 0) { $parentTerm = get_term($parentId, 'topic'); $termhier = array_merge(array($parentTerm->name), $termhier); $parentId = $parentTerm->parent; } $row['terms'] = array_merge($row['terms'], array($termhier)); } $item->loadById($item_id); $row['type'] = $item->type; $row['dim'] = ''; $row['level'] = 0; foreach (array('FW', 'PW', 'KW') as $dim) { if ($item->level[$dim] > 0) { $row['dim'] = $dim; $row['level'] = $item->level[$dim]; } } $row['points'] = $item->getPoints(); array_push($items, $row); } $whatever = intval($_POST['whatever']); $whatever += 10; wp_send_json($items); // echo $whatever; // wp_die(); // this is required to terminate immediately and return a proper response }
function prepare_items() { $this->process_bulk_action(); $columns = $this->get_columns(); $hidden = array(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array($columns, $hidden, $sortable); // usort( $this->example_data, array( &$this, 'usort_reorder' ) ); // $this->items = $this->example_data; $this->items = array(); $itemids = get_user_meta(get_current_user_id(), 'itembasket', true); if ($itemids == null) { $itemids = array(); } foreach ($itemids as $item_id) { $post = get_post($item_id); if ($post == null) { continue; } $row = array('ID' => $item_id); if ($post->post_type == 'itemsc') { $item = new EAL_ItemSC(); $row['type'] = 'Single Choice'; } if ($post->post_type == 'itemmc') { $item = new EAL_ItemMC(); $row['type'] = 'Mutliple Choice'; } $item->loadById($item_id); $row['title'] = $item->title; $row['FW'] = $item->level['FW'] > 0 ? EAL_Item::$level_label[$item->level['FW'] - 1] : ''; $row['KW'] = $item->level['KW'] > 0 ? EAL_Item::$level_label[$item->level['KW'] - 1] : ''; $row['PW'] = $item->level['PW'] > 0 ? EAL_Item::$level_label[$item->level['PW'] - 1] : ''; $row['points'] = $item->getPoints(); array_push($this->items, $row); } }
public static function loadAllItemsFromBasket() { // load all items from basket $items = array(); $itemids = RoleTaxonomy::getCurrentBasket(); // get_user_meta(get_current_user_id(), 'itembasket', true); if ($itemids == null) { $itemids = array(); } $itemids_new = array(); foreach ($itemids as $item_id) { $post = get_post($item_id); if ($post == null) { continue; } $item = null; if ($post->post_type == 'itemsc') { $item = new EAL_ItemSC(); } if ($post->post_type == 'itemmc') { $item = new EAL_ItemMC(); } if ($item == null) { continue; } $item->loadById($item_id); if (RoleTaxonomy::getCurrentRoleDomain()["name"] != "" && $item->domain != RoleTaxonomy::getCurrentRoleDomain()["name"]) { continue; } array_push($items, $item); array_push($itemids_new, $item_id); } RoleTaxonomy::setCurrentBasket($itemids_new); // update_user_meta (get_current_user_id(), 'itembasket', $itemids_new); return $items; }
* * @package WordPress * @subpackage Twenty_Sixteen * @since Twenty Sixteen 1.0 */ // include ('../includes/class.EAL_ItemMC.php'); get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php the_post(); global $post; $learnout = new EAL_ItemMC(); $learnout->load(); ?> <h1><?php echo $post->post_title; ?> </h1> <div><?php echo $learnout->description; ?> </div> <div style='background-color:F2F6FF; margin-top:2em; padding:1em;'> <?php
private function createQTI($itemids) { $dom = DOMDocument::loadXML('<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE questestinterop SYSTEM "ims_qtiasiv1p2p1.dtd"> <questestinterop></questestinterop> '); foreach ($itemids as $item_id) { $post = get_post($item_id); if ($post == null) { continue; } if ($post->post_type == 'itemsc') { $item = new EAL_ItemSC(); $item_data = array("questiontype" => "SINGLE CHOICE QUESTION", "ident" => "MCSR", "rcardinality" => "Single"); } if ($post->post_type == 'itemmc') { $item = new EAL_ItemMC(); $item_data = array("questiontype" => "MULTIPLE CHOICE QUESTION", "ident" => "MCMR", "rcardinality" => "Multiple"); } $item->loadById($item_id); $xml_IT = $dom->createElement("item"); $xml_IT->setAttribute("ident", "il_0_qst_{$item_id}"); $xml_IT->setAttribute("title", $item->title); $xml_IT->setAttribute("maxattempts", 1); $xml_IT->appendChild($dom->createElement("qticomment", "[EALID:{$item_id}]")); $xml_IT->appendChild($dom->createElement("duration", "P0Y0M0DT0H1M0S")); /* QTI Metadata*/ $xml_QM = $dom->createElement("qtimetadata"); $meta = array("ILIAS_VERSION" => "5.0.8 2015-11-24", "QUESTIONTYPE" => $item_data["questiontype"], "AUTHOR" => get_the_author_meta('login', get_post_field('post_author', $post->ID)), "additional_cont_edit_mode" => "default", "externalId" => "il_0_qst_{$item_id}", "ealid" => $item_id, "thumb_size" => "", "feedback_setting" => 1); foreach ($meta as $key => $value) { $x = $dom->createElement("qtimetadatafield"); $x->appendChild($dom->createElement("fieldlabel", $key)); $x->appendChild($dom->createElement("fieldentry", $value)); $xml_QM->appendChild($x); } $xml_IM = $dom->createElement("itemmetadata"); $xml_IM->appendChild($xml_QM); $xml_IT->appendChild($xml_IM); /* Presentation */ $xml_PR = $dom->createElement("presentation"); $xml_PR->setAttribute("label", $item->title); $xml_FL = $dom->createElement("flow"); $xml_FL->appendChild(EXP_Ilias::createMaterialElement($dom, "text/html", $item->description . "<hr/>" . $item->question)); $xml_RL = $dom->createElement("response_lid"); $xml_RL->setAttribute("ident", $item_data["ident"]); $xml_RL->setAttribute("rcardinality", $item_data["rcardinality"]); $xml_RC = $dom->createElement("render_choice"); $xml_RC->setAttribute("shuffle", "Yes"); foreach ($item->answers as $number => $answer) { $xml_LAB = $dom->createElement("response_label"); $xml_LAB->setAttribute("ident", $number); $xml_LAB->appendChild(EXP_Ilias::createMaterialElement($dom, "text/plain", $answer["answer"])); $xml_RC->appendChild($xml_LAB); } $xml_RL->appendChild($xml_RC); $xml_FL->appendChild($xml_RL); $xml_PR->appendChild($xml_FL); $xml_IT->appendChild($xml_PR); $xml_RP = $dom->createElement("resprocessing"); $xml_OC = $dom->createElement("outcomes"); $xml_DV = $dom->createElement("decvar"); $xml_OC->appendChild($xml_DV); $xml_RP->appendChild($xml_OC); foreach ($item->answers as $number => $answer) { foreach (array(1, 0) as $checked) { $xml_RC = $dom->createElement("respcondition"); $xml_RC->setAttribute("continue", "Yes"); $xml_CV = $dom->createElement("conditionvar"); $xml_NO = $dom->createElement("not"); $xml_VE = $dom->createElement("varequal", $number); $xml_VE->setAttribute("respident", $item_data["ident"]); if ($checked == 1) { $xml_CV->appendChild($xml_VE); } else { $xml_NO->appendChild($xml_VE); $xml_CV->appendChild($xml_NO); } $xml_RC->appendChild($xml_CV); // if ($item->type == "itemsc") array_push ($item->answers, array ("answer" => $v["text"], "points" => $v["positive"])); // if ($item->type == "itemmc") array_push ($item->answers, array ("answer" => $v["text"], "positive" => $v["positive"], "negative" => $v["negative"])); if ($item->type == "itemsc") { $xml_SV = $dom->createElement("setvar", $checked == 1 ? $answer['points'] : 0); } if ($item->type == "itemmc") { $xml_SV = $dom->createElement("setvar", $checked == 1 ? $answer['positive'] : $answer['negative']); } $xml_SV->setAttribute("action", "Add"); $xml_RC->appendChild($xml_SV); $xml_RP->appendChild($xml_RC); } } $xml_IT->appendChild($xml_RP); $dom->documentElement->appendChild($xml_IT); } return $dom; }