-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit.php~
130 lines (82 loc) · 3.93 KB
/
edit.php~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* block_course_daterollover
*
* This plugin adjust assignment date according to the course start date , it will set forward assignment items by x number of days, which includes allowsubmissionfrom,
* due-date, cutoffdate, upcoming events, in a course through one centralized screen
* rather than having to go into each individual assignment activity.
*
* @author Tsedey Terefe <[email protected]>
* @license GNU General Public License version 3
* @package block
* @subpackage course_daterollover
*/
global $CFG,$DB,$course,$PAGE;
require_once('../../config.php');
require_once($CFG->dirroot."/course/lib.php");
require_once($CFG->libdir.'/filelib.php');
require_once($CFG->dirroot.'/blocks/course_daterollover/course_daterollover_form.php');
require_login($SITE);
$courseid=required_param('id',PARAM_INT);
$sql3=$DB->get_fieldset_select('assign','course','course=?',array($courseid));
//if there is no assignment for the course
if (!empty($sql3))
{
$course= $DB->get_record('course',array ('id'=>$courseid),'*',MUST_EXIST);
$coursecontext = context_course::instance($course->id);//returns an object not just an ID
require_capability('block/course_daterollover:changedate', $coursecontext);
block_load_class('course_daterollover');
$block = new block_course_daterollover();
$form = new course_daterollover_form(null, array('coursecontext' => $coursecontext));
if ($data = $form->get_data()) {
$sql2=$DB->get_fieldset_select('course','startdate','id=?',array($courseid));
$assignments = $DB->get_records('assign', array('course'=>$courseid));
foreach($assignments as $assignment)
{
$record = new stdClass();
$record->id = $assignment->id;
$currentime =time();
$tiral3 =(($data->date) - ($sql2[0]));
$record->duedate = ($assignment->duedate )+($data->date) - ($sql2[0]);
$record->allowsubmissionsfromdate = ($assignment->allowsubmissionsfromdate )+($data->date) - ($sql2[0]);
$record->cutoffdate = ($assignment->cutoffdate )+($data->date) - ($sql2[0]);
$record->timemodified = $currentime;
$DB->update_record('assign', $record);
}
$upcomingevents = $DB->get_records('event', array('courseid'=>$courseid));
foreach($upcomingevents as $upcomingevent)
{
$eventrecord = new stdClass();
$eventrecord->id = $upcomingevent->id;
$currentime =time();
$eventrecord->timestart =($upcomingevent->timestart)+($data->date) - ($sql2[0]);
$eventrecord->timemodified = $currentime ;
$DB->update_record('event', $eventrecord);
}
$as = $DB->get_records('course', array('id'=>$courseid));
foreach ($as as $a )
{
$courserecord = new stdClass();
$courserecord->id = $a->id;
$courserecord->startdate = $data->date;
$DB->update_record('course', $courserecord);
}
}
}else{
redirect($CFG->wwwroot.'/course/view.php?id='.$courseid, '', 0);
}
redirect($CFG->wwwroot.'/course/view.php?id='.$courseid, '', 0);