コード例 #1
0
 public function saveNewCourse()
 {
     if (!isset($_POST['nameEN']) || empty($_POST['nameEN']) || !isset($_POST['nameDE']) || empty($_POST['nameDE'])) {
         $this->getView()->addErrorMessage('Please fill out all fields!');
         $this->addCourse();
     } else {
         $nameEN = $this->secureString($_POST['nameEN']);
         $nameDE = $this->secureString($_POST['nameDE']);
         if (Course::createCourse($nameEN, $nameDE)) {
             $this->getView()->addSuccessMessage('Course was successfully added.');
         } else {
             $this->getView()->addErrorMessage('Course could not be added!');
         }
         $this->defaultAction();
     }
 }
コード例 #2
0
         }
         // adds approvalConditions
         foreach ($etCreate as $exerciseType3) {
             if ($exerciseType3 === '') {
                 continue;
             }
             $newApprovalConditionSettings = ApprovalCondition::encodeApprovalCondition(ApprovalCondition::createApprovalCondition(null, $cid, $exerciseType3, 0));
             $URI = $databaseURI . "/approvalcondition";
             http_post_data($URI, $newApprovalConditionSettings, true, $message);
             if ($message != "201") {
                 $RequestError = true;
             }
         }
     }
     // create new course and edit existing one
     $newCourseSettings = Course::encodeCourse(Course::createCourse($cid, $courseName, $semester, $defaultGroupSize));
     $URI = $databaseURI . "/course/course/{$cid}";
     $courseManagement_data = http_put_data($URI, $newCourseSettings, true, $message);
     // show notification
     if ($message == "201" && $RequestError == false) {
         $courseSettingsNotifications[] = MakeNotification("success", Language::Get('main', 'successEditCourse', $langTemplate));
     } else {
         $courseSettingsNotifications[] = MakeNotification("error", Language::Get('main', 'errorEditCourse', $langTemplate));
     }
     ###########################
     ### end course_settings ###
     ###########################
     #endregion course_settings
 } else {
     $courseSettingsNotifications[] = MakeNotification("error", Language::Get('main', 'missingFields', $langTemplate));
 }
コード例 #3
0
ファイル: LExtension.php プロジェクト: sawh/ostepu-system
 /**
  * Install the given component to a course.
  *
  * Called when this component receives an HTTP POST request to
  * /link/course/$courseid/extension/$name(/).
  *
  * @param int $courseid The id of the course.
  * @param int $name The name of the component
  */
 public function addCourseExtension($courseid, $name)
 {
     foreach ($this->_extension as $link) {
         if ($link->getTargetName() === $name || $link->getTarget() === $name) {
             // TODO: hier eventuell alle Course Daten verwenden (vorher Abrufen)
             $courseObject = Course::createCourse($courseid, null, null, null);
             $result = Request::routeRequest('POST', '/course', $this->app->request->headers->all(), Course::encodeCourse($courseObject), $link, 'course');
             // checks the correctness of the query
             if ($result['status'] >= 200 && $result['status'] <= 299) {
                 $this->app->response->setStatus(201);
                 $this->app->response->setBody(null);
                 if (isset($result['headers']['Content-Type'])) {
                     $this->app->response->headers->set('Content-Type', $result['headers']['Content-Type']);
                 }
                 $this->app->stop();
             } else {
                 Logger::Log('POST AddCourseExtension failed', LogLevel::ERROR);
                 $this->app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
                 $this->app->stop();
             }
         }
     }
     $this->app->response->setStatus(404);
     $this->app->response->setBody(null);
 }
コード例 #4
0
 /**
  * Give course from Studip
  *
  * @param string $vid Is the courseid from StudIP
  * @return Course $course which contains our Structure Course with the given information from StudIP
  */
 public function getCourseInStudip($vid)
 {
     $message = null;
     $query = StudIPAuthentication::$StudipAPI . "/request.php?cmd=get_title&vid={$vid}";
     $title = http_get($query, false, $message);
     ///$title = "Veranstaltung";$message=200;
     ///Logger::Log("get_title_url: ".$query, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log');
     ///Logger::Log("get_title_message: ".$message, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log');
     ///Logger::Log("get_title_result: ".$title, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log');
     if ($message == 200 && $title != "not found") {
         $query = StudIPAuthentication::$StudipAPI . "/request.php?cmd=get_semester&vid={$vid}";
         $semester = http_get($query, false, $message);
         ///$semester="SS 2015";$message=200;
         ///Logger::Log("get_semester_url: ".$query, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log');
         ///Logger::Log("get_semester_message: ".$message, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log');
         ///Logger::Log("get_semester_result: ".$semester, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log');
         if ($message == 200 && $semester != "not found") {
             if (substr($semester, 0, 2) === 'WS') {
                 $semester = substr($semester, 0, -2) . '20' . substr($semester, -2);
             }
             return Course::createCourse(null, $title, $semester, 1);
         }
     }
     return null;
 }
