function opigno_lrs_stats_course_content_avg_score in Opigno TinCan API 7
Calculate average score for all course contents
Parameters
string $statement_filter_function: Function to use as statement filter
Return value
int
1 call to opigno_lrs_stats_course_content_avg_score()
- opigno_lrs_stats_course_content_general_statistics in modules/
opigno_tincan_api_stats/ includes/ course_content/ model.inc - Present general statistics
File
- modules/
opigno_tincan_api_stats/ includes/ course_content/ model.inc, line 58 - Courses model functions
Code
function opigno_lrs_stats_course_content_avg_score($statement_filter_function = NULL) {
$total_score = 0;
$passed_statements = isset($statement_filter_function) ? $statement_filter_function(opigno_lrs_stats_all_course_content_passed_statements()) : opigno_lrs_stats_all_course_content_passed_statements();
$failed_statements = isset($statement_filter_function) ? $statement_filter_function(opigno_lrs_stats_all_course_content_failed_statements()) : opigno_lrs_stats_all_course_content_failed_statements();
$finished_statements = array_merge($passed_statements, $failed_statements);
$finished_statements_with_score = opigno_lrs_stats_filter_finished_statements_with_score($finished_statements);
$total_score += array_sum(opigno_lrs_stats_map_finished_statement_scores($finished_statements_with_score));
$number_of_score = count($finished_statements);
return $number_of_score > 0 ? round($total_score / $number_of_score * 100, 0) : 0;
}