Browse Source

Add config "allow_only_one_student_publication_per_user" see BT#15028

Students can only upload one publication
Julio 6 years ago
parent
commit
26d6fb48bd
3 changed files with 23 additions and 6 deletions
  1. 3 0
      main/install/configuration.dist.php
  2. 8 6
      main/work/upload.php
  3. 12 0
      main/work/work_list.php

+ 3 - 0
main/install/configuration.dist.php

@@ -1006,6 +1006,9 @@ VALUES (2, 13, 'session_courses_read_only_mode', 'Lock Course In Session', 1, 1,
 );*/
 // $_configuration['mail_template_system'] = false;
 
+// Students can only upload one publication
+// $_configuration['allow_only_one_student_publication_per_user'] = false;
+
 // ------ Custom DB changes (keep this at the end)
 // Add user activation by confirmation email
 // This option prevents the new user to login in the platform if your account is not confirmed via email

+ 8 - 6
main/work/upload.php

@@ -44,21 +44,23 @@ $token = Security::get_token();
 
 $student_can_edit_in_session = api_is_allowed_to_session_edit(false, true);
 
-//  @todo add an option to allow/block multiple attempts.
-/*
-if (!empty($workInfo) && !empty($workInfo['qualification'])) {
+$onlyOnePublication = api_get_configuration_value('allow_only_one_student_publication_per_user');
+
+if ($onlyOnePublication) {
     $count =  get_work_count_by_student($user_id, $work_id);
     if ($count >= 1) {
-        Display::display_header();
+        api_not_allowed(true);
+
+        /*Display::display_header();
         if (api_get_course_setting('student_delete_own_publication') == '1') {
             echo Display::return_message(get_lang('CantUploadDeleteYourPaperFirst'), 'warning');
         } else {
             echo Display::return_message(get_lang('YouAlreadySentAPaperYouCantUpload'), 'warning');
         }
         Display::display_footer();
-        exit;
+        exit;*/
     }
-}*/
+}
 
 $homework = get_work_assignment_by_id($workInfo['id']);
 $validationStatus = getWorkDateValidationStatus($homework);

+ 12 - 0
main/work/work_list.php

@@ -69,6 +69,7 @@ $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_
     Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
 
 $actionsRight = '';
+$onlyOnePublication = api_get_configuration_value('allow_only_one_student_publication_per_user');
 if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_invitee()) {
     $url = api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId;
     $actionsRight = Display::url(
@@ -83,6 +84,17 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_in
     );
 }
 
+if ($onlyOnePublication) {
+    $count = get_work_count_by_student(
+        api_get_user_id(),
+        $my_folder_data['id']
+    );
+
+    if (!empty($count) && $count >= 1) {
+        $actionsRight = '';
+    }
+}
+
 $tpl = new Template('');
 
 $content = Display::toolbarAction('toolbar-work', [$actionsLeft, $actionsRight]);