Fixed PHP error in Branding, added features to UM courses (4Q, show mark history…
…, update marks). refs #1079, refs #1044
Showing
4 changed files
with
135 additions
and
18 deletions
| ... | @@ -102,7 +102,7 @@ function swap_admin_menu_sections($from_section,$to_section) { | ... | @@ -102,7 +102,7 @@ function swap_admin_menu_sections($from_section,$to_section) { |
| 102 | $from_section = get_admin_menu_section($from_section); | 102 | $from_section = get_admin_menu_section($from_section); |
| 103 | if ($from_section) | 103 | if ($from_section) |
| 104 | $from_section->swap_with($to_section); | 104 | $from_section->swap_with($to_section); |
| 105 | return $section; | 105 | return $from_section; |
| 106 | } | 106 | } |
| 107 | function get_admin_menu_section($section) { | 107 | function get_admin_menu_section($section) { |
| 108 | if (!is_a($section,'WP_AdminMenuSection')) | 108 | if (!is_a($section,'WP_AdminMenuSection')) | ... | ... |
| 1 | function submitMark(e) { | ||
| 2 | if (e.keyCode == 27) { | ||
| 3 | document.getElementById(e.target.getAttribute('data-ref')).style.display = 'inline'; | ||
| 4 | e.target.parentNode.removeChild(e.target); | ||
| 5 | |||
| 6 | return; | ||
| 7 | } | ||
| 8 | |||
| 9 | if (e.keyCode == 13) { | ||
| 10 | jQuery.ajax({ | ||
| 11 | url: '/wp-admin/admin-ajax.php' | ||
| 12 | , data: {ajax: 'yes', action: 'update_mark', uid: user_id, course_id: e.target.getAttribute('data-course-id'), value: e.target.value} | ||
| 13 | , type: 'POST' | ||
| 14 | , dataType: 'json' | ||
| 15 | , success: function() { | ||
| 16 | var oLink = document.getElementById(e.target.getAttribute('data-ref')); | ||
| 17 | oLink.setAttribute('data-mark-value', e.target.value); | ||
| 18 | oLink.firstChild.nodeValue = e.target.value; | ||
| 19 | oLink.style.display = 'inline'; | ||
| 20 | |||
| 21 | e.target.parentNode.removeChild(e.target); | ||
| 22 | } | ||
| 23 | }); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 1 | function update_listing_preference() { | 27 | function update_listing_preference() { |
| 2 | var pref = jQuery('#profile_preference').val(); | 28 | var pref = jQuery('#profile_preference').val(); |
| 3 | if (pref == "Work") { | 29 | if (pref == "Work") { |
| ... | @@ -366,6 +392,34 @@ jQuery(function($) { | ... | @@ -366,6 +392,34 @@ jQuery(function($) { |
| 366 | return false; | 392 | return false; |
| 367 | }); | 393 | }); |
| 368 | 394 | ||
| 369 | 395 | jQuery('#TzFQActions input').click(function(e) { | |
| 396 | jQuery.ajax({ | ||
| 397 | url: '/wp-admin/admin-ajax.php' | ||
| 398 | , data: {ajax: 'yes', action: 'update_fq_status', uid: user_id, status: e.target.value} | ||
| 399 | , type: 'POST' | ||
| 400 | , dataType: 'json' | ||
| 401 | , success: function() { | ||
| 402 | jQuery("#Tz4QContainer").remove(); | ||
| 403 | } | ||
| 404 | }); | ||
| 405 | }); | ||
| 370 | 406 | ||
| 371 | }); | 407 | jQuery('#mark_history a[data-mark="editable"]').click(function(e) { |
| 408 | var oEdit = document.createElement('input'); | ||
| 409 | oEdit.type = 'text'; | ||
| 410 | oEdit.size = 3; | ||
| 411 | oEdit.value = e.target.getAttribute('data-mark-value'); | ||
| 412 | |||
| 413 | e.target.parentNode.appendChild(oEdit); | ||
| 414 | |||
| 415 | oEdit.setAttribute('data-ref', e.target.id); | ||
| 416 | oEdit.setAttribute('data-course-id', e.target.getAttribute('data-course-id')); | ||
| 417 | oEdit.focus(); | ||
| 418 | |||
| 419 | jQuery(oEdit).keydown(submitMark); | ||
| 420 | |||
| 421 | e.target.style.display = 'none'; | ||
| 422 | }).each(function(i, o) { | ||
| 423 | o.onclick = function() { return false; }; | ||
| 424 | }); | ||
| 425 | }); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -389,6 +389,7 @@ class AccountValidation extends Common\Validation { | ... | @@ -389,6 +389,7 @@ class AccountValidation extends Common\Validation { |
| 389 | return false; | 389 | return false; |
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | // here | ||
| 392 | foreach ($this->all_groups as $id => $one) { | 393 | foreach ($this->all_groups as $id => $one) { |
| 393 | if (isset($this->on_groups[$id])) { | 394 | if (isset($this->on_groups[$id])) { |
| 394 | UAM\getGroupByID($id)->addUser($_POST['uid']); | 395 | UAM\getGroupByID($id)->addUser($_POST['uid']); |
| ... | @@ -525,8 +526,32 @@ function run_validation() { | ... | @@ -525,8 +526,32 @@ function run_validation() { |
| 525 | Vars::$validation = new $class($_POST); | 526 | Vars::$validation = new $class($_POST); |
| 526 | return (count(Vars::$validation->errors) > 0 ? false : true); | 527 | return (count(Vars::$validation->errors) > 0 ? false : true); |
| 527 | } | 528 | } |
| 528 | 529 | ||
| 529 | class Actions { | 530 | class Actions { |
| 531 | public static function wp_ajax_update_mark() { | ||
| 532 | $account = new User\Account($_POST['uid']); | ||
| 533 | $marks = $account->marks; | ||
| 534 | |||
| 535 | $marks['history'][$_POST['course_id']]['mark'] = $_POST['value']; | ||
| 536 | |||
| 537 | update_user_meta($account->ID, 'marks', $marks); | ||
| 538 | } | ||
| 539 | |||
| 540 | public static function wp_ajax_update_fq_status() { | ||
| 541 | $return = Array('success' => 'false'); | ||
| 542 | $status = trim(strtolower($_POST['status'])); | ||
| 543 | $lookup = Array( | ||
| 544 | 'approve' => 'A' | ||
| 545 | , 'decline' => 'D' | ||
| 546 | ); | ||
| 547 | |||
| 548 | if (isset($lookup[$status])) { | ||
| 549 | update_user_meta($_POST['uid'], 'course_4q_approvals', $lookup[$status]); | ||
| 550 | $return['success'] = 'true'; | ||
| 551 | } | ||
| 552 | |||
| 553 | die(json_encode($return)); | ||
| 554 | } | ||
| 530 | 555 | ||
| 531 | public static function wp_ajax_update_edit_notes() { | 556 | public static function wp_ajax_update_edit_notes() { |
| 532 | global $wpdb; | 557 | global $wpdb; | ... | ... |
| ... | @@ -3,7 +3,7 @@ namespace Tz\WordPress\Tools\UserManager; | ... | @@ -3,7 +3,7 @@ namespace Tz\WordPress\Tools\UserManager; |
| 3 | use Tz, Tz\Common; | 3 | use Tz, Tz\Common; |
| 4 | use Tz\WordPress\Tools; | 4 | use Tz\WordPress\Tools; |
| 5 | use Tz\WordPress\CBV; | 5 | use Tz\WordPress\CBV; |
| 6 | use Tz\WordPress\CBV\Courses; | 6 | use Tz\WordPress\CBV\Courses, Tz\WordPress\CBV\Courses\Registration; |
| 7 | use Tz\WordPress\CBV\User; | 7 | use Tz\WordPress\CBV\User; |
| 8 | use Tz\WordPress\UAM; | 8 | use Tz\WordPress\UAM; |
| 9 | use WP_Query; | 9 | use WP_Query; |
| ... | @@ -27,20 +27,37 @@ use WP_Query; | ... | @@ -27,20 +27,37 @@ use WP_Query; |
| 27 | }; | 27 | }; |
| 28 | ?> | 28 | ?> |
| 29 | <div style="padding:10px 10px 0px 10px; min-width:760px;"> | 29 | <div style="padding:10px 10px 0px 10px; min-width:760px;"> |
| 30 | <!-- | 30 | <div id="Tz4QContainer"> |
| 31 | <?php if ($user->course_4q_approvals == 'P'): ?> | ||
| 31 | <h2>Security Question Status</h2> | 32 | <h2>Security Question Status</h2> |
| 32 | <p> | 33 | <ul> |
| 33 | 34 | <?php | |
| 35 | CBV\load('Courses\Registration'); | ||
| 36 | $four_questions = Registration\get_four_questions(); | ||
| 37 | foreach ($user->four_security_questions as $key => $yesno) { | ||
| 38 | if ($yesno == 1) { | ||
| 39 | echo "<li>Q: {$four_questions[$key]} (yes)</li>"; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | ?> | ||
| 43 | </ul> | ||
| 44 | |||
| 45 | <p style="padding: 0 1em;"><em>"<?php echo nl2br(htmlspecialchars($user->four_security_explanation)); ?>"</em></p> | ||
| 46 | |||
| 47 | <p id="TzFQActions"> | ||
| 48 | <input type="button" value=" Approve " /> | ||
| 49 | <input type="button" value=" Decline " /> | ||
| 34 | </p> | 50 | </p> |
| 35 | --> | 51 | <?php endif; ?> |
| 52 | </div> | ||
| 36 | 53 | ||
| 37 | <h2 style="margin-bottom:10px;padding-bottom:0px;">Courses</h2> | 54 | <h2 style="margin-bottom:10px;padding-bottom:0px;">Current Courses</h2> |
| 38 | 55 | ||
| 39 | <table class="clean-lines widefat post fixed"> | 56 | <table class="clean-lines widefat post fixed"> |
| 40 | <thead><tr> | 57 | <thead><tr> |
| 41 | <th>Course</th> | 58 | <th>Course</th> |
| 42 | <th>Type</th> | 59 | <th width="85">Type</th> |
| 43 | <th>Mark & Pass/Fail</th> | 60 | <th width="100">Latest Mark</th> |
| 44 | <th>Registration Deadline</th> | 61 | <th>Registration Deadline</th> |
| 45 | <th>Semester Runs</th> | 62 | <th>Semester Runs</th> |
| 46 | <th>Register</th> | 63 | <th>Register</th> |
| ... | @@ -59,7 +76,7 @@ use WP_Query; | ... | @@ -59,7 +76,7 @@ use WP_Query; |
| 59 | <td><?php echo get_post_meta(get_the_ID(), 'course_type', true); ?></td> | 76 | <td><?php echo get_post_meta(get_the_ID(), 'course_type', true); ?></td> |
| 60 | <td><?php echo $user->getMark(get_the_ID()); ?></td> | 77 | <td><?php echo $user->getMark(get_the_ID()); ?></td> |
| 61 | <td><?php echo $fn_cd(get_the_ID(), 'course_regi_close'); ?> | 78 | <td><?php echo $fn_cd(get_the_ID(), 'course_regi_close'); ?> |
| 62 | <td><?php echo $fn_cd(get_the_ID(), 'course_start') . ' - ' . $fn_cd(get_the_ID(), 'course_end'); ?></td> | 79 | <td><?php echo $fn_cd(get_the_ID(), 'course_start') . ' - ' . $fn_cd(get_the_ID(), 'course_end'); ?></td> |
| 63 | <td> | 80 | <td> |
| 64 | <?php if (isset($lookup[get_the_ID()]) && $lookup[get_the_ID()]->registrationOpen()): ?> | 81 | <?php if (isset($lookup[get_the_ID()]) && $lookup[get_the_ID()]->registrationOpen()): ?> |
| 65 | <?php if ($user->courseApprovalStatus($lookup[get_the_ID()]->getID()) == $user::CAS_APPROVED): ?> | 82 | <?php if ($user->courseApprovalStatus($lookup[get_the_ID()]->getID()) == $user::CAS_APPROVED): ?> |
| ... | @@ -77,10 +94,31 @@ use WP_Query; | ... | @@ -77,10 +94,31 @@ use WP_Query; |
| 77 | </tbody> | 94 | </tbody> |
| 78 | </table> | 95 | </table> |
| 79 | 96 | ||
| 80 | <?php /* | 97 | <h2>Course History</h2> |
| 81 | <pre><?php print_r(get_user_meta($_GET['uid'], 'courses_registered', true)); ?></pre> | 98 | <table class="clean-lines widefat post fixed" id="mark_history"> |
| 82 | <pre><?php print_r(get_user_meta($_GET['uid'], 'marks', true)); ?></pre> | 99 | <thead><tr> |
| 83 | <pre><?php print_r(get_user_meta($_GET['uid'], 'course_4q_approvals', true)); ?></pre> | 100 | <th>Course</th> |
| 84 | */ ?> | 101 | <th>Type</th> |
| 102 | <th>Mark</th> | ||
| 103 | <th>Semester</th> | ||
| 104 | <th>Date Achieved</th> | ||
| 105 | </tr></thead> | ||
| 106 | |||
| 107 | <tbody> | ||
| 108 | <?php | ||
| 109 | foreach ($user->marks['history'] as $data): | ||
| 110 | $course = new Courses\Course($data['course_id']); | ||
| 111 | ?> | ||
| 112 | <tr> | ||
| 113 | <td><?php echo $course->post_title; ?></td> | ||
| 114 | <td><?php echo $course->course_type; ?></td> | ||
| 115 | <td><a href="#" id="edit_mark_<?php echo $course->ID; ?>" data-mark="editable" data-course-id="<?php echo $course->ID; ?>" data-mark-value="<?php echo $data['mark']; ?>"><?php echo $data['mark']; ?></a></td> | ||
| 116 | <td><?php echo $course->semester_id; ?></td> | ||
| 117 | <td><?php echo date('Y-m-d', $data['added']); ?></td> | ||
| 118 | </tr> | ||
| 119 | <?php endforeach; ?> | ||
| 120 | </tbody> | ||
| 121 | </table> | ||
| 122 | |||
| 85 | </div> | 123 | </div> |
| 86 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> | 124 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment