コード例 #1
0
 public static function getListOfLearningOutcomes($learnout_id, $namePrefix = "")
 {
     global $wpdb;
     $sqlres = $wpdb->get_results("\r\n\t\t\t\tSELECT L.id, L.title\r\n\t\t\t\tFROM {$wpdb->prefix}eal_learnout L\r\n\t\t\t\tJOIN {$wpdb->prefix}posts P\r\n\t\t\t\tON (L.id = P.id)\r\n\t\t\t\tWHERE P.post_status = 'publish'\r\n\t\t\t\tAND L.domain = '" . RoleTaxonomy::getCurrentRoleDomain()["name"] . "'\r\n\t\t\t\tORDER BY L.title\r\n\t\t\t\t");
     $html .= "<select align='right' name='{$namePrefix}learnout_id'>";
     $html .= "<option value='0'" . ($learnout_id == 0 ? " selected" : "") . ">None</option>";
     foreach ($sqlres as $pos => $sqlrow) {
         $html .= "<option value='{$sqlrow->id}'" . ($learnout_id == $sqlrow->id ? " selected" : "") . ">{$sqlrow->title}</option>";
     }
     $html .= "</select>";
     return $html;
 }
コード例 #2
0
 private static function getValuesByKey($name, $item, $parent)
 {
     if ($name == null || $name == "none") {
         return [0];
     }
     if ($name == "type") {
         return [$item->type];
     }
     if ($name == "difficulty") {
         if (!isset($item->difficulty)) {
             return [];
         }
         return [$item->difficulty];
     }
     if ($name == "dim" || $name == "level") {
         $res = array();
         foreach (array('FW', 'PW', 'KW') as $dim) {
             if ($item->level[$dim] > 0) {
                 if ($name == "dim") {
                     array_push($res, $dim);
                 }
                 // return [$dim];
                 if ($name == "level") {
                     array_push($res, $item->level[$dim]);
                 }
                 // return [$item->level[$dim]];
             }
         }
         return $res;
     }
     if ($name == "topic1" || $name == "topic2") {
         $res = array();
         foreach (wp_get_post_terms($item->id, RoleTaxonomy::getCurrentRoleDomain()["name"]) as $term) {
             $termhier = array($term->name);
             $parentId = $term->parent;
             while ($parentId > 0) {
                 $parentTerm = get_term($parentId, RoleTaxonomy::getCurrentRoleDomain()["name"]);
                 $termhier = array_merge(array($parentTerm->name), $termhier);
                 $parentId = $parentTerm->parent;
             }
             if ($name == "topic1" && !in_array($termhier[0], $res)) {
                 array_push($res, $termhier[0]);
             }
             // for topic2: check if available AND if parent=topic1 is the same
             if ($name == "topic2" && count($termhier) > 1 && $termhier[0] == $parent && !in_array($termhier[1], $res)) {
                 array_push($res, $termhier[1]);
             }
         }
         return $res;
     }
     return [];
 }
