当前位置: 首页>>代码示例>>PHP>>正文


PHP WPCW_arrays_getValue函数代码示例

本文整理汇总了PHP中WPCW_arrays_getValue函数的典型用法代码示例。如果您正苦于以下问题:PHP WPCW_arrays_getValue函数的具体用法?PHP WPCW_arrays_getValue怎么用?PHP WPCW_arrays_getValue使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了WPCW_arrays_getValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: WPCW_showPage_ConvertPage_load

/**
 * Convert page/post to a course unit 
 */
function WPCW_showPage_ConvertPage_load()
{
    $page = new PageBuilder(false);
    $page->showPageHeader(__('Convert Page/Post to Course Unit', 'wp_courseware'), '75%', WPCW_icon_getPageIconURL());
    // Future Feature - Check user can edit other people's pages - use edit_others_pages or custom capability.
    if (!current_user_can('manage_options')) {
        $page->showMessage(__('Sorry, but you are not allowed to edit this page/post.', 'wp_courseware'), true);
        $page->showPageFooter();
        return false;
    }
    // Check that post ID is valid
    $postID = WPCW_arrays_getValue($_GET, 'postid') + 0;
    $convertPost = get_post($postID);
    if (!$convertPost) {
        $page->showMessage(__('Sorry, but the specified page/post does not appear to exist.', 'wp_courseware'), true);
        $page->showPageFooter();
        return false;
    }
    // Check that post isn't already a course unit before trying change.
    // This is where the conversion takes place.
    if ('course_unit' != $convertPost->post_type) {
        // Confirm we want to do the conversion
        if (!isset($_GET['confirm'])) {
            $message = sprintf(__('Are you sure you wish to convert the <em>%s</em> to a course unit?', 'wp_courseware'), $convertPost->post_type);
            $message .= '<br/><br/>';
            // Yes Button
            $message .= sprintf('<a href="%s&postid=%d&confirm=yes" class="button-primary">%s</a>', admin_url('admin.php?page=WPCW_showPage_ConvertPage'), $postID, __('Yes, convert it', 'wp_courseware'));
            // Cancel
            $message .= sprintf('&nbsp;&nbsp;<a href="%s&postid=%d&confirm=no" class="button-secondary">%s</a>', admin_url('admin.php?page=WPCW_showPage_ConvertPage'), $postID, __('No, don\'t convert it', 'wp_courseware'));
            $page->showMessage($message);
            $page->showPageFooter();
            return false;
        } else {
            // Confirmed conversion
            if ($_GET['confirm'] == 'yes') {
                $postDetails = array();
                $postDetails['ID'] = $postID;
                $postDetails['post_type'] = 'course_unit';
                // Update the post into the database
                wp_update_post($postDetails);
            }
            // Cancelled conversion
            if ($_GET['confirm'] != 'yes') {
                $page->showMessage(__('Conversion to a course unit cancelled.', 'wp_courseware'), false);
                $page->showPageFooter();
                return false;
            }
        }
    }
    // Check conversion happened
    $convertedPost = get_post($postID);
    if ('course_unit' == $convertedPost->post_type) {
        $page->showMessage(sprintf(__('The page/post was successfully converted to a course unit. You can <a href="%s">now edit the course unit</a>.', 'wp_courseware'), admin_url(sprintf('post.php?post=%d&action=edit', $postID))));
    } else {
        $page->showMessage(__('Unfortunately, there was an error trying to convert the page/post to a course unit. Perhaps you could try again?', 'wp_courseware'), true);
    }
    $page->showPageFooter();
}
开发者ID:NClaus,项目名称:Ambrose,代码行数:61,代码来源:page_unit_convertpage.inc.php

