Esempio n. 1
0
 // creates a new course
 if ($_POST['action'] == "SetCondition") {
     // bool which is true if any error occured
     $RequestError = false;
     foreach ($_POST as $key => $value) {
         // skips the first POST which includes the 'action' type
         if ($key == "action") {
             continue;
         }
         // changes the percentage for each exercise type
         $approvalConditionId = $key;
         $percentage = cleanInput($value);
         if (is_numeric($percentage) && $percentage >= 0 && $percentage <= 100) {
             $percentage = $percentage / 100;
             $newApprovalCondition = ApprovalCondition::createApprovalCondition($approvalConditionId, $cid, null, $percentage);
             $newApprovalConditionSettings = ApprovalCondition::encodeApprovalCondition($newApprovalCondition);
             $URI = $databaseURI . "/approvalcondition/approvalcondition/" . $approvalConditionId;
             http_put_data($URI, $newApprovalConditionSettings, true, $message);
             if ($message != "201") {
                 $notifications[] = MakeNotification("error", Language::Get('main', 'errorSetCondition', $langTemplate));
                 $RequestError = true;
             }
         } else {
             $notifications[] = MakeNotification("warning", Language::Get('main', 'invalidInput', $langTemplate));
             $RequestError = true;
         }
     }
     // creates a notification depending on RequestError
     if ($RequestError) {
         $notifications[] = MakeNotification("error", Language::Get('main', 'errorSetConditions', $langTemplate));
     } else {
Esempio n. 2
0
         }
     }
 }
 if (isset($etCreate)) {
     if ($etCreate == null) {
         $etCreate = array();
     }
     if (!is_array($etCreate)) {
         $etCreate = array($etCreate);
     }
     // 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 {
Esempio n. 3
0
 public static function ExtractApprovalCondition($data, $singleResult = false, $ApprovalExtension = '', $isResult = true)
 {
     // generates an assoc array of an approval condition by using a
     // defined list of its attributes
     $res = DBJson::getResultObjectsByAttributes($data, ApprovalCondition::getDBPrimaryKey(), ApprovalCondition::getDBConvert(), $ApprovalExtension);
     if ($isResult) {
         // to reindex
         $res = array_merge($res);
         $res = ApprovalCondition::decodeApprovalCondition($res, false);
         if ($singleResult == true) {
             // only one object as result
             if (count($res) > 0) {
                 $res = $res[0];
             }
         }
     }
     return $res;
 }
Esempio n. 4
0
 public function postSamples($callName, $input, $params = array())
 {
     set_time_limit(0);
     $sql = array();
     for ($i = 1; $i <= $params['amount']; $i++) {
         for ($b = 0; $b < 3; $b++) {
             $obj = ApprovalCondition::createApprovalCondition($i * 3 + $b, $i, ($i * 3 + $b) % 1000 + 1, '0.5');
             $sql[] = "insert ignore into ApprovalCondition SET " . $obj->getInsertData() . ";";
         }
         if ($i % 1000 == 0) {
             $this->_component->callSql('out2', implode('', $sql), 201, 'Model::isCreated', array(), 'Model::isProblem', array(new File()));
             $sql = array();
         }
     }
     $this->_component->callSql('out2', implode('', $sql), 201, 'Model::isCreated', array(), 'Model::isProblem', array(new File()));
     return Model::isCreated();
 }