コード例 #3
0
ファイル: class.CPT_Object.php プロジェクト: andreas-thor/eal
 public function WPCB_restrict_manage_posts()
 {
     global $typenow, $wp_query;
     // an array of all the taxonomyies you want to display. Use the taxonomy name or slug
     $taxonomies = array(RoleTaxonomy::getCurrentRoleDomain()["name"]);
     // must set this to the post type you want the filter(s) displayed on
     if ($typenow == $this->type) {
         if ($this->type == "item" || $this->type == "itembasket") {
             $selected = isset($_REQUEST["item_type"]) ? $_REQUEST["item_type"] : "0";
             printf('<select class="postform" name="item_type">');
             printf('<option value="0" %1$s>All Item Types</option>', $selected == "0" ? "selected" : "");
             printf('<option value="itemsc" %1$s>Single Choice</option>', $selected == "itemsc" ? "selected" : "");
             printf('<option value="itemmc" %1$s>Multiple Choice</option>', $selected == "itemmc" ? "selected" : "");
             printf('</select>');
             $selected = isset($_REQUEST["post_status"]) ? $_REQUEST["post_status"] : "0";
             printf('<select class="postform" name="post_status">');
             printf('<option value="0" %1$s>All Item Statuses</option>', $selected == "0" ? "selected" : "");
             printf('<option value="draft" %1$s>Draft</option>', $selected == "draft" ? "selected" : "");
             printf('<option value="pending" %1$s>Pending</option>', $selected == "pending" ? "selected" : "");
             printf('<option value="publish" %1$s>Published</option>', $selected == "publish" ? "selected" : "");
             printf('</select>');
         }
         wp_dropdown_categories(array('show_option_all' => __("Show All Topics"), 'taxonomy' => RoleTaxonomy::getCurrentRoleDomain()["name"], 'name' => 'taxonomy', 'orderby' => 'name', 'selected' => isset($wp_query->query['taxonomy']) ? $wp_query->query['taxonomy'] : '', 'hierarchical' => true, 'depth' => 0, 'value_field' => 'term_id', 'show_count' => true, 'hide_empty' => false));
         foreach (EAL_Item::$level_type as $lt) {
             $selected = isset($_REQUEST["level_{$lt}"]) && $_REQUEST["level_{$lt}"] != '0' ? $_REQUEST["level_{$lt}"] : 0;
             echo "<select class='postform' name='level_{$lt}'>";
             echo "<option value='0'>All {$lt}</option>";
             foreach (array(1, 2, 3, 4, 5, 6) as $v) {
                 echo "<option value='{$v}' " . ($v == $selected ? 'selected' : '') . ">" . EAL_Item::$level_label[$v - 1] . "</option>";
             }
             echo "</select>";
         }
         if (substr($this->type, 0, 4) == 'item') {
             $flag == 0;
             if (isset($_REQUEST["flag"])) {
                 $flag = $_REQUEST["flag"];
             }
             printf("<select class='postform' name='flag'>");
             printf("<option value='0' %s>All Flags</option>", $flag == 0 ? "selected" : "");
             printf("<option value='1' %s>Marked</option>", $flag == 1 ? "selected" : "");
             printf("<option value='2' %s>Unmarked</option>", $flag == 2 ? "selected" : "");
             printf("</select>");
         }
     }
 }