示例2: tryExportCourse

 /**
  * See if there's a course to export based on $_POST variables. If so, trigger the export and XML download.
  * @param Boolean $triggerFileDownload If true, trigger a file download rather than just XML output as a page.
  */
 public static function tryExportCourse($triggerFileDownload = true)
 {
     // See if course is being exported
     if (isset($_POST["update"]) && $_POST["update"] == 'wpcw_export' && current_user_can('manage_options')) {
         // Now check course is valid. If not, then don't do anything, and let
         // normal form handle the errors.
         $courseID = WPCW_arrays_getValue($_POST, 'export_course_id');
         $courseDetails = WPCW_courses_getCourseDetails($courseID);
         if ($courseDetails) {
             $moduleList = false;
             // Work out what details to fetch and then export
             $whatToExport = WPCW_arrays_getValue($_POST, 'what_to_export');
             switch ($whatToExport) {
                 // Just the course title, description and settings (no units or modules)
                 case 'just_course':
                     break;
                     // Just the course settings and module settings (no units)
                 // Just the course settings and module settings (no units)
                 case 'course_modules':
                     $moduleList = WPCW_courses_getModuleDetailsList($courseDetails->course_id);
                     break;
                     // Basically case 'whole_course' - The whole course, modules and units
                 // Basically case 'whole_course' - The whole course, modules and units
                 default:
                     $moduleList = WPCW_courses_getModuleDetailsList($courseDetails->course_id);
                     if ($moduleList) {
                         // Grab units for each module, in the right order, and associate with each module object.
                         foreach ($moduleList as $module) {
                             // This might return false, but that's OK. We'll check for it later.
                             $module->units = WPCW_units_getListOfUnits($module->module_id);
                         }
                     }
                     break;
             }
             // If true, trigger a file download of the XML file.
             if ($triggerFileDownload) {
                 $exportFile = "wp-courseware-export-" . date("Y-m-d") . ".xml";
                 header('Content-Description: File Transfer');
                 header("Content-Disposition: attachment; filename={$exportFile}");
             }
             header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
             // When debugging, comment out the line above, and use the following line so that you can see
             // any error messages.
             // header('Content-Type: text/plain');
             $export = new WPCW_Export();
             echo $export->exportCourseDetails($courseDetails, $moduleList);
             die;
         }
     }
     // If get here, then normal WPCW processing takes place.
 }
开发者ID:JalpMi,项目名称:v2contact,代码行数:55,代码来源:class_export.inc.php

示例3: WPCW_showPage_ImportExport_load

/**
 * Shows the page to do with importing/exporting training courses.
 */
function WPCW_showPage_ImportExport_load()
{
    switch (WPCW_arrays_getValue($_GET, 'show')) {
        case 'import':
            WPCW_showPage_ImportExport_import();
            break;
        case 'import_users':
            WPCW_showPage_ImportExport_importUsers();
            break;
        default:
            WPCW_showPage_ImportExport_export();
            break;
    }
}
开发者ID:umairriaz90,项目名称:Daschug1,代码行数:17,代码来源:page_import_export.inc.php

示例4: WPCW_showPage_Documentation_load

/**
 * Shows the documentation page for the plugin. 
 */
function WPCW_showPage_Documentation_load()
{
    $page = new PageBuilder();
    // List of tabs to show
    $docTabs = array('default' => array('flag' => false, 'fn' => 'WPCW_showPage_Documentation_shortcodes', 'label' => __('Shortcodes', 'wp_courseware')), 'howto' => array('flag' => 'howto', 'fn' => 'WPCW_showPage_Documentation_howto', 'label' => __('How-To Videos', 'wp_courseware')));
    // Allow modification of the documentation tabs.
    $docTabs = apply_filters('wpcw_back_documentation_tabs', $docTabs);
    printf('<div class="wrap">');
    $tabNames = array_keys($docTabs);
    // What tabs are active?
    $tabSel = WPCW_arrays_getValue($_GET, 'info');
    if (!in_array($tabSel, $tabNames)) {
        $tabSel = false;
    }
    // Create main settings tab URL
    $baseURL = admin_url('admin.php?page=WPCW_showPage_Documentation');
    // Header
    printf('<h2 class="nav-tab-wrapper">');
    // Icon
    printf('<div id="icon-pagebuilder" class="icon32" style="background-image: url(\'%s\'); margin: 0px 6px 0 6px;"><br></div>', WPCW_icon_getPageIconURL());
    foreach ($docTabs as $type => $tabDetails) {
        // Tabs
        $urlToUse = $baseURL;
        if ($tabDetails['flag']) {
            $urlToUse = $baseURL . '&info=' . $tabDetails['flag'];
        }
        printf('<a href="%s" class="nav-tab %s">%s</a>', $urlToUse, $tabDetails['flag'] == $tabSel ? 'nav-tab-active' : '', $tabDetails['label']);
    }
    printf('</h2>');
    // Create the doc header.
    $page->showPageHeader(false, '75%', false, true);
    // What settings do we show?
    if (in_array($tabSel, $tabNames)) {
        call_user_func($docTabs[$tabSel]['fn']);
    } else {
        call_user_func($docTabs['default']['fn']);
    }
    // Needed to show RHS section for panels
    $page->showPageMiddle('23%');
    // RHS Support Information
    WPCW_docs_showSupportInfo($page);
    WPCW_docs_showSupportInfo_News($page);
    WPCW_docs_showSupportInfo_Affiliate($page);
    $page->showPageFooter();
    // Final div closed by showPageFooter().
    //printf('</div>');
}
开发者ID:NClaus,项目名称:Ambrose,代码行数:50,代码来源:page_documentation.inc.php

示例5: WPCW_AJAX_units_handleQuizResponse

/**
 * Function called when a user is submitting quiz answers via
 * the frontend form. 
 */
