-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit.php~
136 lines (84 loc) · 3.83 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
131
132
133
134
135
136
<?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_assignment_daterollover
*
* This plugin adjust assignment date items 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 assignment_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/assignment_daterollover/assignment_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/assignment_daterollover:changedate', $coursecontext);
block_load_class('assignment_daterollover');
$block = new block_assignment_daterollover();
$form = new assignment_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));
$sql3=$DB->get_fieldset_select('assign','duedate','id=?',array($data->assign));
$sql4=$DB->get_fieldset_select('assign','cutoffdate','id=?',array($data->assign));
$sql5=$DB->get_fieldset_select('assign','allowsubmissionsfromdate','id=?',array($data->assign));
if ($data->updateduedate=='Adjust duedate')
{
$record = new stdClass();
$record ->id = $data->assign;
$record ->duedate = $data->date ;
$DB->update_record('assign', $record);
$sqlevent=$DB->get_fieldset_select('event','id','instance=?',array($data->assign));
$eventrecord = new stdClass();
// $upcomingdiff=( $data->date)-(86400*5);
$eventrecord->id = $sqlevent[0];
$currentime =time();
$eventrecord->timestart =$data->date;
$eventrecord->timemodified = $currentime ;
$DB->update_record('event', $eventrecord);
}
if ($data->updatecutoff=='Adjust cutoff date')
{
$cutoffrecord = new stdClass();
$cutoffrecord ->id = $data->assign;
$cutoffrecord ->cutoffdate = $data->cutoff ;
$DB->update_record('assign', $cutoffrecord);
}
if ($data->updateallowsub=='Adjust allow submission')
{
$allowsubrecord = new stdClass();
$allowsubrecord ->id = $data->assign;
$allowsubrecord ->allowsubmissionsfromdate = $data->allowsubmission ;
$DB->update_record('assign', $allowsubrecord);
}
}
}else{
redirect($CFG->wwwroot.'/course/view.php?id='.$courseid, '', 0);
}
redirect($CFG->wwwroot.'/course/view.php?id='.$courseid, '', 0);