Skip to content

Commit

Permalink
adjust add result function for import feature
Browse files Browse the repository at this point in the history
  • Loading branch information
randhirexpresstech committed Jul 1, 2024
1 parent 89c4ad0 commit e5a1b04
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,7 @@ public function qsm_get_quiz_to_reload() {
*
* @return boolean results added or not
*/
private function add_quiz_results( $data ) {
public function add_quiz_results( $data ) {
global $wpdb;
if ( empty( $wpdb ) || empty( $data['qmn_array_for_variables'] ) || empty( $data['results_array'] ) || empty( $data['unique_id'] ) || ! isset( $data['http_referer'] ) || ! isset( $data['form_type'] ) ) {
return false;
Expand All @@ -1883,6 +1883,9 @@ private function add_quiz_results( $data ) {
$wpdb->suppress_errors();

try {
if ( empty( $data['page_name'] ) ) {
$data['page_name'] = url_to_postid( $data['http_referer'] ) ? get_the_title( url_to_postid( $data['http_referer'] ) ) : '';
}
$res = $wpdb->insert(
$table_name,
array(
Expand All @@ -1902,11 +1905,11 @@ private function add_quiz_results( $data ) {
'time_taken' => $data['qmn_array_for_variables']['time_taken'],
'time_taken_real' => gmdate( 'Y-m-d H:i:s', strtotime( $data['qmn_array_for_variables']['time_taken'] ) ),
'quiz_results' => maybe_serialize( $data['results_array'] ),
'deleted' => 0,
'deleted' => ( isset( $data['deleted'] ) && 1 === intval( $data['deleted'] ) ) ? 1 : 0,
'unique_id' => $data['unique_id'],
'form_type' => $data['form_type'],
'page_url' => $data['http_referer'],
'page_name' => url_to_postid( $data['http_referer'] ) ? get_the_title( url_to_postid( $data['http_referer'] ) ) : '',
'page_name' => sanitize_text_field( $data['page_name'] ),
),
array(
'%d',
Expand Down

0 comments on commit e5a1b04

Please sign in to comment.