Пример #1
0
 public function init($args = array())
 {
     $this->type = "itembasket";
     $this->label = "Item Basket";
     $this->menu_pos = 0;
     parent::init();
 }
Пример #2
0
 public function WPCB_register_meta_box_cb()
 {
     global $item;
     $item = new EAL_ItemSC();
     $item->load();
     parent::WPCB_register_meta_box_cb();
 }
Пример #3
0
    public static function HTML_itemlist(array $items, string $dir, string $name)
    {
        ?>
		<script type="text/javascript">

		jQuery(document).ready(function($) {
			$('.previewButton').click(function(){
				console.log ($(this).parent().parent().siblings("div").children(":last-child"));
				$(this).parent().parent().siblings("div").children(":last-child").css({display:"none"});
				$(this).parent().parent().children(":last-child").toggle();
			});


			$('.importAll').change(function(){
				$(this).siblings("div").find(".importCheckbox").prop("checked",this.checked);
				noofchecked = $(this).parent().parent().parent().find(".importCheckbox:checked").length;
				$("#importButton").text("Import " + noofchecked + " Item(s)");
			});

			
			$('.importCheckbox').change(function(){
				noofchecked = $(this).parent().parent().parent().find(".importCheckbox:checked").length;
				$(this).parent().parent().parent().find(".importAll").prop("checked", noofchecked == ($(this).parent().parent().parent().find(".importCheckbox").length));
				$("#importButton").text("Import " + noofchecked + " Item(s)");
			});
			
		});
		</script>
<?php 
        printf("<div class='wrap'><h1>Select Items & Test Results for Import</h1>");
        printf("<form enctype='multipart/form-data' action='admin.php?page=import-items' method='post'>");
        printf("<input type='hidden' name='file_dir' value='%s'>", $dir);
        printf("<input type='hidden' name='file_name' value='%s'>", $name);
        printf("<div style='margin-top:2em'>");
        printf("<input class='importAll' type='checkbox' value='1' checked>&nbsp;");
        printf("<button id='importButton' type='submit' name='action' value='import'>Import %s Items</button>", count($items));
        foreach ($items as $ident => $item) {
            // 			if ($item->type == "itemsc") $symbol = "<span class='dashicons dashicons-marker'></span>";
            // 			if ($item->type == "itemmc") $symbol = "<span class='dashicons dashicons-forms'></span>";
            printf("\t\t\t\t\t\r\n\t\t\t\t<div style='margin-top:2em;'>\r\n\t\t\t\t\t<hr/>\r\n\t\t\t\t\t<div style='margin-top:0em;'>\r\n\t\t\t\t\t\t<input class='importCheckbox' type='checkbox' name='import[]' value='%s' checked>&nbsp;\r\n\t\t\t\t\t\t<input class='previewButton' type='button' value='Preview'></input>&nbsp;\r\n\t\t\t\t\t\t%s %s\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div style='margin-top:2em; display:none'>\r\n\t\t\t\t\t\t%s\r\n\t\t\t\t\t\t<br style='clear:both;'/>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t\t", $ident, $item->title, $symbol, CPT_Item::getHTML_Item($item, FALSE, TRUE, $ident . "_"));
        }
        printf("</div></form></div>");
    }
