reports_cert_and_dip.php 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * enrol_teacherskey file description here.
  18. *
  19. * @package enrol_teacherskey
  20. * @copyright 2022 alex sidorov <alex.sidorof@ya.ru>
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. require_once(__DIR__ . '/../../config.php');
  24. require "$CFG->libdir/tablelib.php";
  25. $userid = optional_param('userid', 0, PARAM_INT);
  26. $download = optional_param('download', '', PARAM_ALPHA);
  27. $user = \core_user::get_user($userid ?: $USER->id, '*', MUST_EXIST);
  28. if(isset($_GET['courseid'])){
  29. $courseid = $_GET['courseid'];
  30. }else{
  31. redirect($CFG->wwwroot . "/my");
  32. }
  33. $context= \context_course::instance($courseid);
  34. $PAGE->set_context($context);
  35. $PAGE->set_url(new moodle_url('/local/olimp_reports/reports_cert_and_dip.php'));
  36. $table = new \enrol_teacherskey\output\listteachers('teacherskey');
  37. $name_downloadfile = "reports_olimp-".date('Y-m-d');
  38. $table->is_downloading($download, '$name_downloadfile', 'reports_olimp');
  39. //
  40. //echo breadcrumbs
  41. $course = get_course($courseid);
  42. if (!$table->is_downloading()){
  43. $PAGE->set_pagelayout('standard');
  44. $PAGE->set_title(get_string('reports_olimp', 'local_olimp_reports'));
  45. $PAGE->set_heading(get_string('reports_olimp', 'local_olimp_reports'));
  46. $PAGE->navbar->add(get_string('courses'), new moodle_url('/course/index.php'));
  47. $PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', ['id' => $courseid]));
  48. $PAGE->navbar->add(get_string('reports_olimp', 'local_olimp_reports'), new moodle_url("/local/olimp_reports/reports_cert_and_dip.php", ['courseid' => $courseid]));
  49. echo $OUTPUT->header(get_string('reports_olimp', 'local_olimp_reports'));
  50. }
  51. $fields = "mtd.userid as id, concat(tu.lastname, ' ', tu.firstname, ' ', tu.middlename) as fullname,
  52. tu.email as email,
  53. (select data from mdl_user_info_data where userid=mtd.userid and fieldid=2) as name_obr,
  54. (select data from mdl_user_info_data where userid=mtd.userid and fieldid=1) as place_obr,
  55. round(mgg.finalgrade) as ball,
  56. mtct.name as dip_or_sap,
  57. (select data from mdl_user_info_data where userid=mtd.userid and fieldid=3) as fio,
  58. date(to_timestamp(mtci.timecreated)) as gdate,
  59. mtci.code as kod";
  60. $from = "{teacherskey_data} mtd
  61. inner join {grade_items} mgi on mgi.courseid=mtd.courseid and mgi.itemmodule = 'quiz'
  62. inner join {grade_grades} mgg on mgg.userid=mtd.userid and mgg.itemid=mgi.id
  63. inner join {user} tu on tu.id = mtd.userid
  64. inner join {course} mc on mc.id = mtd.courseid
  65. inner join {tool_certificate_issues} mtci on mtci.userid = mtd.userid
  66. inner join {tool_certificate_templates} mtct on mtct.id = mtci.templateid";
  67. $where = 'mtd.courseid = :courseid';
  68. $params = array('courseid' => $courseid);
  69. $table->set_sql($fields, $from, $where, $params);
  70. $table->define_baseurl(new moodle_url("/local/olimp_reports/reports_cert_and_dip.php", ['courseid' => $courseid]));
  71. $table->out(10, true);
  72. if (!$table->is_downloading()) {
  73. echo $OUTPUT->footer();
  74. }