Skip to content

Commit

Permalink
Merge pull request #2651 from QuizandSurveyMaster/CU-85ztkvkek-qsm-ul…
Browse files Browse the repository at this point in the history
…timate-hooks

Fixed quiz links
  • Loading branch information
zubairraeen authored Sep 25, 2024
2 parents 5f557d4 + cc43606 commit 364acf7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 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, true );
if ( ( ! current_user_can( 'view_qsm_quiz_result' ) || intval($post_author) != get_current_user_id()) && ! current_user_can( 'edit_others_qsm_quizzes' ) ) {
return;
}

Expand Down
15 changes: 14 additions & 1 deletion php/admin/admin-results-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,20 @@ function qsm_results_overview_tab_content() {
?>
<tr>
<td><input type="checkbox" class="qmn_delete_checkbox" name="delete_results[]" value="<?php echo esc_attr( $quiz_infos[ $x ]->result_id ); ?>" /></td>
<td class="<?php echo apply_filters( 'qsm_results_quiz_name_class','', $quiz_infos[ $x ]->result_id ); ?>"><span style="font-size:16px;"><?php echo esc_html( $quiz_infos[ $x ]->quiz_name ); ?></span><div class="row-actions"><span style="color:green;font-size:16px;"><a href="admin.php?page=qsm_quiz_result_details&result_id=<?php echo esc_attr( $quiz_infos[ $x ]->result_id ); ?>"><?php esc_html_e( 'View Results', 'quiz-master-next' ); ?></a> | <a style="color: red;" class="delete_table_quiz_results_item" data-quiz-id="<?php echo esc_attr( $quiz_infos[ $x ]->result_id ); ?>" data-quiz-name="<?php echo esc_attr( $quiz_infos[ $x ]->quiz_name ); ?>" href='#'><?php esc_html_e( 'Delete', 'quiz-master-next' ); ?></a> | <a class="<?php echo esc_attr( $quiz_infos[ $x ]->proctor_report_class ); ?>" href='<?php echo esc_attr( $quiz_infos[ $x ]->proctor_report_link ); ?>'><?php esc_html_e( 'Proctor Reports', 'quiz-master-next' ); ?></a></span></div></td>
<td class="<?php echo apply_filters( 'qsm_results_quiz_name_class', '', $quiz_infos[ $x ]->result_id ); ?>">
<span style="font-size: 16px;"><?php echo esc_html( $quiz_infos[ $x ]->quiz_name ); ?></span>
<div class="row-actions">
<span style="color: green; font-size: 16px;">
<?php
if ( ( current_user_can( 'view_qsm_quiz_result' ) && $quiz_infos[ $x ]->user == get_current_user_id() ) || current_user_can( 'edit_others_qsm_quizzes' ) ) {
?>
<a href="admin.php?page=qsm_quiz_result_details&result_id=<?php echo esc_attr( $quiz_infos[ $x ]->result_id ); ?>"><?php esc_html_e( 'View Results', 'quiz-master-next' ); ?></a> |
<?php } ?>
<a style="color: red;" class="delete_table_quiz_results_item" data-quiz-id="<?php echo esc_attr( $quiz_infos[ $x ]->result_id ); ?>" data-quiz-name="<?php echo esc_attr( $quiz_infos[ $x ]->quiz_name ); ?>" href='#'><?php esc_html_e( 'Delete', 'quiz-master-next' ); ?></a> |
<a class="<?php echo esc_attr( $quiz_infos[ $x ]->proctor_report_class ); ?>" href='<?php echo esc_attr( $quiz_infos[ $x ]->proctor_report_link ); ?>'><?php esc_html_e( 'Proctor Reports', 'quiz-master-next' ); ?></a>
</span>
</div>
</td>
<?php
foreach ( $values as $k => $v ) {
if ( isset( $v['content'][ $x ] ) ) {
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 364acf7

Please sign in to comment.