view.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * This php script contains all the stuff to display iAssign.
  4. *
  5. * @author Patricia Alves Rodrigues
  6. * @author Leo^nidas O. Branda~o
  7. * @version v 1.0 2012/10/16
  8. * @package mod_iassign
  9. * @since 2010/09/27
  10. * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - Computer Science Dep. of IME-USP (Brazil)
  11. *
  12. * <b>License</b>
  13. * - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  14. */
  15. require_once("../../config.php");
  16. require_once("lib.php");
  17. require_once($CFG->libdir . '/completionlib.php');
  18. require_once($CFG->libdir . '/plagiarismlib.php');
  19. //DEBUG 2020/08/31
  20. //D require_once("ilm_debug/escreva.php"); //leo REMOVER! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  21. //D $resp = writeContent("", "", "todos_files_iassign.txt", "Teste"); // ($filetype1, $pathbase, $outputFile, $msgToRegister) //leo REMOVER!
  22. function get_all_iassign_files () {
  23. // Get all iAssign files on table 'files':
  24. // files = id; contenthash; pathnamehash; contextid; component; filearea; itemid; filepath; filename; userid; filesize; mimetype; status; source; author;
  25. // license; timecreated; timemodified; sortorder; referencefileid
  26. global $DB;
  27. // $all_files = $DB->get_records('files', array('component' => 'mod_iassign')); // pegar os do iAssign
  28. $indices = "id=257279 OR id=257791 OR id=258303 OR id=258559 OR id=127743 OR id=64767 OR id=65023 OR id= 65535 OR id= 87394 OR " .
  29. "id=138498 OR id=138506 OR id=138514 OR id=138522 OR id=50463 OR id=50464 OR id= 50465 OR id=138530 OR id= 50466 OR " .
  30. "id= 50467 OR id= 50468 OR id= 50469 OR id=50470 OR id=50471 OR id=104744 OR id=50472";
  31. $str_query = "SELECT * FROM {files} WHERE " . $indices . " ORDER BY timecreated DESC";
  32. $all_files = $DB->get_records_sql($str_query);
  33. $total = count($all_files);
  34. $msg = "#linhas = " . $total . "\n";
  35. foreach ($all_files as $linha) {
  36. foreach ($linha as $key => $value) {
  37. if ($key == "timecreated") {
  38. $time1 = date('Y-m-d H:i:s', $value - date('Z')); // 12:50:29
  39. $msg .= $time1 . ";" . $value . ";";
  40. }
  41. else
  42. if ($key == "source") {
  43. // $item = str_replace(";", "\;", $value);
  44. $item = addslashes($value);
  45. $msg .= "'" . addslashes($value) . "';";
  46. }
  47. else $msg .= $value . ";";
  48. }
  49. $msg .= "\n";
  50. }
  51. require_once("ilm_debug/escreva.php"); //leo REMOVER! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  52. $resp = writeContent("", "", "todos_files_iassign.csv", $msg); // ($filetype1, $pathbase, $outputFile, $msgToRegister) //leo REMOVER!
  53. }
  54. //D get_all_iassign_files(); //leo REMOVER! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  55. //D Remover todos itens de 'files' tal que: filesize = 0
  56. //Parameters GET e POST (parâmetros GET e POST)
  57. $id = optional_param('id', 0, PARAM_INT); // Course Module ID
  58. $a = optional_param('a', 0, PARAM_INT); // iAssign instance id (from table 'iassign')
  59. $mood_url = new moodle_url('/mod/iassign/view.php');
  60. if ($id) {
  61. // ./lib/datalib.php : function get_coursemodule_from_id($modulename, $cmid, $courseid=0, $sectionnum=false, $strictness=IGNORE_MISSING): returns 'course_modules.*' and 'modules.name'
  62. $cm = get_coursemodule_from_id('iassign', $id);
  63. if (!$cm) { // Moodle function 'get_coursemodule_from_id(...)' returns the object from table '*_iassign_statement'
  64. print_error('invalidcoursemodule');
  65. }
  66. $iassign = $DB->get_record("iassign", array("id" => $cm->instance));
  67. if (!$iassign) { // 'course_modules.instance = iassign.id'
  68. print_error('invalidid', 'iassign');
  69. }
  70. $course = $DB->get_record("course", array("id" => $iassign->course));
  71. if (!$course) {
  72. print_error('coursemisconf', 'iassign');
  73. }
  74. $mood_url->param('id', $id);
  75. }
  76. else {
  77. $iassign = $DB->get_record("iassign", array("id" => $a));
  78. if (!$iassign) {
  79. print_error('invalidid', 'iassign');
  80. }
  81. $course = $DB->get_record("course", array("id" => $iassign->course));
  82. if (!$course) {
  83. print_error('coursemisconf', 'iassign');
  84. }
  85. $cm = get_coursemodule_from_instance("iassign", $iassign->id, $course->id);
  86. if (!$cm) {
  87. print_error('invalidcoursemodule');
  88. }
  89. $mood_url->param('a', $a);
  90. }
  91. $PAGE->set_url($mood_url);
  92. require_login($course, true, $cm);
  93. $PAGE->set_title(format_string($iassign->name));
  94. $PAGE->set_heading($course->fullname);
  95. // Mark viewed by user (if required)
  96. $completion = new completion_info($course);
  97. $completion->set_module_viewed($cm);
  98. // About each object
  99. // - $iassing :: object from table '*_iassign_statement'
  100. // - $cm :: object from table '*_course_modules'
  101. // - $course :: object from table '*_course_modules_completion'
  102. $write_solution = 1;
  103. // locallib.php : class iassign : function __construct ($iassign, $cm, $course)
  104. //$iassigninstance = new iassign($iassign, $cm, $course, array('write_solution' => 1));
  105. $iassigninstance = new iassign($iassign, $cm, $course);
  106. // ./mod/iassign/locallib.php : in class iassign, actually who display the iAssign whose id is '$id'! (this function ignores parameters)
  107. $iassigninstance->view(); // will call $this->action(), that calls view_iassign_current()