/** * Fetch the form for showing actions at the bottom of the page for the QuestionPool. */ function WPCW_showPage_QuestionPool_actionForm() { // Start wrapper for bulk actions $formWrapper_end = '<div id="wpcw_tbl_question_pool_bulk_actions">'; // Error messages - if no questions or tags have been selected. $formWrapper_end .= sprintf('<div id="wpcw_bulk_action_message_no_questions" class="wpcw_msg_error">%s</div>', __('Please select <b>at least 1 question</b> before continuing...', 'wp_courseware')); $formWrapper_end .= sprintf('<div id="wpcw_bulk_action_message_no_tag_first" class="wpcw_msg_error">%s</div>', __('Please select the <b>first tag</b> before continuing...', 'wp_courseware')); $formWrapper_end .= sprintf('<div id="wpcw_bulk_action_message_no_tag_second" class="wpcw_msg_error">%s</div>', __('Please select the <b>second tag</b> before continuing...', 'wp_courseware')); // Label - saying these are actions $formWrapper_end .= sprintf('<label>%s</label>', __('Action for selected questions?', 'wp_courseware')); // Dropdown of actions $formWrapper_end .= sprintf(WPCW_forms_createDropdown('wpcw_bulk_action_actions', array('' => __('--- Select action ---', 'wp_courseware'), 'add_tag' => __('Add tag to selected questions', 'wp_courseware'), 'remove_tag' => __('Remove tag from selected questions', 'wp_courseware'), 'replace_tag' => __('Replace all instances of tag', 'wp_courseware')), false, 'wpcw_tbl_question_pool_bulk_actions_chooser', false)); // #### The starting labels for all 3 actions. $formWrapper_end .= sprintf('<label class="wpcw_bulk_action_label wpcw_bulk_action_add_tag">%s:</label>', __('Add Tag', 'wp_courseware')); $formWrapper_end .= sprintf('<label class="wpcw_bulk_action_label wpcw_bulk_action_remove_tag">%s:</label>', __('Remove Tag', 'wp_courseware')); $formWrapper_end .= sprintf('<label class="wpcw_bulk_action_label wpcw_bulk_action_replace_tag">%s:</label>', __('Replace Tag', 'wp_courseware')); // #### All 3 - Selector for Add/Remove/Replace tag - first box $formWrapper_end .= WPCW_questions_tags_getTagDropdown(__('Select a tag', 'wp_courseware'), 'wpcw_bulk_action_select_tag_a', WPCW_arrays_getValue($_POST, 'wpcw_bulk_action_select_tag_a'), 'wpcw_bulk_action_select_tag_a wpcw_bulk_action_select_tag wpcw_bulk_action_add_tag wpcw_bulk_action_remove_tag wpcw_bulk_action_replace_tag'); // ### Just 'Replace Tag' - the second label $formWrapper_end .= sprintf('<label class="wpcw_bulk_action_label wpcw_bulk_action_replace_tag">%s:</label>', __('With', 'wp_courseware')); // Just 'Replace Tag' - the second dropdown $formWrapper_end .= WPCW_questions_tags_getTagDropdown(__('Select a tag', 'wp_courseware'), 'wpcw_bulk_action_select_tag_b', WPCW_arrays_getValue($_POST, 'wpcw_bulk_action_select_tag_b'), 'wpcw_bulk_action_select_tag_b wpcw_bulk_action_select_tag wpcw_bulk_action_replace_tag'); // Button - submit $formWrapper_end .= sprintf('<input type="submit" class="button-primary" value="%s">', __('Update Questions', 'wp_courseware')); // End wrapper for bulk actions $formWrapper_end .= '</div>'; return $formWrapper_end; }
/** * Creates a simple spinner line with delete/tag selection. * * @param Integer $defaultCount The default count on the spinner. */ function WPCW_showPage_thickbox_randomQuestion_tagSelectionLine($defaultCount = 10, $isFirst = false) { printf('<div class="wpcw_tb_option_wrap_question_tags_row">'); // Label prefix printf('<label>%s </label>', __('Select ', 'wp_courseware')); // Input box printf('<input type="text" class="wpcw_spinner" value="%d" />', $defaultCount); // Label suffix printf('<label> %s </label>', __('questions from', 'wp_courseware')); // The tag dropdown echo WPCW_questions_tags_getTagDropdown(__('--- Select Tag ---', 'wp_courseware'), 'tag_selection', false, 'wpcw_tb_option_tag_select', true); // The deletion link. printf('<a href="#" class="wpcw_delete_icon" rel="%s" %s>%s</a>', __('Are you sure you wish to delete this selection?', 'wp_courseware'), $isFirst ? 'style="display: none;"' : false, __('Delete', 'wp_courseware')); // Marker to show that a tag needs selection. printf('<div class="wpcw_missing_tag">%s</div>', __('Please select a tag', 'wp_courseware')); printf('</div>'); }
/** * Generates the form where the trainer can edit the details of the custom message. */ function generate_editForm() { $html = false; // Build the root of each field name, then append a suffix for each field. $fieldSuffix = '_' . $this->feedbackMsgDetails->qfeedback_id; $fieldPrefix = 'wpcw_qcfm_sgl_'; $html .= sprintf('<div id="%swrapper%s"><table class="wpcw_quiz_custom_feedback_wrap_single" cellspacing="0"><tbody>', $fieldPrefix, $fieldSuffix); // ### 1) - Show the feedback message - summary field. $html .= sprintf('<tr class="wpcw_quiz_custom_feedback_hdr">'); // Label $html .= sprintf('<th>%s:<span class="wpcw_inner_hint">%s</span></th>', __('Message Description', 'wp_courseware'), __('(Required) A quick summary for this message. This will not be displayed to students.')); $html .= '<td>'; // Entry field for message summary name $html .= sprintf('<input name="%s" type="text" value="%s" class="wpcw_qcfm_sgl_summary" placeholder="%s">', $fieldPrefix . 'summary' . $fieldSuffix, $this->feedbackMsgDetails->qfeedback_summary, __('e.g. Low score on MyTag section', 'wp_courseware')); // Error message if incomplete $html .= sprintf('<span class="wpcw_quiz_custom_feedback_error">%s</span>', __('Please specify a quick summary for this message.', 'wp_courseware')); $html .= '</td>'; // Toggle field //$html .= sprintf('<td class="wpcw_quiz_custom_feedback_toggle">[+]</td>'); $html .= '</tr>'; // ### 2) - Show tag selection field $html .= sprintf('<tr>'); // Label $html .= sprintf('<th>%s:<span class="wpcw_inner_hint">%s</span></th>', __('Select Question Tag', 'wp_courseware'), __('(Required) Select the tag for which you want to provide feedback.')); // Tag selection $html .= '<td>'; // Dropdown for the tags $html .= WPCW_questions_tags_getTagDropdown(__('-- Please choose a tag ---', 'wp_courseware'), $fieldPrefix . 'tag' . $fieldSuffix, $this->feedbackMsgDetails->qfeedback_tag_id, 'wpcw_qcfm_sgl_tag', false, false); // Error message if incomplete $html .= sprintf('<span class="wpcw_quiz_custom_feedback_error">%s</span>', __('Please select a tag for this message.', 'wp_courseware')); // Shows the count of how many tags are available for this tag // This has not been continued for now, as it's an extremely expensive operation due to the random questions. /* if ($this->feedbackMsgDetails->qfeedback_tag_id > 0) { $questionCount = 3;//WPCW_quizzes_getQuestionCountForTag($this->quizID, $this->feedbackMsgDetails->qfeedback_tag_id); // Show count based on how many questions found for this tag. $html .= sprintf('<span class="wpcw_quiz_custom_feedback_question_count"><b>%d %s</b> %s</span>', $questionCount, _n('question', 'questions', $questionCount, 'wp_courseware'), __('found for this tag in this quiz.', 'wp_courseware') ); } // No selected tag, so just hide this. else { $html .= '<span class="wpcw_quiz_custom_feedback_question_count" style="display: none;"></span>'; }*/ $html .= '</td>'; // Empty toggle field. //$html .= sprintf('<td></td>'); $html .= '</tr>'; // ### 3) - Show the score level selection $html .= sprintf('<tr class="alternate">'); // Label $html .= sprintf('<th>%s:<span class="wpcw_inner_hint">%s</span></th>', __('Select Question Tag', 'wp_courseware'), __('(Required) Select the tag for which you want to provide feedback.')); $html .= '<td class="wpcw_quiz_custom_feedback_score">'; $html .= sprintf('<span class="wpcw_quiz_custom_feedback_score_label_first">%s</span>', __('Display this message to students who score:', 'wp_courseware')); // Score condition check $html .= '<span class="wpcw_quiz_custom_feedback_score_radio_wrap">'; $html .= sprintf('<label><input type="radio" name="%s" value="above" %s /> %s</label>', $fieldPrefix . 'score_type' . $fieldSuffix, $this->feedbackMsgDetails->qfeedback_score_type == 'above' ? 'checked="checked"' : false, __('above', 'wp_courseware')); $html .= sprintf('<label><input type="radio" name="%s" value="below" %s /> %s</label>', $fieldPrefix . 'score_type' . $fieldSuffix, $this->feedbackMsgDetails->qfeedback_score_type == 'below' ? 'checked="checked"' : false, __('at or below', 'wp_courseware')); $html .= '</span>'; // Score selection $html .= WPCW_forms_createDropdown($fieldPrefix . 'score_grade' . $fieldSuffix, WPCW_quizzes_getPercentageList(false), $this->feedbackMsgDetails->qfeedback_score_grade); $html .= sprintf('<span class="wpcw_quiz_custom_feedback_score_label_second">%s</span>', __('across all questions for the tag selected above', 'wp_courseware')); // Error message if incomplete $html .= sprintf('<span class="wpcw_quiz_custom_feedback_error">%s</span>', __('Please select a trigger score for this message.', 'wp_courseware')); $html .= '</td>'; $html .= '</tr>'; // ### 4) - Show the message form $html .= sprintf('<tr>'); // Label $html .= sprintf('<th>%s:<span class="wpcw_inner_hint">%s</span></th>', __('Custom Feedback Message', 'wp_courseware'), __('(Required) Enter the message to display to students when conditions above are met.'), 'test'); $html .= '<td>'; // Text area for message $html .= sprintf('<textarea name="%s" rows="7" class="wpcw_qcfm_sgl_message">%s</textarea>', $fieldPrefix . 'message' . $fieldSuffix, $this->feedbackMsgDetails->qfeedback_message); // Error message if incomplete $html .= sprintf('<span class="wpcw_quiz_custom_feedback_error">%s</span>', __('Please enter a helpful feedback message for the trainee.', 'wp_courseware')); $html .= '</td>'; $html .= '</tr>'; // ### 5) Show the footer with the delete icon $html .= sprintf('<tr class="wpcw_quiz_row_footer"> <td colspan="3" class="wpcw_question_actions"> <a href="#" class="wpcw_delete_icon" rel="%s">Delete</a> </td> </tr>', __('Are you sure you wish to delete this custom feedback message?', 'wp_courseware')); $html .= '</tbody></table></div>'; return $html; }
/** * Shows a list of tags and a button to filter the question pool by tag. * * @param String $currentTag The current tag that has been selected. * @param String $pageForURL The name of the page to show this form on (where page=WPCW_showPage_QuestionPool) * * @return String The HTML to render the tag filtering code. */ function WPCW_questions_tags_createTagFilter($currentTag, $pageForURL) { $html = sprintf('<div class="wpcw_questions_tag_filter_wrap"><form method="get" action="%s">', admin_url('admin.php?page=' . $pageForURL)); // Page that this form is being shown on. $html .= sprintf('<input type="hidden" name="page" value="%s" />', $pageForURL); // Select $html .= sprintf('<label for="wpcw_questions_tag_filter">%s</label>', __('Filter By:', 'wp_courseware')); $html .= WPCW_questions_tags_getTagDropdown(__('-- View All Tags --', 'wp_courseware'), 'filter', $currentTag, 'wpcw_questions_tag_filter'); // CTA $html .= sprintf('<input type="submit" class="button-secondary" value="%s" />', __('Filter', 'wp_courseware')); return $html . '</form></div>'; }