コード例 #4
0
function my_new_toolbar_item($wp_admin_bar)
{
    $args = array('id' => 'eal_logo', 'title' => '<div style="width:10em"><a href="' . site_url() . '/wp-admin/"><img style="display:block; margin-top:1em; margin-left:-1em; width:11em"  src="' . plugin_dir_url(__FILE__) . 'Logo_EAs.LiT.png"></a></div>');
    $wp_admin_bar->add_node($args);
    // 	$wp_admin_bar->remove_menu ('user-actions');
    $wp_admin_bar->remove_menu('updates');
    $wp_admin_bar->remove_menu('comments');
    $wp_admin_bar->remove_menu('new-content');
    $wp_admin_bar->remove_menu('wp-logo');
    $wp_admin_bar->remove_menu('site-name');
    // 	$title  = "<div>";
    // 	$title .= sprintf ("<div class='dashicons-before %s' style='display:inline'>&nbsp;", (RoleTaxonomy::getCurrentRoleType()=="author") ? "dashicons-admin-users" :  "dashicons-groups");
    $title .= sprintf("%s %s", site_url(), RoleTaxonomy::getCurrentRoleDomain()["label"]);
    // 	$title .= sprintf ("<a class='ab-item' href='%s/wp-admin/profile.php'>%s</a></div>", site_url(), RoleTaxonomy::getCurrentRoleDomain()["label"]);
    // 	$wp_admin_bar->add_menu (array ("id" => "eal_currentRole", "title" => $title, "meta" => array ("class" => sprintf ("dashicons-before %s", (RoleTaxonomy::getCurrentRoleType()=="author") ? "dashicons-admin-users" :  "dashicons-groups"))));
    $wp_admin_bar->add_menu(array("id" => "eal_currentRole", "href" => sprintf('%s/wp-admin/profile.php', site_url()), "title" => sprintf("<div class='wp-menu-image dashicons-before %s'>&nbsp;%s</div>", RoleTaxonomy::getCurrentRoleType() == "author" ? "dashicons-admin-users" : "dashicons-groups", RoleTaxonomy::getCurrentRoleDomain()["label"])));
}
コード例 #5
0
ファイル: class.CPT_Item.php プロジェクト: andreas-thor/eal
    public static function getHTML_Metadata(EAL_Item $item, $editable, $namePrefix)
    {
        // Status and Id
        $res = sprintf("<div>%s (%d)</div><br/>", $item->getStatusString(), $item->id);
        // Learning Outcome (Title + Description), if available
        $learnout = $item->getLearnOut();
        if ($editable) {
            $res .= sprintf("<div>%s</div>", EAL_LearnOut::getListOfLearningOutcomes($learnout == null ? 0 : $learnout->id, $namePrefix));
        } else {
            if (!is_null($learnout)) {
                $res .= sprintf("<div><b>%s</b>: %s</div><br/>", $learnout->title, $learnout->description);
            }
        }
        // Level-Table
        $res .= sprintf("<div>%s</div><br/>", CPT_Object::getLevelHTML($namePrefix, $item->level, is_null($learnout) ? null : $learnout->level, $editable ? "" : "disabled", 1, ''));
        // Taxonomy Terms: Name of Taxonomy and list of terms (if available)
        $res .= sprintf("<div><b>%s</b>:", RoleTaxonomy::getDomains()[$item->domain]);
        if ($editable) {
            $res .= sprintf('
				<div class="inside">
					<div class="categorydiv">
						<div id="topic-all" class="tabs-panel"><input type="hidden" name="%1$s_taxonomy[]" value="0">
							<ul id="topicchecklist" data-wp-lists="list:topic" class="categorychecklist form-no-clear">
							%2$s
							</ul>
						</div>
					</div>
				</div>', $namePrefix, CPT_Item::getHTML_TopicHierarchy($namePrefix, get_terms(array('taxonomy' => $item->domain, 'hide_empty' => false)), 0, wp_get_post_terms($item->id, $item->domain, array("fields" => "ids"))));
        } else {
            $terms = wp_get_post_terms($item->id, $item->domain, array("fields" => "names"));
            if (count($terms) > 0) {
                $res .= sprintf("<div style='margin-left:1em'>");
                foreach ($terms as $t) {
                    $res .= sprintf("%s</br>", $t);
                }
                $res .= sprintf("</div>");
            }
        }
        $res .= sprintf("</div>");
        return $res;
    }
コード例 #6
0
ファイル: class.EAL_Item.php プロジェクト: andreas-thor/eal
 public function load()
 {
     global $post;
     if (get_post_status($post->ID) == 'auto-draft') {
         /* Create new item */
         $this->id = $post->ID;
         $this->title = '';
         $this->description = '';
         $this->question = '';
         $this->level["FW"] = 0;
         $this->level["KW"] = 0;
         $this->level["PW"] = 0;
         $this->learnout_id = isset($_POST['learnout_id']) ? $_POST['learnout_id'] : (isset($_GET['learnout_id']) ? $_GET['learnout_id'] : null);
         $this->learnout = null;
         $this->difficulty = null;
         $this->domain = RoleTaxonomy::getCurrentRoleDomain()["name"];
         $this->note = "";
         $this->flag = 0;
     } else {
         $this->loadById($post->ID);
     }
 }
コード例 #7
0
    public static function createPage()
    {
        if ($_POST['action'] == 'Upload') {
            //	checks for errors and that file is uploaded
            if ($_FILES['uploadedfile']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) {
                $level = -1;
                $lastParent = array(-1 => $_POST['topicroot']);
                foreach (file($_FILES['uploadedfile']['tmp_name'], FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
                    $identSize = strlen($line) - strlen(ltrim($line));
                    if ($identSize > $level) {
                        $level++;
                    }
                    if ($identSize < $level) {
                        $level = max(0, $identSize);
                    }
                    $x = wp_insert_term(utf8_encode(trim($line)), RoleTaxonomy::getCurrentRoleDomain()["name"], array('parent' => $lastParent[$level - 1]));
                    $lastParent[$level] = $x instanceof WP_Error ? $x->error_data['term_exists'] : $x['term_id'];
                }
            }
        }
        ?>
			
		<div class="wrap">
		
			<h1>Import Taxonomy Terms</h1>
			
			<h2>Upload Terms</h2>
			<form  enctype="multipart/form-data" action="admin.php?page=import-taxonomy" method="post">
				<table class="form-table">
					<tbody>
						<tr class="user-first-name-wrap">
							<th><label>File</label></th>
							<td><input class="menu-name regular-text menu-item-textbox input-with-default-title" name="uploadedfile" type="file" size="30" accept="text/*"></td>
						</tr>
						<tr class="user-first-name-wrap">
							<th><label>Parent</label></th>
							<td>
<?php 
        wp_dropdown_categories(array('show_option_none' => __("None"), 'option_none_value' => 0, 'taxonomy' => RoleTaxonomy::getCurrentRoleDomain()["name"], 'name' => 'topicroot', 'value_field' => 'id', 'orderby' => 'name', 'selected' => '', 'hierarchical' => true, 'depth' => 0, 'show_count' => false, 'hide_empty' => false));
        ?>
							</td>
						</tr>
						<tr>
							<th>
								<input type="submit" name="action" class="button button-primary" value="Upload">
							</th>
							<td></td>
						</tr>
					</tbody>
				</table>
			</form>
			
			
			<h2>Download Topic Terms</h2>
			<form action="options.php" method="post" name="options">
				<table class="form-table">
					<tbody>
						<tr class="user-first-name-wrap">
							<th><label>Parent</label></th>
							<td>
<?php 
        wp_dropdown_categories(array('show_option_none' => __("None"), 'option_none_value' => 0, 'taxonomy' => 'topic', 'name' => 'topicroot', 'value_field' => 'id', 'orderby' => 'name', 'selected' => '', 'hierarchical' => true, 'depth' => 0, 'show_count' => false, 'hide_empty' => false));
        ?>
								
								
							</td>
						</tr>
						<tr>
							<th><input type="submit" name="action" class="button button-primary" value="Download"></th>
							<td></td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>	
									
			
<?php 
    }
コード例 #8
0
 public static function getHTML_Metadata(EAL_LearnOut $lo)
 {
     // Level-Table
     $res = sprintf("<div>%s</div><br/>", CPT_Object::getLevelHTML("lo" . $lo->id, $lo->level, null, "disabled", 0, ''));
     // Taxonomy Terms: Name of Taxonomy and list of terms (if available)
     $res .= sprintf("<div><b>%s</b>:", RoleTaxonomy::getDomains()[$lo->domain]);
     $terms = wp_get_post_terms($lo->id, $lo->domain, array("fields" => "names"));
     if (count($terms) > 0) {
         $res .= sprintf("<div style='margin-left:1em'>");
         foreach ($terms as $t) {
             $res .= sprintf("%s</br>", $t);
         }
         $res .= sprintf("</div>");
     }
     $res .= sprintf("</div>");
     return $res;
 }
コード例 #9
0
ファイル: class.PAG_Basket.php プロジェクト: andreas-thor/eal
 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>";
 }
コード例 #10
0
ファイル: class.EXP_Ilias.php プロジェクト: andreas-thor/eal
 /**
  * 
  * @param DOMDocument $doc
  * @param $itemids: array (qref -> item_id) ... if item_id is available 
  * @return array (qref -> item) return the item object for each qref (if the item is already in the database, it has been loaded and updated with the values)
  */
 public function parseQTI(DOMDocument $doc, $itemids)
 {
     $items = array();
     $root = $doc->documentElement;
     $xpath = new DOMXPath($doc);
     foreach ($xpath->evaluate("//item", $doc->documentElement) as $itemXML) {
         // determine (==item_id) if available and item type
         $item_id = $itemids[$itemXML->getAttribute("ident")];
         $item_type = "";
         foreach ($xpath->evaluate(".//qtimetadatafield[./fieldlabel='QUESTIONTYPE']/fieldentry", $itemXML) as $md) {
             if ($md->nodeValue == "SINGLE CHOICE QUESTION") {
                 $item_type = "itemsc";
             }
             if ($md->nodeValue == "MULTIPLE CHOICE QUESTION") {
                 $item_type = "itemmc";
             }
         }
         // TODO: Handling if item type not found
         if ($item_type == "") {
             unset($itemids[$itemXML->getAttribute("ident")]);
             continue;
         }
         // initialize item
         if ($item_type == "itemsc") {
             $item = new EAL_ItemSC();
         }
         if ($item_type == "itemmc") {
             $item = new EAL_ItemMC();
         }
         if ($item_id != "") {
             $item->loadById($item_id);
         }
         // get title and description + question
         $item->domain = RoleTaxonomy::getCurrentRoleDomain()["name"];
         $item->title = $itemXML->getAttribute("title");
         $descques = $xpath->evaluate("./presentation/flow/material/mattext/text()", $itemXML)[0]->wholeText;
         $descques = preg_replace_callback('|(<img[^>]+)src=["\']([^"]*)["\']|', function ($match) {
             /* if img is stored inline (src="data:image/png;base64,iVBOR....") --> do nothing */
             if (strtolower(substr($match[2], 0, 5)) == 'data:') {
                 return $match[1] . "src='" . $match[2] . "'";
             }
             /* locate file */
             $entries = scandir("{$this->dir}/{$this->name}/objects/{$match[2]}/");
             $entry = $entries[count($entries) - 1];
             /* generate unique filename for img */
             $count = 0;
             $path = wp_upload_dir()["path"];
             $filename = $match[2];
             while (file_exists($path . "/" . $filename . "_" . $count)) {
                 $count++;
             }
             $from = "{$this->dir}/{$this->name}/objects/{$entry}";
             $to = $path . "/" . $filename . "_" . $count;
             copy("{$this->dir}/{$this->name}/objects/{$match[2]}/{$entry}", $path . "/" . $filename . "_" . $count);
             return $match[1] . "src='" . wp_upload_dir()["url"] . "/" . $filename . "_" . $count . "'";
         }, $descques);
         // Description and Question are separated by horizontal line
         $split = explode("<hr />", $descques, 2);
         if (count($split) == 1) {
             $item->description = "";
             $item->question = $split[0];
         } else {
             $item->description = $split[0];
             $item->question = $split[1];
         }
         // collect answer ids
         $answers = array();
         foreach ($xpath->evaluate("./presentation/flow//response_label", $itemXML) as $resp) {
             $answers[$resp->getAttribute("ident")] = array("text" => $xpath->evaluate("./material/mattext/text()", $resp)[0]->wholeText, "positive" => 0, "negative" => 0);
         }
         // collect points for each answer
         foreach ($xpath->evaluate("./resprocessing/respcondition", $itemXML) as $resp) {
             $answerId = $resp->getElementsByTagName("conditionvar")[0]->firstChild->nodeValue;
             $answerPositive = $xpath->evaluate("./setvar[../conditionvar/varequal]/text()", $resp);
             $answerNegative = $xpath->evaluate("./setvar[../conditionvar/not/varequal]/text()", $resp);
             if ($answerPositive->length > 0) {
                 $answers[$answerId]["positive"] = $answerPositive[0]->wholeText;
             }
             if ($answerNegative->length > 0) {
                 $answers[$answerId]["negative"] = $answerNegative[0]->wholeText;
             }
         }
         // set answer data for items
         $item->answers = array();
         foreach ($answers as $k => $v) {
             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"]));
             }
         }
         // update Item id (for newly created items)
         $items[$itemXML->getAttribute("ident")] = $item;
     }
     return $items;
 }
