Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Customizing Stat Report
Tagged: customized stat report
- This topic has 7 replies, 3 voices, and was last updated 8 years ago by H.K. Latiyan.
Viewing 8 posts - 1 through 8 (of 8 total)
-
AuthorPosts
-
February 28, 2016 at 3:22 am #32695kamranSpectatorHello, 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, KamranFebruary 29, 2016 at 9:09 am #32832H.K. LatiyanParticipantMarch 2, 2016 at 2:35 am #33226kamranSpectatorMarch 2, 2016 at 2:43 am #33228kamranSpectatorThanks, 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.March 2, 2016 at 3:18 am #33231kamranSpectatorAlso this is for Course Stat download. I tried it and still does not see email for instance in the downloaded CSV downloaded file.March 2, 2016 at 2:42 pm #33366Anshuman SahuKeymasterI 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/March 31, 2016 at 2:20 am #39898kamranSpectatorI 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.March 31, 2016 at 12:32 pm #40052H.K. LatiyanParticipantI 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; } }
-
AuthorPosts
Viewing 8 posts - 1 through 8 (of 8 total)
- The topic ‘Customizing Stat Report’ is closed to new replies.