$turnitintooltwofileuploadoptions = array('maxbytes' => $maxfilesize, 'subdirs' => false, 'maxfiles' => 1, 'accepted_types' => '*');
if (!($parts = $turnitintooltwoassignment->get_parts())) {
    turnitintooltwo_print_error('partgeterror', 'turnitintooltwo', null, null, __FILE__, __LINE__);
}
// Get whether user is a tutor/student.
$istutor = has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id));
$userrole = $istutor ? 'Instructor' : 'Learner';
// Deal with actions here.
if (!empty($action)) {
    turnitintooltwo_activitylog("Action: " . $action . " | Id: " . $turnitintooltwo->id . " | Part: " . $part, "REQUEST");
    switch ($action) {
        case "delpart":
            if (!confirm_sesskey()) {
                throw new moodle_exception('invalidsesskey', 'error');
            }
            if ($turnitintooltwoassignment->delete_moodle_assignment_part($turnitintooltwoassignment->turnitintooltwo->id, $part)) {
                $_SESSION["notice"]['message'] = get_string('partdeleted', 'turnitintooltwo');
            }
            redirect(new moodle_url('/course/mod.php', array('update' => $cm->id, 'return' => true, 'sesskey' => sesskey())));
            exit;
            break;
        case "addtutor":
            if (!confirm_sesskey()) {
                throw new moodle_exception('invalidsesskey', 'error');
            }
            $tutorid = required_param('turnitintutors', PARAM_INT);
            $_SESSION["notice"]['message'] = $turnitintooltwoassignment->add_tii_tutor($tutorid);
            redirect(new moodle_url('/mod/turnitintooltwo/view.php', array('id' => $id, 'do' => $do)));
            exit;
            break;
        case "removetutor":