Exemplo n.º 1
0
                          PERMISSIONS
  =============================================================================*/
$assignmentIsVisible = (bool) ($assignment->getVisibility() == 'VISIBLE');
// --
$is_allowedToEditAll = (bool) claro_is_allowed_to_edit();
// can submit, edit, delete
if (!$assignmentIsVisible && !$is_allowedToEditAll) {
    // if assignment is not visible and user is not course admin or upper
    claro_redirect(Url::Contextualize("work.php"));
    exit;
}
// upload or update is allowed between start and end date or after end date if late upload is allowed
$uploadDateIsOk = $assignment->isUploadDateOk();
//-- is_allowedToEdit
// TODO check if submission has feedback
$autoFeedbackIsDisplayedForAuthId = (bool) (trim(strip_tags($assignment->getAutoFeedbackText(), $allowedTags)) != '' || $assignment->getAutoFeedbackFilename() != '') && ($assignment->getAutoFeedbackSubmitMethod() == 'AFTERPOST' && count($assignment->getSubmissionList($_REQUEST['authId']) > 0) || $assignment->getAutoFeedbackSubmitMethod() == 'ENDDATE' && $assignment->getEndDate() <= time());
// if correction is automatically submitted user cannot edit his work
if (claro_is_user_authenticated() && !$autoFeedbackIsDisplayedForAuthId) {
    if ($assignment->getAssignmentType() == 'GROUP' && claro_is_in_a_group()) {
        $userCanEdit = (bool) ($submission->getGroupId() == claro_get_current_group_id());
    } elseif ($assignment->getAssignmentType() == 'GROUP') {
        // check if user is in the group that owns the work
        $userCanEdit = array_key_exists($submission->getGroupId(), $userGroupList);
    } elseif ($assignment->getAssignmentType() == 'INDIVIDUAL') {
        // a work is set, assignment is individual, user is authed and the work is his work
        $userCanEdit = (bool) ($submission->getUserId() == claro_get_current_user_id());
    }
} else {
    // user not authed
    // OR a correction has already been made
    $userCanEdit = false;
Exemplo n.º 2
0
$nameTools = get_lang('Assignment');
ClaroBreadCrumbs::getInstance()->setCurrent($nameTools, Url::Contextualize($_SERVER['PHP_SELF'] . '?assigId=' . (int) $req['assignmentId']));
ClaroBreadCrumbs::getInstance()->prepend(get_lang('Assignments'), Url::Contextualize('../work/work.php'));
/**
 * TOOL TITLE
 */
$pageTitle['mainTitle'] = $nameTools;
$pageTitle['subTitle'] = $assignment->getTitle();
// SHOW FEEDBACK
// only if :
//      - there is a text OR a file in automatic feedback
//    AND
//          feedback must be shown after end date and end date is past
//      OR  feedback must be shown directly after a post (from the time a work was uploaded by the student)
// there is a prefill_ file or text, so there is something to show
$textOrFilePresent = (bool) $assignment->getAutoFeedbackText() != '' || $assignment->getAutoFeedbackFilename() != '';
// feedback must be shown after end date and end date is past
$showAfterEndDate = (bool) ($assignment->getAutoFeedbackSubmitMethod() == 'ENDDATE' && $assignment->getEndDate() < time());
// feedback must be shown directly after a post
// check if user has already posted a work
// do not show to anonymous users because we can't know
// if the user already uploaded a work
$showAfterPost = (bool) claro_is_user_authenticated() && ($assignment->getAutoFeedbackSubmitMethod() == 'AFTERPOST' && count($assignment->getSubmissionList(claro_get_current_user_id())) > 0);
// Command list
$cmdList = array();
if ($is_allowedToSubmit && $assignment->getAssignmentType() != 'GROUP') {
    // Link to create a new assignment
    $cmdList[] = array('name' => get_lang('Submit a work'), 'url' => claro_htmlspecialchars(Url::Contextualize('user_work.php?authId=' . claro_get_current_user_id() . '&cmd=rqSubWrk' . '&assigId=' . $req['assignmentId'])));
}
if ($is_allowedToEditAll) {
    $cmdList[] = array('name' => get_lang('Edit automatic feedback'), 'url' => claro_htmlspecialchars(Url::Contextualize('feedback.php?cmd=rqEditFeedback' . '&assigId=' . $req['assignmentId'])));
Exemplo n.º 3
0
// do not execute if there is no assignment ID
if ($is_allowedToEdit && $isFeedbackSubmitted && $assignmentId) {
    $formCorrectlySent = true;
    // Feedback
    // check if there is text in it
    if (trim(strip_tags($_REQUEST['autoFeedbackText'], $allowedTags)) == '') {
        $autoFeedbackText = '';
    } else {
        $autoFeedbackText = trim($_REQUEST['autoFeedbackText']);
    }
    // uploaded file come from the feedback form
    if (is_uploaded_file($_FILES['autoFeedbackFilename']['tmp_name'])) {
        if ($_FILES['autoFeedbackFilename']['size'] > $fileAllowedSize) {
            $dialogBox->error(get_lang('You didnt choose any file to send, or file is too big'));
            $formCorrectlySent = false;
            $autoFeedbackFilename = $assignment->getAutoFeedbackFilename();
        } else {
            // add file extension if it doesn't have one
            $newFileName = $_FILES['autoFeedbackFilename']['name'];
            $newFileName .= add_extension_for_uploaded_file($_FILES['autoFeedbackFilename']);
            // Replace dangerous characters
            $newFileName = replace_dangerous_char($newFileName);
            // Transform any .php file in .phps fo security
            $newFileName = get_secure_file_name($newFileName);
            // -- create a unique file name to avoid any conflict
            // there can be only one automatic feedback but the file is put in the
            // assignments directory
            $autoFeedbackFilename = $assignment->createUniqueFilename($newFileName);
            $tmpWorkUrl = $assignment->getAssigDirSys() . $autoFeedbackFilename;
            if (move_uploaded_file($_FILES['autoFeedbackFilename']['tmp_name'], $tmpWorkUrl)) {
                chmod($tmpWorkUrl, CLARO_FILE_PERMISSIONS);