Moodle plugin, allowing collaborative annotations in PDF files
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

128 lignes
4.5 KiB

  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. * @package mod_pdfannotator
  18. * @author Ahmad Obeid (ahmad.obeid@rwth-aachen.de), Rabea de Groot and Anna Heynkes (see README.md)
  19. * @copyright 2018 RWTH Aachen
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  21. *
  22. */
  23. defined('MOODLE_INTERNAL') || die();
  24. require_once('../../config.php');
  25. class mod_pdfannotator_renderer extends plugin_renderer_base {
  26. /**
  27. *
  28. * @param type $index
  29. * @return type
  30. */
  31. public function render_index($index) {
  32. return $this->render_from_template('pdfannotator/index', $index->export_for_template($this));
  33. }
  34. /**
  35. *
  36. * @param \templatable $statistic
  37. * @return type
  38. */
  39. public function render_statistic(\templatable $statistic) {
  40. $data = $statistic->export_for_template($this);
  41. return $this->render_from_template('mod_pdfannotator/statistic', $data);
  42. }
  43. /**
  44. * Render a table containing information about a comment the user wants to report
  45. *
  46. * @param pdfannotator_comment_info $info a renderable
  47. * @return string
  48. */
  49. public function render_pdfannotator_comment_info(pdfannotator_comment_info $info) {
  50. $o = '';
  51. $o .= $this->output->container_start('appointmentinfotable');
  52. $o .= $this->output->box_start('boxaligncenter appointmentinfotable');
  53. $t = new html_table();
  54. $row = new html_table_row();
  55. $cell1 = new html_table_cell(get_string('slotdatetimelabel', 'pdfannotator'));
  56. $cell2 = $info->datetime;
  57. $row->cells = array($cell1, $cell2);
  58. $t->data[] = $row;
  59. $row = new html_table_row();
  60. $cell1 = new html_table_cell(get_string('author', 'pdfannotator'));
  61. $cell2 = new html_table_cell($info->author);
  62. $row->cells = array($cell1, $cell2);
  63. $t->data[] = $row;
  64. $row = new html_table_row();
  65. $cell1 = new html_table_cell(get_string('comment', 'pdfannotator'));
  66. $cell2 = new html_table_cell($info->content);
  67. $row->cells = array($cell1, $cell2);
  68. $t->data[] = $row;
  69. $o .= html_writer::table($t);
  70. $o .= $this->output->box_end();
  71. $o .= $this->output->container_end();
  72. return $o;
  73. }
  74. /**
  75. * Construct a tab header.
  76. *
  77. * @param moodle_url $baseurl
  78. * @param string $namekey
  79. * @param string $what
  80. * @param string $subpage
  81. * @param string $nameargs
  82. * @return tabobject
  83. */
  84. private function pdfannotator_create_tab(moodle_url $baseurl, $namekey = null, $action,
  85. $pdfannotatorname = null, $nameargs = null) {
  86. $taburl = new moodle_url($baseurl, array('action' => $action));
  87. $tabname = get_string($namekey, 'pdfannotator', $nameargs);
  88. if ($pdfannotatorname) {
  89. strlen($pdfannotatorname) > 20 ? $tabname = substr($pdfannotatorname, 0, 21) . "..." : $tabname = $pdfannotatorname;
  90. }
  91. $id = $action;
  92. $tab = new tabobject($id, $taburl, $tabname);
  93. return $tab;
  94. }
  95. /**
  96. * Render the tab header hierarchy.
  97. *
  98. * @param moodle_url $baseurl
  99. * @param type $selected
  100. * @param type $pdfannotatorname
  101. * @param type $context
  102. * @param type $inactive
  103. * @return type
  104. */
  105. public function pdfannotator_render_tabs(moodle_url $baseurl, $selected = null, $pdfannotatorname, $context, $inactive = null) {
  106. $overviewtab = $this->pdfannotator_create_tab($baseurl, 'overview', 'overview');
  107. $level1 = array(
  108. $overviewtab,
  109. $this->pdfannotator_create_tab($baseurl, 'document', 'view', $pdfannotatorname),
  110. $this->pdfannotator_create_tab($baseurl, 'statistic', 'statistic'),
  111. $this->pdfannotator_create_tab($baseurl, 'feedback', 'feedback'),
  112. );
  113. return $this->tabtree($level1, $selected, $inactive);
  114. }
  115. }