Customizing Stat Report

Home Forums Legacy Support Support queries How-to & Troubleshooting Customizing Stat Report

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #32695
    kamran
    Spectator
    Hello, I would like to customize the info that is downloaded in stat report. I just need to add three more columns as following: First name Last Name Email Could you please let me know how these three can be added to the list of stat info so it can be downloaded as part of the stat report? Thanks a lot, Kamran  
    #32832
    H.K. Latiyan
    Participant
    #33226
    kamran
    Spectator
       
    #33228
    kamran
    Spectator
    Thanks, It seems that the link is focused on quiz. I understand that it would be similar for stat report. The post does not show any description on how we can make it specific to our needs. It is just a bunch of code for email in quiz stat download. Could you please let me know how I can modify the code for my purpose (adding student's first name, student's last name, and student email). For instance for student's first name, what should change in the attached code? What about student's last name? An example with my case would be great.  
    #33231
    kamran
    Spectator
    Also this is for Course Stat download. I tried it and still does not see email for instance in the downloaded CSV downloaded file.
    #33366
    Anshuman Sahu
    Keymaster
    I guess there has been some misunderstanding there . Please refer this tip to add custom fields in course stats : https://wplms.io/support/knowledge-base/add-custom-user-field-in-download-course-stats/
    #39898
    kamran
    Spectator
    I still have not figured this out. When I add the code you suggest in the link above, I get a 500 error. When I remove that from PHP file, then everything goes back to normal. I am really confused and I need to figure this out for creating a custom report for our corporate client. I would like to add First Name, Last Name, Email, and Country/Location to the list of downloadable stats. I really appreciate your help on this.
    #40052
    H.K. Latiyan
    Participant
    I think you have added both the codes in that tip: Let me make it clear for you. If you want to add only one field then add just this code to the wplms-customizer.php file in your wplms customizer plugin: add_filter('wplms_course_stats_list','add_custom_course_stat'); add_action('wplms_course_stats_process','process_custom_course_stat',10,6); function add_custom_course_stat($list){   $list['user_field']= 'Location';   return $list; } function process_custom_course_stat(&$csv_title, &$csv,&$i,&$course_id,&$user_id,&$field){   if($field != 'user_field') // Ensures the field was checked.      return;   $title=__('Location','vibe');   if(!in_array($title,$csv_title))     $csv_title[$i]=$title;   $ifield = 'Location';    if(bp_is_active('xprofile'))    $field_val= bp_get_profile_field_data( 'field='.$ifield.'&user_id=' .$user_id );   if(isset($field_val) && $field_val)     $csv[$i][]= $field_val;   else     $csv[$i][]= 'N.A';  } Now if you want to add multiple fields then do not use the above code and use only the code below: add_filter('wplms_course_stats_list','add_custom_course_stat'); add_action('wplms_course_stats_process','process_custom_course_stat',10,6); function add_custom_course_stat($list){   $new_list = array(                     'user_field1'=>'Location',                     'user_field2'=>'Bio'                      );        $list=array_merge($list,$new_list);     return $list; }           function process_custom_course_stat(&$csv_title, &$csv,&$i,&$course_id,&$user_id,&$field){   if( strpos($field, 'user_field1') === false &&  strpos($field, 'user_field2') === false)       return;   if($field == 'user_field1'){    $title=__('Location','vibe');     if(!in_array($title,$csv_title))       $csv_title[$i]=$title;     $ifield = 'Location';     if(bp_is_active('xprofile'))      $field_val= bp_get_profile_field_data( 'field='.$ifield.'&user_id=' .$user_id );                 if(isset($field_val) && $field_val)       $csv[$i][]= $field_val;     else       $csv[$i][]= 'N.A';       return;    }    if($field == 'user_field2'){        $title=__('Bio','vibe');     if(!in_array($title,$csv_title))       $csv_title[$i]=$title;     $ifield = 'Bio';       if(bp_is_active('xprofile'))      $field_val= bp_get_profile_field_data( 'field='.$ifield.'&user_id=' .$user_id );                 if(isset($field_val) && $field_val)       $csv[$i][]= $field_val;     else       $csv[$i][]= 'N.A';       return;    } }
Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Customizing Stat Report’ is closed to new replies.