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;
$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'])));
//report event to eventmanager "feedback_posted" $eventNotifier->notifyCourseEvent("work_feedback_posted", claro_get_current_course_id(), claro_get_current_tool_id(), $assignmentId, '0', '0'); } else { $cmd = 'rqEditFeedback'; } } /*----------------------------------- STEP 1 : display form -------------------------------------*/ // edit assignment / display the form if ($cmd == 'rqEditFeedback') { require_once get_path('incRepositorySys') . '/lib/form.lib.php'; // check if it was already sent if (!$isFeedbackSubmitted) { // feedback $form['autoFeedbackText'] = $assignment->getAutoFeedbackText(); $form['autoFeedbackFilename'] = $assignment->getAutoFeedbackFilename(); $form['autoFeedbackSubmitMethod'] = $assignment->getAutoFeedbackSubmitMethod(); } else { // there was an error in the form $form['autoFeedbackText'] = $_REQUEST['autoFeedbackText']; $form['autoFeedbackFilename'] = !empty($_REQUEST['autoFeedbackFilename']) ? $_REQUEST['autoFeedbackFilename'] : ''; $form['autoFeedbackSubmitMethod'] = $_REQUEST['autoFeedbackSubmitMethod']; } // end date (as a reminder for the "after end date" option $form['unix_end_date'] = $assignment->getEndDate(); // ask the display of the form if ($form['autoFeedbackSubmitMethod'] == 'ENDDATE') { $prefillSubmitEndDateCheckStatus = 'checked="checked"'; $prefillSubmitAfterPostCheckStatus = ''; } elseif ($form['autoFeedbackSubmitMethod'] == 'AFTERPOST') {