Exemplo n.º 1
0
             $url = $databaseURI . "/coursestatus/course/{$cid}/user/{$userID}";
             http_delete($url, true, $message);
             // show notification
             if ($message == "201") {
                 $revokeRightsNotifications[] = MakeNotification("success", Language::Get('main', 'successRemoveUser', $langTemplate));
             }
         } else {
             // otherwise show conflict page
             set_error("409");
             exit;
         }
     } else {
         $revokeRightsNotifications[] = MakeNotification("error", Language::Get('main', 'noSelectedUser', $langTemplate));
     }
 } elseif ($_POST['action'] == "AddUser") {
     $f = new FormEvaluator($_POST);
     $f->checkStringForKey('userName', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidUserName', $langTemplate), array('min' => 1));
     $f->checkIntegerForKey('rights', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidCourseStatus', $langTemplate), array('min' => 0, 'max' => 2));
     if ($f->evaluate(true)) {
         $foundValues = $f->foundValues;
         $userName = $foundValues['userName'];
         $rights = $foundValues['rights'];
         $URL = $databaseURI . '/user/user/' . $userName;
         $user = http_get($URL, true);
         $user = json_decode($user, true);
         if (isset($user['id'])) {
             $userId = $user['id'];
             $newUser = User::createCourseStatus($userId, $cid, $rights);
             $newUser = User::encodeUser($newUser);
             $URL = $databaseURI . '/coursestatus';
             http_post_data($URL, $newUser, true, $message);
Exemplo n.º 2
0
                 if ($message == "201") {
                     /// $notifications[] = MakeNotification("success", "Das Passwort wurde geändert!");
                     Authentication::logoutUser();
                 }
             } else {
                 $notifications[] = MakeNotification("error", Language::Get('main', 'differentPasswords', $langTemplate));
             }
         } else {
             $notifications[] = MakeNotification("error", Language::Get('main', 'incorrectOldPassword', $langTemplate));
         }
     } else {
         $notifications = $notifications + $f->notifications;
     }
 } else {
     if ($_POST['action'] == "SetAccountInfo") {
         $f = new FormEvaluator($_POST);
         $f->checkStringForKey('language', FormEvaluator::OPTIONAL, 'warning', '???.');
         if ($f->evaluate(true)) {
             $foundValues = $f->foundValues;
             $language = $foundValues['language'];
             $newUserSettings = User::encodeUser(User::createUser($uid, null, null, null, null, null, null, null, null, null, null, null, null, null, $language));
             $URI = $databaseURI . "/user/" . $uid;
             http_put_data($URI, $newUserSettings, true, $message);
             if ($message == "201") {
                 $notifications[] = MakeNotification("success", Language::Get('main', 'languageChanged', $langTemplate));
             }
         } else {
             $notifications = $notifications + $f->notifications;
         }
     }
 }
Exemplo n.º 3
0
 foreach ($_POST['exercises'] as $key => $exercises) {
     if ($key == $leaderID) {
         // bool which is true if any error occured
         $RequestErrorMarking = false;
         $RequestErrorSubmission = false;
         $hasChangedMarking = false;
         $hasChangedSubmission = false;
         foreach ($exercises as $exerciseId => $exercise) {
             $maxPoints = cleanInput($exercise['maxPoints']);
             $submissionID = cleanInput($exercise['submissionID']);
             $markingID = cleanInput($exercise['markingID']);
             $userName = isset($exercise['user']) ? $exercise['user'] : '******';
             if (isset($exercise['points'])) {
                 $exercise['points'] = str_replace(',', '.', $exercise['points']);
             }
             $f = new FormEvaluator($exercise);
             $f->checkNumberForKey('points', FormEvaluator::OPTIONAL, 'warning', Language::Get('main', 'invalidPoints', $langTemplate), array('min' => 0));
             $f->checkStringForKey('tutorComment', FormEvaluator::OPTIONAL, 'warning', Language::Get('main', 'invalidComment', $langTemplate), array('min' => 1));
             /**
              * @todo get maxStatusID for FormEvaluator.
              */
             $f->checkIntegerForKey('status', FormEvaluator::OPTIONAL, 'warning', Language::Get('main', 'invalidStatus', $langTemplate), array('min' => 0, 'max' => $maxMarkingStatus));
             $f->checkIntegerForKey('accepted', FormEvaluator::OPTIONAL, 'warning', Language::Get('main', 'invalidAcceptance', $langTemplate), array('min' => 0, 'max' => 1));
             if ($f->evaluate(true)) {
                 $foundValues = $f->foundValues;
                 $changed = false;
                 $points = isset($foundValues['points']) ? $foundValues['points'] : null;
                 if ($points > $maxPoints) {
                     $msg = Language::Get('main', 'tooManyPoints', $langTemplate, array('maxPoints' => $maxPoints));
                     if (!isset($GroupNotificationElements[$key])) {
                         $GroupNotificationElements[$key] = array();
Exemplo n.º 4
0
             }
         }
     }
     $URI = $serverURI . "/logic/LMarking/marking";
     http_post_data($URI, Marking::encodeMarking($markings), true, $message);
     if ($message == "201" || $message == "200") {
         $msg = Language::Get('main', 'successAssignment', $langTemplate);
         $assignManuallyNotifications[] = MakeNotification("success", $msg);
     } else {
         $msg = Language::Get('main', 'errorAssignment', $langTemplate);
         $assignManuallyNotifications[] = MakeNotification("error", $msg);
     }
 }
 // assigns manually chosen submissions to the selected tutor
 if (isset($_POST['actionAssignManually'])) {
     $f = new FormEvaluator($_POST);
     $f->checkIntegerForKey('tutorId', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidTutor', $langTemplate));
     $f->checkArrayOfArraysForKey('assign', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidSelection', $langTemplate));
     if ($f->evaluate(true)) {
         // extracts the php POST data
         $foundValues = $f->foundValues;
         $selectedTutorID = $foundValues['tutorId'];
         $assigns = cleanInput($_POST['assign']);
         $markings = array();
         foreach ($assigns as $owner => $ass) {
             $markingList = isset($ass['marking']) ? $ass['marking'] : array();
             $proposals = isset($ass['proposal']) ? $ass['proposal'] : array();
             // change assignment only if different source and target
             if ($owner != $selectedTutorID) {
                 foreach ($markingList as $markingId => $subs) {
                     $subs = $subs[0];
Exemplo n.º 5
0
<?php

// automatically assigns all unassigned submissions to the selected tutors
if (isset($_POST['action']) && $_POST['action'] == "AssignAutomatically") {
    set_time_limit(180);
    $f = new FormEvaluator($_POST);
    $f->checkArrayOfIntegersForKey('tutorIds', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidTutors', $langTemplate));
    if ($f->evaluate(true)) {
        // extracts the php POST data
        $foundValues = $f->foundValues;
        $selectedTutorIDs = $foundValues['tutorIds'];
        $data = array('tutors' => array(), 'unassigned' => array());
        // load user data from the database for the first time
        $URL = $getSiteURI . "/tutorassign/user/{$uid}/course/{$cid}/exercisesheet/{$sid}";
        $tutorAssign_data = http_get($URL, false);
        $tutorAssign_data = json_decode($tutorAssign_data, true);
        // adds all tutors that are selected in the form to the request body
        foreach ($selectedTutorIDs as $tutorID) {
            $newTutor = array('tutorId' => $tutorID);
            $data['tutors'][] = $newTutor;
        }
        // adds all unassigned submissions to the request body
        if (!empty($tutorAssign_data['tutorAssignments'])) {
            foreach ($tutorAssign_data['tutorAssignments'] as $tutorAssignment) {
                if ($tutorAssignment['tutor']['userName'] == "unassigned") {
                    foreach ($tutorAssignment['submissions'] as $submission) {
                        unset($submission['unassigned']);
                        $data['unassigned'][] = $submission;
                    }
                }
            }
Exemplo n.º 6
0
            }
            $processes = json_decode(Process::encodeProcess($processors), true);
            #############################
            ### end create_processors ###
            #############################
            #endregion
        }
        $sheet_data['exercises'] = json_decode(Exercise::encodeExercise($exercises), true);
    }
}
if (isset($_POST['action'])) {
    // && $_POST['action'] == "new"
    $timestamp = time();
    $errorInSent = false;
    // validate all sheet data
    $f = new FormEvaluator($_POST);
    $f->checkStringForKey('sheetName', FormEvaluator::REQUIRED, 'error', Language::Get('main', 'invalidSheetName', $langTemplate));
    $f->checkStringForKey('startDate', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidPeriodBegin', $langTemplate));
    $f->checkStringForKey('endDate', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidPeriodEnd', $langTemplate));
    // check if defaultGroupSize is bigger than standard groupsize 10
    if ($createsheetData['user']['courses'][0]['course']['defaultGroupSize'] < 10) {
        $maxgroup = 10;
    } else {
        $maxgroup = $createsheetData['user']['courses'][0]['course']['defaultGroupSize'];
    }
    $f->checkIntegerForKey('groupSize', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidGroupSize', $langTemplate), array('min' => 0, 'max' => $maxgroup));
    /*$f->checkArrayOfArraysForKey('exercises',
      FormEvaluator::REQUIRED,
      'warning',
      'Bitte erstellen Sie mindestens eine Aufgabe.');*/
    // check if startDate is not later than endDate and if it matches format
Exemplo n.º 7
0
                 $url = $databaseURI . "/coursestatus/course/{$courseID}/user/{$userID}";
                 http_put_data($url, $data, true, $message);
                 if ($message == "201") {
                     $notifications[] = MakeNotification("success", Language::Get('main', 'successSetAdmin', $langTemplate));
                 } else {
                     $notifications[] = MakeNotification("error", Language::Get('main', 'errorSetAdmin', $langTemplate));
                 }
             } else {
                 $notifications[] = MakeNotification("success", Language::Get('main', 'successSetAdmin', $langTemplate));
             }
         }
     }
 }
 // creates a new user
 if ($_POST['action'] == "CreateUser") {
     $f = new FormEvaluator($_POST);
     $f->checkStringForKey('lastName', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidLastName', $langTemplate), array('min' => 1));
     $f->checkStringForKey('firstName', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidFirstName', $langTemplate), array('min' => 1));
     $f->checkStringForKey('userName', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidUserName', $langTemplate), array('min' => 1));
     $f->checkEmailForKey('email', FormEvaluator::OPTIONAL, false, 'warning', Language::Get('main', 'invalidMail', $langTemplate));
     $f->checkStringForKey('password', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidPassword', $langTemplate), array('min' => 6));
     $f->checkStringForKey('passwordRepeat', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidPasswordRepeat', $langTemplate), array('min' => 6));
     if ($f->evaluate(true)) {
         $foundValues = $f->foundValues;
         $lastName = $foundValues['lastName'];
         $firstName = $foundValues['firstName'];
         $email = isset($foundValues['email']) ? $foundValues['email'] : null;
         $userName = $foundValues['userName'];
         $password = $foundValues['password'];
         $passwordRepeat = $foundValues['passwordRepeat'];
         // both passwords are equal