| 1 |
<style type="text/css"> |
| 2 |
<?php watu_resp_table_css(800);?> |
| 3 |
|
| 4 |
tr.watu-sortable-question { |
| 5 |
cursor:move; |
| 6 |
} |
| 7 |
</style> |
| 8 |
|
| 9 |
<div class="wrap"> |
| 10 |
<h2><?php printf(__("Manage Questions in %s", 'watu'), $exam_name); ?></h2> |
| 11 |
|
| 12 |
<div class="postbox-container" style="min-width:60%;max-width:75%;margin-right:2%;"> |
| 13 |
|
| 14 |
<p><a href="admin.php?page=watu_exams"><?php printf(__('Back to %s', 'watu'), WATU_QUIZ_WORD_PLURAL)?></a> |
| 15 |
| <a href="admin.php?page=watu_exam&quiz=<?php echo intval($_GET['quiz'])?>&action=edit"><?php printf(__('Edit this %s', 'watu'), WATU_QUIZ_WORD)?></a> |
| 16 |
| <a href="admin.php?page=watu_grades&quiz_id=<?php echo intval($_GET['quiz'])?>"><?php _e('Manage Grades / Results', 'watu')?></a> |
| 17 |
| <a href="admin.php?page=watu_import_questions&quiz_id=<?php echo intval($_GET['quiz'])?>"><?php _e('Import Questions', 'watu');?></a></p> |
| 18 |
|
| 19 |
<?php |
| 20 |
wp_enqueue_script( 'listman' ); |
| 21 |
wp_print_scripts(); |
| 22 |
?> |
| 23 |
|
| 24 |
<p style="color:green;"><?php printf(__('To add this %s to your blog, insert the code ', 'watu'), WATU_QUIZ_WORD); ?> <input type="text" readonly size="8" onclick="this.select();" value="[WATU <?php echo intval($_REQUEST['quiz']) ?>]"> <?php _e('into any post or page.', 'watu') ?></p> |
| 25 |
|
| 26 |
<form method="get" action="admin.php"> |
| 27 |
<input type="hidden" name="page" value="watu_questions"> |
| 28 |
<input type="hidden" name="quiz" value="<?php echo intval($_GET['quiz'])?>"> |
| 29 |
<p><?php _e('Show questions of type:', 'watu');?> |
| 30 |
<select name="filter_answer_type"> |
| 31 |
<option value=""><?php _e('All types', 'watu');?></option> |
| 32 |
<option value="radio" <?php if(!empty($_GET['filter_answer_type']) and $_GET['filter_answer_type'] == 'radio') echo 'selected'?>><?php _e('Single choice', 'watu');?></option> |
| 33 |
<option value="textarea" <?php if(!empty($_GET['filter_answer_type']) and $_GET['filter_answer_type'] == 'textarea') echo 'selected'?>><?php _e('Open end (essay)', 'watu');?></option> |
| 34 |
<option value="checkbox" <?php if(!empty($_GET['filter_answer_type']) and $_GET['filter_answer_type'] == 'checkbox') echo 'selected'?>><?php _e('Multiple choice', 'watu');?></option> |
| 35 |
</select> |
| 36 |
|
| 37 |
<?php _e('from category', 'watu');?> |
| 38 |
|
| 39 |
<select name="filter_cat"> |
| 40 |
<option value=""><?php _e('All categories', 'watu');?></option> |
| 41 |
<?php foreach($cats as $cat):?> |
| 42 |
<option value="<?php echo $cat->ID;?>" <?php if(!empty($_GET['filter_cat']) and $_GET['filter_cat'] == $cat->ID) echo 'selected';?>><?php echo stripslashes($cat->name);?></option> |
| 43 |
<?php endforeach;?> |
| 44 |
<option value="-1" <?php if(!empty($_GET['filter_cat']) and $_GET['filter_cat'] == -1) echo 'selected';?>><?php _e('Uncategorized', 'watu');?></option> |
| 45 |
</select> |
| 46 |
|
| 47 |
|
| 48 |
<?php _e('with ID (you can separate multiple IDs with comma):', 'watu')?> <input type="text" name="filter_id" value="<?php echo empty($_GET['filter_id']) ? 0 : intval($_GET['filter_id'])?>" size="6"> |
| 49 |
<br> |
| 50 |
<?php _e('and question contains (phrase):', 'watu');?> <input type="text" name="filter_contents" value="<?php echo empty($_GET['filter_contents']) ? '' : esc_attr($_GET['filter_contents'])?>"> |
| 51 |
|
| 52 |
<input type="submit" value="<?php _e('Filter questions', 'watu')?>" class="button-primary"> |
| 53 |
<input type="button" class="button" value="<?php _e('Clear filters', 'watu');?>" onclick="window.location='admin.php?page=watu_questions&quiz=<?php echo intval($_GET['quiz'])?>';"></p> |
| 54 |
|
| 55 |
<p><?php _e('Questions per page:', 'watu');?> <select name="page_limit" onchange="this.form.submit();"> |
| 56 |
<option value="10" <?php if($page_limit == 10) echo 'selected';?>>10</option> |
| 57 |
<option value="20" <?php if($page_limit == 20) echo 'selected';?>>20</option> |
| 58 |
<option value="50" <?php if($page_limit == 50) echo 'selected';?>>50</option> |
| 59 |
<option value="100" <?php if($page_limit == 100) echo 'selected';?>>100</option> |
| 60 |
<option value="200" <?php if($page_limit == 200) echo 'selected';?>>200</option> |
| 61 |
<option value="500" <?php if($page_limit == 500) echo 'selected';?>>500</option> |
| 62 |
</select></p> |
| 63 |
</form> |
| 64 |
|
| 65 |
<form method="post"> |
| 66 |
<table class="widefat watu-table"> |
| 67 |
<thead> |
| 68 |
<tr> |
| 69 |
<th><input type="checkbox" onclick="WatuSelectAll(this);"></th> |
| 70 |
<th scope="col"><div style="text-align: center;"><a href="admin.php?page=watu_questions&quiz=<?php echo intval($_GET['quiz'])?>&fix_sort_order=1" title="<?php _e('Click here to automatically fix the order of questions.', 'watu')?>">#</a></div></th> |
| 71 |
<th scope="col"><?php _e('ID', 'watu') ?></th> |
| 72 |
<th scope="col"><?php _e('Question', 'watu') ?></th> |
| 73 |
<th scope="col"><?php _e('Question type', 'watu') ?></th> |
| 74 |
<th scope="col"><?php _e('Category', 'watu') ?></th> |
| 75 |
<th scope="col"><?php _e('Required?', 'watu') ?></th> |
| 76 |
<th scope="col"><?php _e('Number Of Answers', 'watu') ?></th> |
| 77 |
<th scope="col" colspan="3"><?php _e('Action', 'watu') ?></th> |
| 78 |
</tr> |
| 79 |
</thead> |
| 80 |
|
| 81 |
<tbody id="watuQuestionsList"> |
| 82 |
<?php |
| 83 |
|
| 84 |
|
| 85 |
if (count($all_question)) { |
| 86 |
$bgcolor = ''; |
| 87 |
$question_count = 0; |
| 88 |
foreach($all_question as $question) { |
| 89 |
if(empty($class)) $class = 'alternate'; |
| 90 |
else $class = ''; |
| 91 |
$question_count++; |
| 92 |
print "<tr id='question-{$question->ID}' class='$class watu-sortable-question'>\n"; |
| 93 |
?> |
| 94 |
<td><input type="checkbox" name="qids[]" value="<?php echo $question->ID?>" class="qids" onclick="toggleMassDelete();"></td> |
| 95 |
<td style="text-align: center;"> |
| 96 |
<div style='float:left;<?php if(!empty($_POST['filter_cat_id'])) echo 'display:none;'?>'> |
| 97 |
|
| 98 |
</div> |
| 99 |
<?php echo $question_count ?></td> |
| 100 |
<td><?php echo $question->ID;?></td> |
| 101 |
<td><?php echo stripslashes($question->question) ?></td> |
| 102 |
<td><?php switch($question->answer_type): |
| 103 |
case 'radio': _e('Single choice', 'watu'); break; |
| 104 |
case 'checkbox': _e('Multiple choice', 'watu'); break; |
| 105 |
case 'textarea': _e('Open end (essay)', 'watu'); break; |
| 106 |
endswitch; |
| 107 |
if($question->is_inactive) echo " <span style='color:red'>".__('Inactive', 'watu')."</span> ";?></td> |
| 108 |
<td><?php echo $question->cat_id ? stripslashes($question->cat) : __('Uncategorized', 'watu');?></td> |
| 109 |
<td><?php echo $question->is_required ? __('Yes', 'watu') : __('No', 'watu');?></td> |
| 110 |
<td><?php echo $question->answer_count ?></td> |
| 111 |
<td><a href='admin.php?page=watu_question&question=<?php echo $question->ID?>&action=edit&quiz=<?php echo intval($_REQUEST['quiz'])?>' class='edit'><?php _e('Edit', 'watu'); ?></a></td> |
| 112 |
<td><a href="<?php echo wp_nonce_url('admin.php?page=watu_questions&action=delete&question='.$question->ID.'&quiz='.intval($_REQUEST['quiz']), 'watu_questions');?>" class='delete' onclick="return confirm('<?php echo addslashes(__("You are about to delete this question. This will delete the answers to this question. Press 'OK' to delete and 'Cancel' to stop.", 'watu'))?>');"><?php _e('Delete', 'watu')?></a></td> |
| 113 |
</tr> |
| 114 |
<?php |
| 115 |
} |
| 116 |
} else { |
| 117 |
?> |
| 118 |
<tr style='background-color: <?php echo @$bgcolor; ?>;'> |
| 119 |
<td colspan="4"><?php _e('No questions found.', 'watu') ?></td> |
| 120 |
</tr> |
| 121 |
<?php |
| 122 |
} |
| 123 |
?> |
| 124 |
</tbody> |
| 125 |
</table> |
| 126 |
|
| 127 |
<a href="admin.php?page=watu_question&action=new&quiz=<?php echo intval($_REQUEST['quiz']) ?>"><?php _e('Create New Question', 'watu')?></a> |
| 128 |
|
| 129 |
<p align="center"><?php if($offset>0):?><a href="admin.php?page=watu_questions&quiz=<?php echo $quiz_id;?>&offset=<?php echo ($offset-$page_limit)?><?php echo $filter_params?>"><?php _e('Previous page', 'watu')?></a><?php endif;?> |
| 130 |
|
| 131 |
<?php if($offset + $page_limit < $count):?> <a href="admin.php?page=watu_questions&quiz=<?php echo $quiz_id;?>&offset=<?php echo ($offset+$page_limit)?><?php echo $filter_params?>"><?php _e('Next page', 'watu')?></a> <?php endif;?></p> |
| 132 |
|
| 133 |
<div align="center" style="display:none;" id="massDeleteQuesions"><p align="center"> |
| 134 |
<input type="submit" name="mass_delete" onclick="if(!confirm('<?php _e('Are you sure?', 'watu')?>')) return false;" value="<?php _e('Delete Selected', 'watu')?>" class="button"><p> |
| 135 |
<h3 align="center"><?php _e('Other Mass Changes:', 'watu');?></h3> |
| 136 |
<p><?php _e('Change properties of selected questions:', 'watu');?> <select name="is_required"> |
| 137 |
<option value="-1"><?php _e("Don't change required status", 'watu');?></option> |
| 138 |
<option value="1"><?php _e('Change all to required', 'watu');?></option> |
| 139 |
<option value="0"><?php _e('Change all to not required', 'watu');?></option> |
| 140 |
</select> |
| 141 |
|
| 142 |
|
| 143 |
<input type="submit" name="mass_update" value="<?php _e('Update Selected', 'watu');?>" class="button-primary"></p> |
| 144 |
<?php wp_nonce_field('watu_questions');?> |
| 145 |
</div> |
| 146 |
|
| 147 |
<p style="display:none;color:red;text-align:center;font-weight:bold;" id="watuSaveOrderBtn"> |
| 148 |
<?php _e('When done with reordering press the button to save:', 'watu');?> |
| 149 |
|
| 150 |
<input type="button" class="button button-primary" value="<?php _e('Save New Questions Order', 'watu');?>" onclick="WatuReorderQuestions();"> |
| 151 |
</p> |
| 152 |
<p style="display:none;color:green;text-align:center;font-weight:bold;" id="watuSaveOrderBtnMsg"> |
| 153 |
<?php _e('Questions order saved.', 'watu');?> |
| 154 |
</p> |
| 155 |
|
| 156 |
</form> |
| 157 |
</div> |
| 158 |
<div id="watu-sidebar"> |
| 159 |
<?php include(WATU_PATH."/views/sidebar.php");?> |
| 160 |
</div> |
| 161 |
</div> |
| 162 |
|
| 163 |
<script type="text/javascript"> |
| 164 |
function WatuSelectAll(chk) { |
| 165 |
if(chk.checked) { |
| 166 |
jQuery(".qids").attr('checked',true); |
| 167 |
} |
| 168 |
else { |
| 169 |
jQuery(".qids").removeAttr('checked'); |
| 170 |
} |
| 171 |
|
| 172 |
toggleMassDelete(); |
| 173 |
} |
| 174 |
|
| 175 |
// shows or hides the mass delete button |
| 176 |
function toggleMassDelete() { |
| 177 |
var len = jQuery(".qids:checked").length; |
| 178 |
|
| 179 |
if(len) jQuery('#massDeleteQuesions').show(); |
| 180 |
else jQuery('#massDeleteQuesions').hide(); |
| 181 |
} |
| 182 |
|
| 183 |
jQuery(function(){ |
| 184 |
jQuery('#watuQuestionsList').sortable({ |
| 185 |
stop: function(event, ui) { |
| 186 |
jQuery('#watuSaveOrderBtn').show(); |
| 187 |
jQuery('#watuSaveOrderBtnMsg').hide(); |
| 188 |
} |
| 189 |
}); |
| 190 |
}); |
| 191 |
|
| 192 |
function WatuReorderQuestions() { |
| 193 |
// to avoid sending many unnecessary queries to the server |
| 194 |
var questions = jQuery('#watuQuestionsList').sortable("toArray"); |
| 195 |
|
| 196 |
data = {"action":'watu_reorder_questions', 'exam_id' : <?php echo intval($_GET['quiz']);?>, 'questions' : questions, 'watu_nonce': watu_i18n.watu_nonce }; |
| 197 |
|
| 198 |
jQuery.post("<?php echo admin_url( 'admin-ajax.php' ); ?>", data, function(msg){ |
| 199 |
jQuery('#watuSaveOrderBtn').hide(); |
| 200 |
jQuery('#watuSaveOrderBtnMsg').show(); |
| 201 |
}); |
| 202 |
} |
| 203 |
|
| 204 |
<?php watu_resp_table_js();?> |
| 205 |
</script> |