Skip to content

Commit

Permalink
Fixed quiz links
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-pranav committed Sep 25, 2024
1 parent 60b3e81 commit 968cf0a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions php/admin/admin-results-details-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ function qsm_generate_results_details_tab() {
$quiz_id = intval( $results_data->quiz_id );
$mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz_id );

$quiz_post_id = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'quiz_id' AND meta_value = '$quiz_id'" );
if ( empty( $quiz_post_id ) || ! current_user_can( 'edit_qsm_quiz', $quiz_post_id ) ) {
$quiz_post_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'quiz_id' AND meta_value = %d", $quiz_id ) );
$post_author = get_post_field( 'post_author', $quiz_post_id );
if ( ( current_user_can( 'view_qsm_quiz_result' ) && $post_author == get_current_user_id() ) || ! current_user_can( 'edit_others_qsm_quizzes' ) ) {
return;
}

Expand Down
8 changes: 4 additions & 4 deletions php/admin/quizzes-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,16 @@ public function qsm_post_row_actions( $actions, $post ) {
$quiz_id = get_post_meta( $post->ID, 'quiz_id', true );
if ( ! empty( $quiz_id ) ) {
$actions = array();
if ( current_user_can( 'edit_qsm_quiz', $post->ID ) ) {
if ( ( current_user_can( 'edit_qsm_quiz', $post->ID ) && $post->post_author == get_current_user_id() ) || current_user_can( 'edit_others_qsm_quizzes' ) ) {
$actions['edit'] = '<a class="qsm-action-link" href="admin.php?page=mlw_quiz_options&quiz_id=' . esc_attr( $quiz_id ) . '">' . esc_html__( 'Edit', 'quiz-master-next' ) . '</a>';
}
if ( current_user_can( 'duplicate_qsm_quiz', $post->ID ) ) {
if ( ( current_user_can( 'duplicate_qsm_quiz', $post->ID ) && $post->post_author == get_current_user_id() ) || current_user_can( 'edit_others_qsm_quizzes' ) ) {
$actions['duplicate'] = '<a class="qsm-action-link qsm-action-link-duplicate" href="#" data-id="' . esc_attr( $quiz_id ) . '">' . esc_html__( 'Duplicate', 'quiz-master-next' ) . '</a>';
}
if ( current_user_can( 'delete_published_qsm_quizzes' ) ) {
if ( ( current_user_can( 'delete_qsm_quiz', $post->ID ) && $post->post_author == get_current_user_id() ) || current_user_can( 'delete_others_qsm_quizzes' ) ) {
$actions['delete'] = '<a class="qsm-action-link qsm-action-link-delete" href="#" data-id="' . esc_attr( $quiz_id ) . '" data-name="' . esc_attr( $post->post_title ) . '">' . esc_html__( 'Delete', 'quiz-master-next' ) . '</a>';
}
if ( current_user_can( 'view_qsm_quiz_result' ) ) {
if ( ( current_user_can( 'view_qsm_quiz_result' ) && $post->post_author == get_current_user_id() ) || current_user_can( 'edit_others_qsm_quizzes' ) ) {
$actions['view_result'] = '<a class="qsm-action-link" href="admin.php?page=mlw_quiz_results&quiz_id=' . esc_attr( $quiz_id ) . '">' . esc_html__( 'View Results', 'quiz-master-next' ) . '</a>';
}
if ( empty( $settings['disable_quiz_public_link'] ) ) {
Expand Down

0 comments on commit 968cf0a

Please sign in to comment.