public function onAdd()
 {
     $items = post('items', []);
     $name = post('new_name');
     $totalPoints = post('new_total_points');
     $startDate = post('new_start_date');
     $endDate = post('new_end_date');
     $bonusPerDay = post('new_bonus_per_day');
     $bonusDays = post('new_bonus_days');
     $penaltyPerDay = post('new_penalty_per_day');
     $penaltyDays = post('new_penalty_days');
     $experience = new Model();
     $experience->name = $name;
     $experience->total_points = $totalPoints;
     $start = new DateTime($startDate);
     $experience->start_date = $start->format('c');
     $end = new DateTime($endDate);
     $experience->end_date = $end->format('c');
     $experience->bonus_per_day = $bonusPerDay;
     $experience->bonus_days = $bonusDays;
     $experience->penalty_per_day = $penaltyPerDay;
     $experience->penalty_days = $penaltyDays;
     $experience->save();
     $this->page['items'] = Model::all();
 }
Esempio n. 2
0
 public function getExperienceInstanceOptions()
 {
     $instances = ExperienceModel::all();
     if (count($instances) === 0) {
         return $array_dropdown = ['0' => 'No instances available'];
     } else {
         $array_dropdown = ['0' => '- select Experience Instance - '];
         foreach ($instances as $instance) {
             $array_dropdown[$instance->id] = $instance->name;
         }
         return $array_dropdown;
     }
 }
Esempio n. 3
0
 public function getExperienceOptions()
 {
     $instances = ExperienceModel::all();
     if (count($instances) === 0) {
         return $array_dropdown = ["0" => "No instances available. Component won\\'t work"];
     } else {
         $array_dropdown = ["0" => "- select Experience Instance - "];
         foreach ($instances as $instance) {
             $array_dropdown[$instance->id] = $instance->name;
         }
         return $array_dropdown;
     }
 }
Esempio n. 4
0
 public function getExperienceInstanceOptions()
 {
     $instances = ExperienceModel::all();
     if (count($instances) === 0) {
         return $array_dropdown = ['0' => 'No instances available. Bonus/penalties won\'t appear in the gradebook'];
     } else {
         $array_dropdown = ['0' => '- select Experience Instance - '];
         foreach ($instances as $instance) {
             $array_dropdown[$instance->id] = $instance->name;
         }
         return $array_dropdown;
     }
 }
Esempio n. 5
0
 public function getInstanceOptions()
 {
     $instances = ExperienceModel::all();
     $array_dropdown = ['0' => '- select Experience Instance - '];
     foreach ($instances as $instance) {
         $array_dropdown[$instance->id] = $instance->name;
     }
     return $array_dropdown;
 }