コード例 #11
0
ファイル: class.CPT_Review.php プロジェクト: andreas-thor/eal
 public function WPCB_posts_join($join, $checktype = TRUE)
 {
     global $wp_query, $wpdb;
     if ($wp_query->query["post_type"] == $this->type || !$checktype) {
         $domain = RoleTaxonomy::getCurrentRoleDomain();
         $join .= " JOIN {$wpdb->prefix}eal_{$this->type} AS R ON (R.id = {$wpdb->posts}.ID) ";
         $join .= " JOIN {$wpdb->prefix}eal_item AS I ON (I.id = R.item_id " . ($domain["name"] != "" ? "AND I.domain = '" . $domain["name"] . "')" : ")");
         $join .= " JOIN {$wpdb->posts} AS postitem ON (I.id = postitem.id) ";
         $join .= " JOIN {$wpdb->users} UI ON (UI.id = postitem.post_author) ";
         $join .= " JOIN {$wpdb->users} UR ON (UR.id = {$wpdb->posts}.post_author) ";
     }
     return $join;
 }
コード例 #12
0
 public static function getCurrentRoleDomain()
 {
     $result = array("name" => "", "label" => "");
     $current_role = get_user_meta(get_current_user_id(), 'current_role', true);
     if (!isset($current_role) || $current_role == "") {
         return $result;
     }
     if ($current_role == "administrator") {
         return $result;
     }
     $result["name"] = substr($current_role, 2);
     $result["label"] = RoleTaxonomy::getDomains()[$result["name"]];
     return $result;
 }