X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=blobdiff_plain;f=mod%2Flesson%2Flocallib.php;h=125397975c5e24bb49a0429bbccef20711d1ea0c;hp=82560041fee07d0278d79df8e5061e0888878cb2;hb=ea8b25c51fc7cf7d5ff40d3a6187023d733ce81d;hpb=b4b61be922b7532af4df31b713366c5745fdb0a5 diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index 82560041fee..125397975c5 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -704,10 +704,12 @@ function lesson_get_overview_report_table_and_data(lesson $lesson, $currentgroup list($esql, $params) = get_enrolled_sql($context, '', $currentgroup, true); list($sort, $sortparams) = users_order_by_sql('u'); + $extrafields = get_extra_user_fields($context); + $params['a1lessonid'] = $lesson->id; $params['b1lessonid'] = $lesson->id; $params['c1lessonid'] = $lesson->id; - $ufields = user_picture::fields('u'); + $ufields = user_picture::fields('u', $extrafields); $sql = "SELECT DISTINCT $ufields FROM {user} u JOIN ( @@ -895,16 +897,35 @@ function lesson_get_overview_report_table_and_data(lesson $lesson, $currentgroup $table = new html_table(); + $headers = [get_string('name')]; + + foreach ($extrafields as $field) { + $headers[] = get_user_field_name($field); + } + + $headers [] = get_string('attempts', 'lesson'); + // Set up the table object. if ($data->lessonscored) { - $table->head = array(get_string('name'), get_string('attempts', 'lesson'), get_string('highscore', 'lesson')); - } else { - $table->head = array(get_string('name'), get_string('attempts', 'lesson')); + $headers [] = get_string('highscore', 'lesson'); + } + + $colcount = count($headers); + + $table->head = $headers; + + $table->align = []; + $table->align = array_pad($table->align, $colcount, 'center'); + $table->align[$colcount - 1] = 'left'; + + if ($data->lessonscored) { + $table->align[$colcount - 2] = 'left'; } - $table->align = array('center', 'left', 'left'); - $table->wrap = array('nowrap', 'nowrap', 'nowrap'); + + $table->wrap = []; + $table->wrap = array_pad($table->wrap, $colcount, 'nowrap'); + $table->attributes['class'] = 'standardtable generaltable'; - $table->size = array(null, '70%', null); // print out the $studentdata array // going through each student that has attempted the lesson, so, each student should have something to be displayed @@ -991,14 +1012,21 @@ function lesson_get_overview_report_table_and_data(lesson $lesson, $currentgroup } // get line breaks in after each attempt $attempts = implode("
\n", $attempts); + $row = [$studentname]; + + foreach ($extrafields as $field) { + $row[] = $student->$field; + } + + $row[] = $attempts; if ($data->lessonscored) { // Add the grade if the lesson is graded. - $table->data[] = array($studentname, $attempts, $bestgrade . "%"); - } else { - // This lesson does not have a grade. - $table->data[] = array($studentname, $attempts); + $row[] = $bestgrade."%"; } + + $table->data[] = $row; + // Add the student data. $dataforstudent->id = $student->id; $dataforstudent->fullname = $studentname;