Example #1
0
$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'])));
    if (claro_is_platform_admin() || get_conf('allow_download_all_submissions')) {
        $cmdList[] = array('img' => 'save', 'name' => get_lang('Download submissions'), 'url' => claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=rqDownload' . '&assigId=' . $req['assignmentId'])));
    }
}
/**
 * OUTPUT
 *
Example #2
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;