function WPCW_AJAX_units_handleQuizResponse()
{
    // Security check
    if (!wp_verify_nonce(WPCW_arrays_getValue($_POST, 'progress_nonce'), 'wpcw-progress-nonce')) {
        die(__('Security check failed!', 'wp_courseware'));
    }
    // Quiz ID and Unit ID are combined in the single CSS ID for validation.
    // So validate both are correct and that user is allowed to access quiz.
    $quizAndUnitID = WPCW_arrays_getValue($_POST, 'id');
    // e.g. quiz_complete_69_1 or quiz_complete_17_2 (first ID is unit, 2nd ID is quiz)
    if (!preg_match('/quiz_complete_(\\d+)_(\\d+)/', $quizAndUnitID, $matches)) {
        echo WPCW_units_getCompletionBox_error();
        die;
    }
    // Use the extracted data for further validation
    $unitID = $matches[1];
    $quizID = $matches[2];
    $user_id = get_current_user_id();
    // #### Get associated data for this unit. No course/module data, not a unit
    $parentData = WPCW_units_getAssociatedParentData($unitID);
    if (!$parentData) {
        // No error, as not a valid unit.
        die;
    }
    // #### User not allowed access to content, so certainly can't say they've done this unit.
    if (!WPCW_courses_canUserAccessCourse($parentData->course_id, $user_id)) {
        // No error, as not a valid unit.
        die;
    }
    // #### Check that the quiz is valid and belongs to this unit
    $quizDetails = WPCW_quizzes_getQuizDetails($quizID, true);
    if (!($quizDetails && $quizDetails->parent_unit_id == $unitID)) {
        die;
    }
    // Validate the quiz answers... which means we might have to
    // send back the form to be re-filled.
    $canContinue = WPCW_quizzes_handleQuizRendering_canUserContinueAfterQuiz($quizDetails, $_POST, $user_id);
    // Check that user is allowed to progress.
    if ($canContinue) {
        WPCW_units_saveUserProgress_Complete($user_id, $unitID, 'complete');
        // Unit complete, check if course/module is complete too.
        do_action('wpcw_user_completed_unit', $user_id, $unitID, $parentData);
        // Only complete if allowed to continue.
        echo WPCW_units_getCompletionBox_complete($parentData, $unitID, $user_id);
    }
    die;
}
开发者ID:JalpMi,项目名称:v2contact,代码行数:51,代码来源:ajax_frontend.inc.php

示例6: check_paging_shouldWeShowAnswerLaterButton

 /**
  * Check if we need to show the answer later button.
  * @return Boolean True if yes, false otherwise.
  */
 function check_paging_shouldWeShowAnswerLaterButton()
 {
     if (!$this->unitQuizDetails) {
         return false;
     }
     // First check if settings allow it.
     $pagingSettings = maybe_unserialize($this->unitQuizDetails->quiz_paginate_questions_settings);
     $allowAnswerLater = 'on' == WPCW_arrays_getValue($pagingSettings, 'allow_students_to_answer_later');
     // True if settings allow it, and we're allowed to show it based on what question we're at.
     return $allowAnswerLater && (empty($this->unitQuizProgress) || !empty($this->unitQuizProgress) && $this->unitQuizProgress->quiz_paging_next_q < $this->unitQuizProgress->quiz_question_total);
 }
开发者ID:NClaus,项目名称:Ambrose,代码行数:15,代码来源:class_frontend_unit.inc.php

示例7: WPCW_quizzes_calculateGradeForQuiz

/**
 * Calculates the grade for a set of results, taking into account the
 * different types of questions.
 * 
 * @param Array $quizData The list of quiz results data.
 * @param Integer $questionsThatNeedMarking How many questions need marking.
 * 
 * @return Integer The overall grade for the results.
 */
function WPCW_quizzes_calculateGradeForQuiz($quizData, $questionsThatNeedMarking = 0)
{
    if ($questionsThatNeedMarking > 0) {
        return '-1';
    }
    $questionTotal = 0;
    $gradeTotal = 0;
    foreach ($quizData as $questionID => $questionResults) {
        // It's a truefalse/multi question
        if ($questionResults['got_right']) {
            // Got it right, so add 100%.
            if ($questionResults['got_right'] == 'yes') {
                $gradeTotal += 100;
            }
        } else {
            // Making assumption that the grade number exists
            // Otherwise we'd never get this far as the question still needs marking.
            $gradeTotal += WPCW_arrays_getValue($questionResults, 'their_grade');
        }
        $questionTotal++;
    }
    // Simple calculation that averages the grade.
    $grade = 0;
    if ($questionTotal) {
        $grade = number_format($gradeTotal / $questionTotal, 1);
    }
    return $grade;
}
开发者ID:umairriaz90,项目名称:Daschug1,代码行数:37,代码来源:common.inc.php

