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']))); 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'])));
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;
$assignment->setSubmissionType($_REQUEST['authorized_content']); } if (isset($_REQUEST['allow_late_upload'])) { $assignment->setAllowLateUpload($_REQUEST['allow_late_upload']); } $unixStartDate = mktime($_REQUEST['startHour'], $_REQUEST['startMinute'], '00', $_REQUEST['startMonth'], $_REQUEST['startDay'], $_REQUEST['startYear']); $assignment->setStartDate($unixStartDate); $unixEndDate = mktime($_REQUEST['endHour'], $_REQUEST['endMinute'], '00', $_REQUEST['endMonth'], $_REQUEST['endDay'], $_REQUEST['endYear']); $assignment->setEndDate($unixEndDate); $assignment_data['start_date'] = $unixStartDate; $assignment_data['end_date'] = $unixEndDate; } else { // create new assignment // add date format used to pre fill the form $assignment_data['start_date'] = $assignment->getStartDate(); $assignment_data['end_date'] = $assignment->getEndDate(); } } // Submission download requested if ($is_allowedToEdit && $cmd == 'rqDownload' && (claro_is_platform_admin() || get_conf('allow_download_all_submissions'))) { require_once $includePath . '/lib/form.lib.php'; $dialogBox->title(get_lang('Download')); $dialogBox->form('<form action="' . get_module_url('CLWRK') . '/export.php" method="POST">' . "\n" . claro_form_relay_context() . '<input type="hidden" name="cmd" value="exDownload" />' . "\n" . '<input type="radio" name="downloadMode" id="downloadMode_from" value="from" checked /><label for="downloadMode_from">' . get_lang('Submissions posted or modified after date :') . '</label><br />' . "\n" . claro_html_date_form('day', 'month', 'year', time(), 'long') . ' ' . claro_html_time_form('hour', 'minute', time() - fmod(time(), 86400) - 3600) . '<small>' . get_lang('(d/m/y hh:mm)') . '</small>' . '<br /><br />' . "\n" . '<input type="radio" name="downloadMode" id="downloadMode_all" value="all" /><label for="downloadMode_all">' . get_lang('All submissions') . '</label><br /><br />' . "\n" . '<input type="checkbox" name="downloadOnlyCurrentMembers" id="downloadOnlyCurrentMembers_id" value="yes" checked="checked" /><label for="downloadOnlyCurrentMembers_id">' . get_lang('Download only submissions from current course members') . '</label><br /><br />' . "\n" . '<input type="checkbox" name="downloadScore" id="downloadScore_id" value="yes" checked="checked" /><label for="downloadScore_id">' . get_lang('Download score') . '</label><br /><br />' . "\n" . '<input type="submit" value="' . get_lang('OK') . '" /> ' . "\n" . claro_html_button('work.php', get_lang('Cancel')) . '</form>' . "\n"); } if ($is_allowedToEdit) { /*-------------------------------------------------------------------- CHANGE VISIBILITY --------------------------------------------------------------------*/ // change visibility of an assignment if ($cmd == 'exChVis') { if (isset($_REQUEST['vis'])) {
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') { $prefillSubmitEndDateCheckStatus = ''; $prefillSubmitAfterPostCheckStatus = 'checked="checked"'; } $displayFeedbackForm = true; } } /** * DISPLAY */ // bredcrump to return to the list when in a form