コード例 #5
0
}
if ($login->isUserLoggedIn() === false) {
    exit(1);
}
// Test permissions
if (!$user->hasPrivilege("canCreateCourse")) {
    header("Location: ?view=accessdenied");
    exit;
}
// Namespaces to use
use PFBC\Form;
use PFBC\Element;
use PFBC\Validation;
// If form is submitted and correct
if (!empty($_POST) && Form::isValid("createCourse")) {
    $course = Course::createCourse($_POST['name']);
    // Add the course to this user
    $user->addCourse($course->id);
    // Add current user as admin
    $course->addAdmin($_SESSION['user_id']);
    echo '<h3>Success!</h3><a href="?"><button class="btn btn-success">Go back</button></a>';
} else {
    $form = new Form("createCourse");
    $form->configure(array("action" => "?view=createcourse"));
    $form->addElement(new Element\HTML('<legend>Create new course</legend>'));
    $form->addElement(new Element\Hidden("form", "createCourse"));
    $form->addElement(new Element\Textbox("Name:", "name", array("validation" => new Validation\RegExp("/^[\\d\\p{L} ]{2,64}\$/", "Error: The %element% field must contain only characters, numbers and whitespaces and be between 2 and 64 characters."), "required" => 1, "longDesc" => "Name of the course")));
    $form->addElement(new Element\Button("Create"));
    $form->addElement(new Element\Button("Cancel", "button", array("onclick" => "history.go(-1);")));
    $form->render();
}
コード例 #6
0
ファイル: MainSettings.php プロジェクト: sawh/ostepu-system
 $f->checkStringForKey('semester', FormEvaluator::REQUIRED, array('min' => 1), 'warning', Language::Get('main', 'invalidSemester', $langTemplate));
 $f->checkIntegerForKey('defaultGroupSize', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidGroupSize', $langTemplate), array('min' => 0));
 $f->checkArrayOfIntegersForKey('exerciseTypes', FormEvaluator::OPTIONAL, 'warning', Language::Get('main', 'invalidExerciseType', $langTemplate));
 $f->checkArrayOfIntegersForKey('plugins', FormEvaluator::OPTIONAL, 'warning', Language::Get('main', 'noSelectedExtensions', $langTemplate));
 if ($f->evaluate(true)) {
     // bool which is true if any error occured
     $RequestError = false;
     $foundValues = $f->foundValues;
     // extracts the php POST data
     $courseName = $foundValues['courseName'];
     $semester = $foundValues['semester'];
     $defaultGroupSize = $foundValues['defaultGroupSize'];
     $plugins = $foundValues['plugins'];
     $exerciseTypes = $foundValues['exerciseTypes'];
     // creates a new course
     $newCourse = Course::createCourse(null, $courseName, $semester, $defaultGroupSize);
     $newCourseSettings = Course::encodeCourse($newCourse);
     $URI = $logicURI . "/course";
     $newCourse = http_post_data($URI, $newCourseSettings, true, $messageNewCourse);
     // extracts the id of the new course
     $newCourse = json_decode($newCourse, true);
     $newCourseId = $newCourse['id'];
     // creates a new approvalCondition for every selected exerciseType
     if (isset($exerciseTypes) && !empty($exerciseTypes)) {
         foreach ($exerciseTypes as $exerciseType) {
             $newApprovalCondition = ApprovalCondition::createApprovalCondition(null, $newCourseId, $exerciseType, 0);
             $newApprovalConditionSettings = ApprovalCondition::encodeApprovalCondition($newApprovalCondition);
             $URI = $databaseURI . "/approvalcondition";
             http_post_data($URI, $newApprovalConditionSettings, true, $messageNewAc);
             if ($messageNewAc != "201") {
                 $RequestError = true;