require_capability('moodle/grade:import', $context);
require_capability('gradeimport/csv:view', $context);
+$separatemode = (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context));
+$currentgroup = groups_get_course_group($course);
+
// sort out delimiter
if (isset($CFG->CSV_DELIMITER)) {
$csv_delimiter = '\\' . $CFG->CSV_DELIMITER;
break;
}
+ if ($separatemode and !groups_is_member($currentgroup, $studentid)) {
+ // not allowed to import into this group, abort
+ $status = false;
+ import_cleanup($importcode);
+ notify('user not member of current group, can not update!');
+ break;
+ }
+
// insert results of this students into buffer
if ($status and !empty($newgrades)) {
}
} else {
+ groups_print_course_menu($course, 'index.php?id='.$id);
+ echo '<div class="clearer"></div>';
+
// display the standard upload file form
$mform->display();
}
class grade_import_form extends moodleform {
function definition (){
+ global $COURSE;
+
$mform =& $this->_form;
if (isset($this->_customdata)) { // hardcoding plugin names here is hacky
$options = array('10'=>10, '20'=>20, '100'=>100, '1000'=>1000, '100000'=>100000);
$mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'grades'), $options); // TODO: localize
$mform->setType('previewrows', PARAM_INT);
+ $mform->addElement('hidden', 'groupid', groups_get_course_group($COURSE));
+ $mform->setType('groupid', PARAM_INT);
$this->add_action_buttons(false, get_string('uploadgrades', 'grades'));
}
}
class grade_import_mapping_form extends moodleform {
function definition () {
- global $CFG;
+ global $CFG, $COURSE;
$mform =& $this->_form;
// this is an array of headers
$mform->setType('separator', PARAM_ALPHA);
$mform->addElement('hidden', 'separator', 'comma');
$mform->setType('verbosescales', PARAM_INT);
+ $mform->addElement('hidden', 'groupid', groups_get_course_group($COURSE));
+ $mform->setType('groupid', PARAM_INT);
$this->add_action_buttons(false, get_string('uploadgrades', 'grades'));
}