示例8: WPCW_showPage_QuizSummary_load

/**
 * Function that show a summary of the quizzes.
 */
function WPCW_showPage_QuizSummary_load()
{
    global $wpcwdb, $wpdb;
    $wpdb->show_errors();
    // Get the requested page number
    $paging_pageWanted = WPCW_arrays_getValue($_GET, 'pagenum') + 0;
    if ($paging_pageWanted == 0) {
        $paging_pageWanted = 1;
    }
    // Title for page with page number
    $titlePage = false;
    if ($paging_pageWanted > 1) {
        $titlePage = sprintf(' - %s %s', __('Page', 'wp_courseware'), $paging_pageWanted);
    }
    $page = new PageBuilder(false);
    $page->showPageHeader(__('Quiz &amp; Survey Summary', 'wp_courseware') . $titlePage, '75%', WPCW_icon_getPageIconURL());
    // Handle the quiz deletion before showing remaining quizzes...
    WPCW_quizzes_handleQuizDeletion($page);
    // Handle the sorting and filtering
    $orderBy = WPCW_arrays_getValue($_GET, 'orderby');
    $ordering = WPCW_arrays_getValue($_GET, 'order');
    // Validate ordering
    switch ($orderBy) {
        case 'quiz_title':
        case 'quiz_id':
            break;
        default:
            $orderBy = 'quiz_id';
            break;
    }
    // Create opposite ordering for reversing it.
    $ordering_opposite = false;
    switch ($ordering) {
        case 'desc':
            $ordering_opposite = 'asc';
            break;
        case 'asc':
            $ordering_opposite = 'desc';
            break;
        default:
            $ordering = 'desc';
            $ordering_opposite = 'asc';
            break;
    }
    // Was a search string specified? Or a specific item?
    $searchString = WPCW_arrays_getValue($_GET, 's');
    // Create WHERE string based search - Title or Description of Quiz
    $stringWHERE = false;
    if ($searchString) {
        $stringWHERE = $wpdb->prepare(" WHERE quiz_title LIKE %s OR quiz_desc LIKE %s ", '%' . $searchString . '%', '%' . $searchString . '%');
    }
    $summaryPageURL = admin_url('admin.php?page=WPCW_showPage_QuizSummary');
    // Show the form for searching
    ?>
			
	<form id="wpcw_quizzes_search_box" method="get" action="<?php 
    echo $summaryPageURL;
    ?>
">
	<p class="search-box">
		<label class="screen-reader-text" for="wpcw_quizzes_search_input"><?php 
    _e('Search Quizzes', 'wp_courseware');
    ?>
</label>
		<input id="wpcw_quizzes_search_input" type="text" value="<?php 
    echo $searchString;
    ?>
" name="s"/>
		<input class="button" type="submit" value="<?php 
    _e('Search Quizzes', 'wp_courseware');
    ?>
"/>
		
		<input type="hidden" name="page" value="WPCW_showPage_QuizSummary" />
	</p>
	</form>
	<br/><br/>
	<?php 
    $SQL_PAGING = "\n\t\t\tSELECT COUNT(*) as quiz_count \n\t\t\tFROM {$wpcwdb->quiz}\t\t\t\n\t\t\t{$stringWHERE}\n\t\t\tORDER BY quiz_id DESC \n\t\t";
    $paging_resultsPerPage = 50;
    $paging_totalCount = $wpdb->get_var($SQL_PAGING);
    $paging_recordStart = ($paging_pageWanted - 1) * $paging_resultsPerPage + 1;
    $paging_recordEnd = $paging_pageWanted * $paging_resultsPerPage;
    $paging_pageCount = ceil($paging_totalCount / $paging_resultsPerPage);
    $paging_sqlStart = $paging_recordStart - 1;
    // Show search message - that a search has been tried.
    if ($searchString) {
        printf('<div class="wpcw_search_count">%s "%s" (%s %s) (<a href="%s">%s</a>)</div>', __('Search results for', 'wp_courseware'), htmlentities($searchString), $paging_totalCount, _n('result', 'results', $paging_totalCount, 'wp_courseware'), $summaryPageURL, __('reset', 'wp_courseware'));
    }
    // Do main query
    $SQL = "SELECT * \n\t\t\tFROM {$wpcwdb->quiz}\t\t\t\n\t\t\t{$stringWHERE}\n\t\t\tORDER BY {$orderBy} {$ordering}\n\t\t\tLIMIT {$paging_sqlStart}, {$paging_resultsPerPage}\t\t\t \n\t\t\t";
    // These are already checked, so they are safe, hence no prepare()
    // Generate paging code
    $baseURL = WPCW_urls_getURLWithParams($summaryPageURL, 'pagenum') . "&pagenum=";
    $paging = WPCW_tables_showPagination($baseURL, $paging_pageWanted, $paging_pageCount, $paging_totalCount, $paging_recordStart, $paging_recordEnd);
    $quizzes = $wpdb->get_results($SQL);
    if ($quizzes) {
//.........这里部分代码省略.........
开发者ID:NClaus,项目名称:Ambrose,代码行数:101,代码来源:page_quiz_summary.inc.php

示例9: WPCW_showPage_customFeedback_processSave

/**
 * Handle saving a feedback message to the database.
 * 
 * @param Integer $quizID The quiz for which the questions apply to. 
 */
function WPCW_showPage_customFeedback_processSave($quizID)
{
    global $wpdb, $wpcwdb;
    $wpdb->show_errors();
    $msgToSave = array();
    $msgToSave_New = array();
    // Check $_POST data for the
    foreach ($_POST as $key => $value) {
        // ### 1) - Check if we're deleting a custom feedback message
        if (preg_match('/^delete_wpcw_qcfm_sgl_wrapper_([0-9]+)$/', $key, $matches)) {
            // Delete the message from the message table
            $SQL = $wpdb->prepare("\n\t\t\t\tDELETE FROM {$wpcwdb->quiz_feedback}\n\t\t\t\tWHERE qfeedback_id = %d\n\t\t\t", $matches[1]);
            $wpdb->query($SQL);
        }
        // #### 2 - See if we have a custom feedback message to add or update
        // Checking for wpcw_qcfm_sgl_wrapper_1 or wpcw_qcfm_sgl_wrapper_new_message_1
        if (preg_match('/^wpcw_qcfm_sgl_summary(_new_message)?_([0-9]+)$/', $key, $matches)) {
            // Got the ID of the message we're updating or adding.
            $messageID = $matches[2];
            // Store the extra string if we're adding a new message.
            $newMessagePrefix = $matches[1];
            $fieldSuffix = $newMessagePrefix . '_' . $messageID;
            // Fetch each field we need that will be saved
            $messageFields = array('qfeedback_quiz_id' => $quizID, 'qfeedback_summary' => stripslashes(WPCW_arrays_getValue($_POST, 'wpcw_qcfm_sgl_' . 'summary' . $fieldSuffix)), 'qfeedback_message' => stripslashes(WPCW_arrays_getValue($_POST, 'wpcw_qcfm_sgl_' . 'message' . $fieldSuffix)), 'qfeedback_tag_id' => intval(WPCW_arrays_getValue($_POST, 'wpcw_qcfm_sgl_' . 'tag' . $fieldSuffix)), 'qfeedback_score_grade' => intval(WPCW_arrays_getValue($_POST, 'wpcw_qcfm_sgl_' . 'score_grade' . $fieldSuffix)), 'qfeedback_score_type' => WPCW_arrays_getValue($_POST, 'wpcw_qcfm_sgl_' . 'score_type' . $fieldSuffix));
            // Check we have a valid score type.
            if ('below' != $messageFields['qfeedback_score_type'] && 'above' != $messageFields['qfeedback_score_type']) {
                $messageFields['qfeedback_score_type'] = 'below';
            }
            // #### 3) - Not a new message - so add to list of new messages to add.
            if ($newMessagePrefix) {
                $msgToSave_New[] = $messageFields;
            } else {
                $messageFields['qfeedback_id'] = $messageID;
                $msgToSave[] = $messageFields;
            }
        }
        // end of preg_match check
    }
    // each of $_POST foreach.
    // #### 4) Add new messages
    if (!empty($msgToSave_New)) {
        foreach ($msgToSave_New as $messageDetails) {
            $wpdb->query(arrayToSQLInsert($wpcwdb->quiz_feedback, $messageDetails));
        }
    }
    // #### 5) Update existing messages
    if (!empty($msgToSave)) {
        foreach ($msgToSave as $messageDetails) {
            $wpdb->query(arrayToSQLUpdate($wpcwdb->quiz_feedback, $messageDetails, 'qfeedback_id'));
        }
    }
}
开发者ID:Juni4567,项目名称:meritscholarship,代码行数:57,代码来源:page_quiz_modify.inc.php

示例10: WPCW_urls_getURLWithParams

/**
 * Get the URL for the desired page, preserving any parameters.
 * @param String $pageBase The based page to fetch.
 * @param Mixed $ignoreFields The array or string of parameters not to include.
 * @return String The newly formed URL. 
 */
function WPCW_urls_getURLWithParams($pageBase, $ignoreFields = false)
{
    // Parameters to extract from URL to keep in the URL.
    $params = array('s' => false, 'pagenum' => false, 'filter' => false);
    // Got fields we don't want in the URL? Handle both a string and
    // arrays
    if ($ignoreFields) {
        if (is_array($ignoreFields)) {
            foreach ($ignoreFields as $field) {
                unset($params[$field]);
            }
        } else {
            unset($params[$ignoreFields]);
        }
    }
    foreach ($params as $paramName => $notused) {
        $value = WPCW_arrays_getValue($_GET, $paramName);
        if ($value) {
            $pageBase .= '&' . $paramName . '=' . $value;
        }
    }
    return $pageBase;
}
开发者ID:JalpMi,项目名称:v2contact,代码行数:29,代码来源:admin_only.inc.php

示例11: WPCW_data_export_quizSurveyData

/**
 * Function that handles the export of the survey responses for a specified survey.
 */
function WPCW_data_export_quizSurveyData()
{
    $quizID = trim(WPCW_arrays_getValue($_GET, 'quiz_id')) + 0;
    $quizDetails = WPCW_quizzes_getQuizDetails($quizID, true, false, false);
    // Check that we can find the survey.
    if (!$quizDetails) {
        printf('<div class="error updated"><p>%s</p></div>', __('Sorry, could not find that survey to export the response data.', 'wp_courseware'));
        return;
    }
    // Ensure it's a survey
    if ('survey' != $quizDetails->quiz_type) {
        printf('<div class="error updated"><p>%s</p></div>', __('Sorry, but the selected item is not a survey, it\'s a quiz.', 'wp_courseware'));
        return;
    }
    // Does this survey contain random questions? If so, then we need to get the full question data
    // of all possible questions
    if (WPCW_quizzes_doesQuizContainRandomQuestions($quizDetails)) {
        $quizDetails->questions = WPCW_quizzes_randomQuestions_fullyExpand($quizDetails);
    }
    global $wpcwdb, $wpdb;
    $wpdb->show_errors();
    // Create a URL-safe version of the filename.
    $csvFileName = WPCW_urls_createCleanURL('survey-' . $quizDetails->quiz_id . '-' . $quizDetails->quiz_title) . '.csv';
    WPCW_data_export_sendHeaders_CSV($csvFileName);
    // The headings
    $headings = array(__('Trainee WP ID', 'wp_courseware'), __('Trainee Name', 'wp_courseware'), __('Trainee Email Address', 'wp_courseware'));
    // Extract the questions to use as headings.
    $questionListForColumns = array();
    // See if we have any questions in the list.
    if (!empty($quizDetails->questions)) {
        foreach ($quizDetails->questions as $questionID => $questionDetails) {
            $questionListForColumns[$questionID] = $questionDetails->question_question;
            // Add this question to the headings.
            $headings[] = $questionDetails->question_question;
        }
    }
    // Start CSV
    $out = fopen('php://output', 'w');
    // Push out the question headings.
    fputcsv($out, $headings);
    // The responses to the questions
    $answers = $wpdb->get_results($wpdb->prepare("\n\t\tSELECT * \n\t\tFROM {$wpcwdb->user_progress_quiz}\n\t\tWHERE quiz_id = %d\n\t", $quizDetails->quiz_id));
    // Process eacy response from the user, extracting their details too.
    if (!empty($answers)) {
        foreach ($answers as $answerDetails) {
            $resultData = array();
            // We've definitely got the ID
            $resultData[] = $answerDetails->user_id;
            // See if we can get the name and email address.
            $userDetails = get_userdata($answerDetails->user_id);
            if ($userDetails) {
                $resultData[] = $userDetails->display_name;
                $resultData[] = $userDetails->user_email;
            } else {
                $resultData[] = __('User no longer on system.', 'wp_courseware');
                $resultData[] = __('n/a', 'wp_courseware');
            }
            // Extract their responses into an array
            $theirResponses = maybe_unserialize($answerDetails->quiz_data);
            // Go through answers logically now
            if (!empty($questionListForColumns)) {
                foreach ($questionListForColumns as $questionID => $questionTitle) {
                    if (isset($theirResponses[$questionID]) && isset($theirResponses[$questionID]['their_answer'])) {
                        $resultData[] = $theirResponses[$questionID]['their_answer'];
                    } else {
                        $resultData[] = __('No answer for this question.', 'wp_courseware');
                    }
                }
            }
            // end of !empty check
            fputcsv($out, $resultData);
        }
        // end foreach
    }
    // end of if (!empty($answers))
    // All done
    fclose($out);
    die;
}
开发者ID:NClaus,项目名称:Ambrose,代码行数:82,代码来源:export_data.inc.php

示例12: WPCW_showPage_ModifyQuestion_load

/**
 * Function that allows a question to be edited.
 */
function WPCW_showPage_ModifyQuestion_load()
{
    $page = new PageBuilder(true);
    $page->showPageHeader(__('Edit Single Question', 'wp_courseware'), '70%', WPCW_icon_getPageIconURL());
    $questionID = false;
    // Check POST and GET
    if (isset($_GET['question_id'])) {
        $questionID = $_GET['question_id'] + 0;
    } else {
        if (isset($_POST['question_id'])) {
            $questionID = $_POST['question_id'] + 0;
        }
    }
    // Trying to edit a question
    $questionDetails = WPCW_questions_getQuestionDetails($questionID, true);
    // Abort if question not found.
    if (!$questionDetails) {
        $page->showMessage(__('Sorry, but that question could not be found.', 'wp_courseware'), true);
        $page->showPageFooter();
        return;
    }
    // See if the question has been submitted for saving.
    if ('true' == WPCW_arrays_getValue($_POST, 'question_save_mode')) {
        WPCW_handler_questions_processSave(false, true);
        $page->showMessage(__('Question successfully updated.', 'wp_courseware'));
        // Assume save has happened, so reload the settings.
        $questionDetails = WPCW_questions_getQuestionDetails($questionID, true);
    }
    // Manually set the order to zero, as not needed for ordering in this context.
    $questionDetails->question_order = 0;
    switch ($questionDetails->question_type) {
        case 'multi':
            $quizObj = new WPCW_quiz_MultipleChoice($questionDetails);
            break;
        case 'truefalse':
            $quizObj = new WPCW_quiz_TrueFalse($questionDetails);
            break;
        case 'open':
            $quizObj = new WPCW_quiz_OpenEntry($questionDetails);
            break;
        case 'upload':
            $quizObj = new WPCW_quiz_FileUpload($questionDetails);
            break;
        default:
            die(__('Unknown quiz type: ', 'wp_courseware') . $questionDetails->question_type);
            break;
    }
    $quizObj->showErrors = true;
    $quizObj->needCorrectAnswers = true;
    $quizObj->hideDragActions = true;
    // #wpcw_quiz_details_questions = needed for media uploader
    // .wpcw_question_holder_static = needed for wrapping the question using existing HTML.
    printf('<div id="wpcw_quiz_details_questions"><ul class="wpcw_question_holder_static">');
    // Create form wrapper, so that we can save this question.
    printf('<form method="POST" action="%s?page=WPCW_showPage_ModifyQuestion&question_id=%d" />', admin_url('admin.php'), $questionDetails->question_id);
    // Question hidden fields
    printf('<input name="question_id" type="hidden" value="%d" />', $questionDetails->question_id);
    printf('<input name="question_save_mode" type="hidden" value="true" />');
    // Show the quiz so that it can be edited. We're re-using the code we have for editing questions,
    // to save creating any special form edit code.
    echo $quizObj->editForm_toString();
    // Save and return buttons.
    printf('<div class="wpcw_button_group"><br/>');
    printf('<a href="%s?page=WPCW_showPage_QuestionPool" class="button-secondary">%s</a>&nbsp;&nbsp;', admin_url('admin.php'), __('&laquo; Return to Question Pool', 'wp_courseware'));
    printf('<input type="submit" class="button-primary" value="%s" />', __('Save Question Details', 'wp_courseware'));
    printf('</div>');
    printf('</form>');
    printf('</ul></div>');
    $page->showPageFooter();
}
开发者ID:NClaus,项目名称:Ambrose,代码行数:73,代码来源:page_question_modify.inc.php

示例13: WPCW_AJAX_units_handleQuizTimerBegin

/**
 * Function called when user starting a quiz and needs to kick off the timer.
 */
function WPCW_AJAX_units_handleQuizTimerBegin()
{
    // Security check
    if (!wp_verify_nonce(WPCW_arrays_getValue($_POST, 'progress_nonce'), 'wpcw-progress-nonce')) {
        die(__('Security check failed!', 'wp_courseware'));
    }
    // Get unit and quiz ID
    $unitID = intval(WPCW_arrays_getValue($_POST, 'unitid'));
    $quizID = intval(WPCW_arrays_getValue($_POST, 'quizid'));
    // Get the post object for this quiz item.
    $post = get_post($unitID);
    if (!$post) {
        echo WPCW_UnitFrontend::message_createMessage_error(__('Error - could not start the timer for the quiz.', 'wp_courseware') . ' ' . __('Could not find training unit.', 'wp_courseware'));
        die;
    }
    // Initalise the unit details
    $fe = new WPCW_UnitFrontend($post);
    // #### Get associated data for this unit. No course/module data, then it's not a unit
    if (!$fe->check_unit_doesUnitHaveParentData()) {
        echo WPCW_UnitFrontend::message_createMessage_error(__('Error - could not start the timer for the quiz.', 'wp_courseware') . ' ' . __('Could not find course details for unit.', 'wp_courseware'));
        die;
    }
    // #### User not allowed access to content
    if (!$fe->check_user_canUserAccessCourse()) {
        echo $fe->message_user_cannotAccessCourse();
        die;
    }
    // #### See if we're in a position to retake this quiz?
    if (!$fe->check_quizzes_canUserRequestRetake()) {
        echo WPCW_UnitFrontend::message_createMessage_error(__('Error - could not start the timer for the quiz.', 'wp_courseware') . ' ' . __('You are not permitted to retake this quiz.', 'wp_courseware'));
        die;
    }
    // Trigger the upgrade to progress so that we can start the quiz, and trigger the timer.
    $fe->update_quizzes_beginQuiz();
    // Only complete if allowed to continue.
    echo $fe->render_detailsForUnit(false, true);
    die;
}
开发者ID:Juni4567,项目名称:meritscholarship,代码行数:41,代码来源:ajax_frontend.inc.php

示例14: dirname

<?php

// Check that plugin is active (so that this cannot be accessed if plugin isn't).
require dirname(__FILE__) . '/../../../wp-config.php';
// Can't find active WP Courseware init function, so cannot be active.
if (!function_exists('WPCW_plugin_init')) {
    WPCW_export_results_notFound();
}
// Get unit and quiz ID
$unitID = intval(WPCW_arrays_getValue($_GET, 'unitid'));
$quizID = intval(WPCW_arrays_getValue($_GET, 'quizid'));
// Get the post object for this quiz item.
$post = get_post($unitID);
if (!$post) {
    WPCW_export_results_notFound(__('Could not find training unit.', 'wp_courseware'));
}
// Initalise the unit details
$fe = new WPCW_UnitFrontend($post);
// #### Get associated data for this unit. No course/module data, then it's not a unit
if (!$fe->check_unit_doesUnitHaveParentData()) {
    WPCW_export_results_notFound(__('Could not find course details for unit.', 'wp_courseware'));
}
// #### User not allowed access to content
if (!$fe->check_user_canUserAccessCourse()) {
    WPCW_export_results_notFound($fe->fetch_message_user_cannotAccessCourse());
}
include_once 'pdf/pdf_quizresults.inc.php';
$qrpdf = new WPCW_QuizResults();
$parentData = $fe->fetch_getUnitParentData();
$quizDetails = $fe->fetch_getUnitQuizDetails();
// Set values for use in the results
开发者ID:NClaus,项目名称:Ambrose,代码行数:31,代码来源:pdf_create_results.php

示例15: loadQuestionData_addQuestionToDatabase

 /**
  * Try to add this specific question to the database (to the pool).
  * @param Array $singleQuestionData Specific question data to add.
  * @return Integer The ID of the newly inserted question ID, or false if it wasn't added.
  */
 private function loadQuestionData_addQuestionToDatabase($singleQuestionData)
 {
     if (!$singleQuestionData || empty($singleQuestionData)) {
         return false;
     }
     global $wpdb, $wpcwdb;
     $wpdb->show_errors();
     // ### 1 - Initialise data to be added for question.
     $questionDetailsToAdd = $singleQuestionData;
     // ### 2 - Need to strip out question order, as there is no question_order field
     // in the database, so we need to use it in the mappings data.
     $question_order = WPCW_arrays_getValue($singleQuestionData, 'question_order');
     unset($questionDetailsToAdd['question_order']);
     // ### 3 - Handle the insert of the special arrays that need serialising. We know these exist
     // as we have specifically validated them.
     $questionDetailsToAdd['question_data_answers'] = false;
     if (!empty($singleQuestionData['question_data_answers'])) {
         $questionDetailsToAdd['question_data_answers'] = serialize($singleQuestionData['question_data_answers']);
     }
     // ### 4 - Extract tags from the question data so that we can insert the question into
     //		   the database without any errors.
     $tagList = array();
     if (isset($questionDetailsToAdd['tags'])) {
         $tagList = $questionDetailsToAdd['tags'];
     }
     unset($questionDetailsToAdd['tags']);
     // ### 5 - Insert details of this particular question into the database.
     $queryResult = $wpdb->query(arrayToSQLInsert($wpcwdb->quiz_qs, $questionDetailsToAdd));
     // ### 6 - Store the ID of the newly inserted ID, we'll need it for associating tags.
     $currentQuestionID = $wpdb->insert_id;
     // ### 7 - Check query succeeded.
     if ($queryResult === FALSE) {
         $this->errorList[] = __('There was a problem adding the question into the database.', 'wp_courseware');
         return false;
     }
     // ### 8 - Now we create the tag associations.
     WPCW_questions_tags_addTags($currentQuestionID, $tagList);
     return $currentQuestionID;
 }
开发者ID:NClaus,项目名称:Ambrose,代码行数:44,代码来源:data_class_import.inc.php


注:本文中的WPCW_arrays_getValue函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。