Пример #4
0
 public static function getHTML_Item(EAL_Item $item, $forReview = TRUE, $editableMeta = FALSE, $namePrefix = "")
 {
     $answers_html = "";
     switch (get_class($item)) {
         case 'EAL_ItemSC':
             $answers_html = CPT_ItemSC::getHTML_Answers($item, $forReview);
             break;
         case 'EAL_ItemMC':
             $answers_html = CPT_ItemMC::getHTML_Answers($item, $forReview);
             break;
     }
     if ($forReview) {
         // description
         $item_html = sprintf("<div>%s</div>", wpautop(stripslashes($item->description)));
         // question and answers
         $item_html .= sprintf("<div style='background-color:F2F6FF; margin-top:2em; padding:1em;'>");
         $item_html .= sprintf("%s", wpautop(stripslashes($item->question)));
         $item_html .= sprintf("%s", $answers_html);
         $item_html .= sprintf("</div>");
         return sprintf("<div>%s</div>", $item_html);
     } else {
         // head line (incl. option to edit)
         $item_html = sprintf("\r\n\t\t\t\t<div onmouseover=\"this.children[1].style.display='inline';\"  onmouseout=\"this.children[1].style.display='none';\">\r\n\t\t\t\t\t<h1 style='display:inline'>%s</span></h1>\r\n\t\t\t\t\t<div style='display:none'>\r\n\t\t\t\t\t\t<span><a href=\"post.php?action=edit&post=%d\">Edit</a></span>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>", $item->title, $item->id);
         // description
         $item_html .= sprintf("<div>%s</div>", wpautop(stripslashes($item->description)));
         // question and answers
         $item_html .= sprintf("<div style='background-color:#F2F6FF; margin-top:1em; padding:1em; border-width:1px; border-style:solid; border-color:#CCCCCC;'>");
         $item_html .= sprintf("%s", wpautop(stripslashes($item->question)));
         $item_html .= sprintf("%s", $answers_html);
         $item_html .= sprintf("</div>");
         return sprintf("\r\n\t\t\t\t<div id='poststuff'>\r\n\t\t\t\t\t<div id='post-body' class='metabox-holder columns-2'>\r\n\t\t\t\t\t\t<div class='postbox-container' id='postbox-container-2'>\r\n\t\t\t\t\t\t\t<div class='meta-box-sortables ui-sortable'>\r\n\t\t\t\t\t\t\t\t%s\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class='postbox-container' id='postbox-container-1'>\r\n\t\t\t\t\t\t\t<div style='background-color:#FFFFFF; margin-top:1em; padding:1em; border-width:1px; border-style:solid; border-color:#CCCCCC;'>\r\n\t\t\t\t\t\t\t\t%s\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>", $item_html, CPT_Item::getHTML_Metadata($item, $editableMeta, $namePrefix));
     }
 }
