Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 29... Línea 29...
29
// get parameters
29
// get parameters
30
$id = required_param('id', PARAM_INT);
30
$id = required_param('id', PARAM_INT);
31
$choosefile = optional_param('choosefile', false, PARAM_PATH);
31
$choosefile = optional_param('choosefile', false, PARAM_PATH);
32
$action = optional_param('action', false, PARAM_ALPHA);
32
$action = optional_param('action', false, PARAM_ALPHA);
Línea 33... Línea 33...
33
 
33
 
34
$url = new moodle_url('/mod/feedback/import.php', array('id'=>$id));
34
$url = new moodle_url('/mod/feedback/import.php', ['id' => $id]);
35
if ($choosefile !== false) {
35
if ($choosefile !== false) {
36
    $url->param('choosefile', $choosefile);
36
    $url->param('choosefile', $choosefile);
37
}
37
}
38
if ($action !== false) {
38
if ($action !== false) {
39
    $url->param('action', $action);
39
    $url->param('action', $action);
40
}
40
}
-
 
41
$PAGE->set_url($url);
Línea 41... Línea 42...
41
$PAGE->set_url($url);
42
navigation_node::override_active_url(new moodle_url('/mod/feedback/edit.php'));
42
 
43
 
43
if (! $cm = get_coursemodule_from_id('feedback', $id)) {
44
if (! $cm = get_coursemodule_from_id('feedback', $id)) {
Línea 44... Línea 45...
44
    throw new \moodle_exception('invalidcoursemodule');
45
    throw new \moodle_exception('invalidcoursemodule');
45
}
46
}
46
 
47
 
Línea 47... Línea 48...
47
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
48
if (! $course = $DB->get_record("course", ["id" => $cm->course])) {
48
    throw new \moodle_exception('coursemisconf');
49
    throw new \moodle_exception('coursemisconf');
49
}
50
}
Línea 50... Línea 51...
50
 
51
 
Línea 51... Línea 52...
51
if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
52
if (! $feedback = $DB->get_record("feedback", ["id" => $cm->instance])) {
Línea 52... Línea 53...
52
    throw new \moodle_exception('invalidcoursemodule');
53
    throw new \moodle_exception('invalidcoursemodule');
53
}
-
 
Línea 54... Línea 54...
54
 
54
}
55
$context = context_module::instance($cm->id);
55
 
-
 
56
$context = context_module::instance($cm->id);
56
 
57
 
57
require_login($course, true, $cm);
58
require_login($course, true, $cm);
58
 
59
 
59
require_capability('mod/feedback:edititems', $context);
60
require_capability('mod/feedback:edititems', $context);
-
 
61
 
60
$actionbar = new \mod_feedback\output\edit_action_bar($cm->id, $url);
62
$mform = new feedback_import_form();
61
 
63
$newformdata = [
Línea 62... Línea 64...
62
$mform = new feedback_import_form();
64
    'id' => $id,
63
$newformdata = array('id'=>$id,
65
    'deleteolditems' => '1',
Línea 97... Línea 99...
97
$PAGE->set_title($feedback->name);
99
$PAGE->set_title($feedback->name);
98
$PAGE->activityheader->set_attrs([
100
$PAGE->activityheader->set_attrs([
99
    "hidecompletion" => true,
101
    "hidecompletion" => true,
100
    "description" => ''
102
    "description" => ''
101
]);
103
]);
-
 
104
$PAGE->add_body_class('limitedwidth');
-
 
105
 
102
echo $OUTPUT->header();
106
echo $OUTPUT->header();
103
/** @var \mod_feedback\output\renderer $renderer */
107
/** @var \mod_feedback\output\renderer $renderer */
104
$renderer = $PAGE->get_renderer('mod_feedback');
108
$renderer = $PAGE->get_renderer('mod_feedback');
105
echo $renderer->main_action_bar($actionbar);
-
 
Línea 106... Línea 109...
106
 
109
 
107
/// Print the main part of the page
110
/// Print the main part of the page
108
///////////////////////////////////////////////////////////////////////////
111
///////////////////////////////////////////////////////////////////////////
109
///////////////////////////////////////////////////////////////////////////
112
///////////////////////////////////////////////////////////////////////////
110
///////////////////////////////////////////////////////////////////////////
-
 
111
if (!$PAGE->has_secondary_navigation()) {
113
///////////////////////////////////////////////////////////////////////////
112
    echo $OUTPUT->heading(get_string('import_questions', 'feedback'), 3);
-
 
Línea 113... Línea 114...
113
}
114
echo $OUTPUT->heading(get_string('import_questions', 'feedback'), 3);
114
 
115
 
115
if (isset($importerror->msg) AND is_array($importerror->msg)) {
116
if (isset($importerror->msg) AND is_array($importerror->msg)) {
116
    echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter');
117
    echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter');
Línea 148... Línea 149...
148
 
149
 
Línea 149... Línea 150...
149
    $deleteolditems = optional_param('deleteolditems', 0, PARAM_INT);
150
    $deleteolditems = optional_param('deleteolditems', 0, PARAM_INT);
150
 
151
 
151
    $error = new stdClass();
152
    $error = new stdClass();
Línea 152... Línea 153...
152
    $error->stat = true;
153
    $error->stat = true;
153
    $error->msg = array();
154
    $error->msg = [];
154
 
155
 
155
    if (!is_array($data)) {
156
    if (!is_array($data)) {
Línea 161... Línea 162...
161
    if ($deleteolditems) {
162
    if ($deleteolditems) {
162
        feedback_delete_all_items($feedbackid);
163
        feedback_delete_all_items($feedbackid);
163
        $position = 0;
164
        $position = 0;
164
    } else {
165
    } else {
165
        //items will be add to the end of the existing items
166
        //items will be add to the end of the existing items
166
        $position = $DB->count_records('feedback_item', array('feedback'=>$feedbackid));
167
        $position = $DB->count_records('feedback_item', ['feedback' => $feedbackid]);
167
    }
168
    }
Línea 168... Línea 169...
168
 
169
 
169
    //depend items we are storing temporary in an mapping list array(new id => dependitem)
170
    // Depend items we are storing temporary in an mapping list [new id => dependitem].
170
    //we also store a mapping of all items array(oldid => newid)
171
    // We also store a mapping of all items [oldid => newid].
171
    $dependitemsmap = array();
172
    $dependitemsmap = [];
172
    $itembackup = array();
173
    $itembackup = [];
173
    foreach ($data as $item) {
174
    foreach ($data as $item) {
174
        $position++;
175
        $position++;
175
        //check the typ
176
        //check the typ
Línea 267... Línea 268...
267
        }
268
        }
Línea 268... Línea 269...
268
 
269
 
269
    }
270
    }
270
    //remapping the dependency
271
    //remapping the dependency
271
    foreach ($dependitemsmap as $key => $dependitem) {
272
    foreach ($dependitemsmap as $key => $dependitem) {
272
        $newitem = $DB->get_record('feedback_item', array('id'=>$key));
273
        $newitem = $DB->get_record('feedback_item', ['id' => $key]);
273
        $newitem->dependitem = $itembackup[$newitem->dependitem];
274
        $newitem->dependitem = $itembackup[$newitem->dependitem];
274
        $DB->update_record('feedback_item', $newitem);
275
        $DB->update_record('feedback_item', $newitem);
Línea 275... Línea 276...
275
    }
276
    }