Example #1
0
 /**
  * Export custom feedback messages for a specific quiz.
  */
 function export_content_handleQuizzes_customFeedbackMessages($quizObj, $feedbackParentPath)
 {
     $xml = false;
     $feedbackPath = $feedbackParentPath . '/custom_feedback_msgs';
     global $fieldsToProcess_quiz_custom_feedback;
     // Check for messages and render in the XML
     $messageList = WPCW_quizzes_feedback_getFeedbackMessagesForQuiz($quizObj->quiz_id);
     if (!empty($messageList)) {
         // Start msgs block
         $xml .= $this->export_startBlock($feedbackPath, 'custom_feedback_msgs');
         // Show each single message
         foreach ($messageList as $singleMessage) {
             // Add the name of the tag rather than the ID, so that this can be matched
             // up later on import.
             $tagDetails = WPCW_questions_tags_getTagDetails($singleMessage->qfeedback_tag_id);
             $singleMessage->qfeedback_tag_name = $tagDetails->question_tag_name;
             $xml .= $this->export_objectToXML('custom_feedback_msg', false, $singleMessage, $fieldsToProcess_quiz_custom_feedback, $feedbackPath . '/', '/custom_feedback_msg');
         }
         // End msgs block
         $xml .= $this->export_endBlock($feedbackPath, 'custom_feedback_msgs');
     }
     return $xml;
 }
/**
 * Show the forms where the quiz custom feedback can be edited.
 * 
 * @param Integer $quizID the ID of the quiz to be edited.
 * @param Object $page The associated page object for showing messages.
 */
function WPCW_showPage_customFeedback_showEditForms($quizID, $page)
{
    // ### 1 - Heading Messages
    printf('<h3>%s</h3>', __('Custom Feedback Messages', 'wp_courseware'));
    printf('<p>(%s) %s</p>', __('Optional', 'wp_courseware'), __('If you are using question tags within you quiz, you can create custom messages to display upon submission of the quiz based on a student\'s results for a particular tag.', 'wp_courseware'));
    printf('<p><em>%s</em></p>', __('Please note: The custom feedback messages do not display any grade information. Use the settings under <b>Result Settings</b> tab, then <b>Show Answers</b> - to customise the display of results.', 'wp_courseware'));
    // ### 2 - Button to add a new message
    printf('<div class="wpcw_button_group"><a href="#" class="button-secondary" id="wpcw_quiz_custom_feedback_add_new">%s</a></div><br/>', __('Add New Feedback Message', 'wp_courseware'));
    // ### 3 - Keep track of new messages and deletions
    printf('<div id="wpcw_quiz_custom_feedback_add_new_count">0</div>');
    printf('<div id="wpcw_quiz_custom_feedback_deletion_holder"></div>');
    // ### 4 - Holder for new messages
    printf('<div id="wpcw_quiz_custom_feedback_holder">');
    // ### 5 - Render the existing forms to modify the custom messages.
    $feedbackList = WPCW_quizzes_feedback_getFeedbackMessagesForQuiz($quizID);
    if (!empty($feedbackList)) {
        // Show an edit form for each custom feedback item.
        foreach ($feedbackList as $feedbackItem) {
            $fb = new WPCW_quiz_CustomFeedback($quizID, $feedbackItem);
            echo $fb->generate_editForm();
        }
    }
    // ### 6 - Close holder
    printf('</div>');
    // ### 7 - Render a hidden form that's used for a placeholder.
    $fb = new WPCW_quiz_CustomFeedback($quizID, false);
    echo $fb->generate_editForm();
}
 /**
  * Works out if we're showing any custom feedback messages to the user.
  * @return $resultsList The list of messages to show (or an empty array). 
  */
 function fetch_customFeedbackMessage_calculateMessages()
 {
     $resultsList = array();
     // #### 1) - Check we have graded questions for a quiz
     if ($this->check_quizzes_validQuizDetails() && $this->unitQuizProgress && 'survey' != $this->unitQuizDetails->quiz_type && $this->unitQuizProgress->quiz_needs_marking == 0) {
         // #### 2) - See if we have any tag grades for this quiz
         $tagBucketList = $this->fetch_quizzes_questionResultsByTag();
         // No tags to check data against
         if (empty($tagBucketList)) {
             return $resultsList;
         }
         // #### 3) - See if we have any feedback messages for this quiz using
         // a combination of the tags from above, and the quiz ID. This saves
         // how much data we load from the database.
         $tagIDList = array_keys($tagBucketList);
         $feedbackList = WPCW_quizzes_feedback_getFeedbackMessagesForQuiz($this->unitQuizDetails->quiz_id, $tagIDList);
         // #### 4) - Now we process each feedback message to see if it matches the criteria.
         if (!empty($feedbackList)) {
             // Now include custom feedback class, as we need it.
             include_once WPCW_plugin_getPluginDirPath() . 'classes/class_custom_feedback.inc.php';
             foreach ($feedbackList as $feedbackItem) {
                 $fb = new WPCW_quiz_CustomFeedback($this->unitQuizDetails->quiz_id, $feedbackItem);
                 // See if the message matches the feedback we've got.
                 if ($fb->doesMessageMatchCriteria($tagBucketList)) {
                     $resultsList[] = $fb->getMessage();
                 }
                 //echo $fb->generate_editForm();
             }
         }
         // end if $feedbackList.
     }
     // end if quiz check
     return $resultsList;
 }