Пример #5
0
 public static function createPageView()
 {
     $itemids = array();
     /* try to get learning outcomes */
     $post_label = "Learning Outcome";
     if ($_REQUEST['learnoutid'] != null) {
         $itemids = [$_REQUEST['learnoutid']];
     }
     if ($_REQUEST['learnoutids'] != null) {
         if (is_array($_REQUEST['learnoutids'])) {
             $itemids = $_REQUEST['learnoutids'];
         }
         if (is_string($_REQUEST['learnoutids'])) {
             $itemids = explode(",", $_REQUEST["learnoutids"]);
         }
     }
     if (count($itemids) == 0) {
         // no learning outcomes found --> get reviews
         $post_label = "Review";
         if ($_REQUEST['reviewid'] != null) {
             $itemids = [$_REQUEST['reviewid']];
         }
         if ($_REQUEST['reviewids'] != null) {
             if (is_array($_REQUEST['reviewids'])) {
                 $itemids = $_REQUEST['reviewids'];
             }
             if (is_string($_REQUEST['reviewids'])) {
                 $itemids = explode(",", $_REQUEST["reviewids"]);
             }
         }
     }
     if (count($itemids) == 0) {
         // nothing found --> get items
         $post_label = "Item";
         if ($_REQUEST['itemid'] != null) {
             $itemids = [$_REQUEST['itemid']];
         }
         if ($_REQUEST['itemids'] != null) {
             if (is_array($_REQUEST['itemids'])) {
                 $itemids = $_REQUEST['itemids'];
             }
             if (is_string($_REQUEST['itemids'])) {
                 $itemids = explode(",", $_REQUEST["itemids"]);
             }
         }
         // fallback: get items from basket
         if (count($itemids) == 0) {
             $itemids = RoleTaxonomy::getCurrentBasket();
         }
         // get_user_meta(get_current_user_id(), 'itembasket', true);
     }
     $html_list = "";
     $html_select = "<form><select onChange='for (x=0; x<this.form.nextSibling.childNodes.length; x++) {  this.form.nextSibling.childNodes[x].style.display = ((this.value<0) || (this.value==x)) ? \"block\" :  \"none\"; }'>";
     $html_select .= sprintf('<option value="-1" selected>[All %1$d %2$ss]</option>', count($itemids), $post_label);
     $count = 0;
     $items = 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 ($post->post_type == 'learnout') {
             $item = new EAL_LearnOut();
         }
         if ($post->post_type == 'review') {
             $item = new EAL_Review();
         }
         if ($item != null) {
             $item->loadById($item_id);
             $html_select .= sprintf("<option value='%d'>%s</option>", $count, $post->post_type == 'review' ? $item->getItem()->title : $item->title);
             $html_list .= sprintf("<div style='margin-top:2em;'><hr/>%s<br style='clear:both;'/></div>", substr($post->post_type, 0, 4) == "item" ? CPT_Item::getHTML_Item($item, FALSE) : ($post->post_type == 'learnout' ? CPT_LearnOut::getHTML_LearnOut($item) : CPT_Review::getHTML_Review($item)));
             $count++;
             array_push($items, $item);
         }
     }
     $html_select .= "</select>&nbsp;&nbsp;&nbsp;<input type='checkbox' checked \r\n\t\t\tonChange='for (x=0; x<this.form.nextSibling.childNodes.length; x++) { this.form.nextSibling.childNodes[x].querySelector(\"#postbox-container-1\").style.display = (this.checked==true) ? \"block\" :  \"none\"; }'/> Show Metadata</form>";
     if ($post_label == "Item") {
         $html_info = sprintf("<form  style='margin-top:5em' enctype='multipart/form-data' action='admin.php?page=view&download=1&itemids=%s' method='post'><table class='form-table'><tbody'>", implode(",", $itemids));
         $html_info .= sprintf("<tr><th style='padding-top:0px; padding-bottom:0px;'><label>%s</label></th>", "Number of Items");
         $html_info .= sprintf("<td style='padding-top:0px; padding-bottom:0px;'>");
         $html_info .= sprintf("<input style='width:5em' type='number' value='%d' readonly/>", count($items));
         $html_info .= sprintf("</td></tr>");
         // Min / Max for all categories
         $categories = array("type", "dim", "level", "topic1");
         foreach ($categories as $category) {
             $html_info .= sprintf("<tr><th style='padding-bottom:0.5em;'><label>%s</label></th></tr>", EAL_Item::$category_label[$category]);
             foreach (PAG_Explorer::groupBy($category, $items, NULL, true) as $catval => $catitems) {
                 $html_info .= sprintf("<tr><td style='padding-top:0px; padding-bottom:0px;'><label>%s</label></td>", $category == "topic1" ? $catval : EAL_Item::$category_value_label[$category][$catval]);
                 $html_info .= sprintf("<td style='padding-top:0px; padding-bottom:0px;'>");
                 $html_info .= sprintf("<input style='width:5em' type='number' value='%d' readonly/>", count($catitems));
                 $html_info .= sprintf("</td></tr>");
             }
         }
         $html_info .= sprintf("<tr><th><button type='submit' name='action' value='download'>Download</button></th><tr>");
         $html_info .= sprintf("</tbody></table></form></div>");
     }
     printf('<div class="wrap"><h1>%1$s Viewer</h1>', $post_label);
     if ($_REQUEST['download'] == '1') {
         $ilias = new EXP_Ilias();
         $link = $ilias->generateExport($itemids);
         printf("<h2><a href='%s'>Download</a></h2>", $link);
     }
     if (count($itemids) > 1 || count($itemids) == 1) {
         print $html_select;
         print "<div style='margin-top:2em'>{$html_list}{$html_info}</div>";
     } else {
         print "<div style='margin-top:2em'>{$html_list}</div>";
     }
     print "</div>";
 }
Пример #6
0
 public function WPCB_mb_item($post, $vars)
 {
     global $review;
     if (!is_null($review->getItem())) {
         $html = CPT_Item::getHTML_Item($review->getItem());
         echo $html;
     }
 }