Exemplo n.º 1
0
 /**
  * Definition of the setting form elements
  */
 public function definition()
 {
     global $OUTPUT;
     $mform = $this->_form;
     $teamwork = $this->_customdata['teamwork'];
     $current = $this->_customdata['current'];
     if (!empty($teamwork->submissionend)) {
         $strtimeexpected = teamwork::timestamp_formats($teamwork->submissionend);
     }
     if (!empty($current->timeallocated)) {
         $strtimeexecuted = teamwork::timestamp_formats($current->timeallocated);
     }
     $mform->addElement('header', 'scheduledallocationsettings', get_string('scheduledallocationsettings', 'teamworkallocation_scheduled'));
     $mform->addHelpButton('scheduledallocationsettings', 'scheduledallocationsettings', 'teamworkallocation_scheduled');
     $mform->addElement('checkbox', 'enablescheduled', get_string('enablescheduled', 'teamworkallocation_scheduled'), get_string('enablescheduledinfo', 'teamworkallocation_scheduled'), 1);
     $mform->addElement('header', 'scheduledallocationinfo', get_string('currentstatus', 'teamworkallocation_scheduled'));
     if ($current === false) {
         $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'teamworkallocation_scheduled'), get_string('resultdisabled', 'teamworkallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid'))));
     } else {
         if (!empty($current->timeallocated)) {
             $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'teamworkallocation_scheduled'), get_string('currentstatusexecution1', 'teamworkallocation_scheduled', $strtimeexecuted) . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/valid'))));
             if ($current->resultstatus == teamwork_allocation_result::STATUS_EXECUTED) {
                 $strstatus = get_string('resultexecuted', 'teamworkallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/valid')));
             } else {
                 if ($current->resultstatus == teamwork_allocation_result::STATUS_FAILED) {
                     $strstatus = get_string('resultfailed', 'teamworkallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid')));
                 } else {
                     $strstatus = get_string('resultvoid', 'teamworkallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid')));
                 }
             }
             if (!empty($current->resultmessage)) {
                 $strstatus .= html_writer::empty_tag('br') . $current->resultmessage;
                 // yes, this is ugly. better solution suggestions are welcome.
             }
             $mform->addElement('static', 'inforesult', get_string('currentstatusresult', 'teamworkallocation_scheduled'), $strstatus);
             if ($current->timeallocated < $teamwork->submissionend) {
                 $mform->addElement('static', 'infoexpected', get_string('currentstatusnext', 'teamworkallocation_scheduled'), get_string('currentstatusexecution2', 'teamworkallocation_scheduled', $strtimeexpected) . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/caution'))));
                 $mform->addHelpButton('infoexpected', 'currentstatusnext', 'teamworkallocation_scheduled');
             } else {
                 $mform->addElement('checkbox', 'reenablescheduled', get_string('currentstatusreset', 'teamworkallocation_scheduled'), get_string('currentstatusresetinfo', 'teamworkallocation_scheduled'));
                 $mform->addHelpButton('reenablescheduled', 'currentstatusreset', 'teamworkallocation_scheduled');
             }
         } else {
             if (empty($current->enabled)) {
                 $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'teamworkallocation_scheduled'), get_string('resultdisabled', 'teamworkallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid'))));
             } else {
                 if ($teamwork->phase != teamwork::PHASE_SUBMISSION) {
                     $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'teamworkallocation_scheduled'), get_string('resultfailed', 'teamworkallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid'))) . html_writer::empty_tag('br') . get_string('resultfailedphase', 'teamworkallocation_scheduled'));
                 } else {
                     if (empty($teamwork->submissionend)) {
                         $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'teamworkallocation_scheduled'), get_string('resultfailed', 'teamworkallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid'))) . html_writer::empty_tag('br') . get_string('resultfaileddeadline', 'teamworkallocation_scheduled'));
                     } else {
                         if ($teamwork->submissionend < time()) {
                             // next cron will execute it
                             $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'teamworkallocation_scheduled'), get_string('currentstatusexecution4', 'teamworkallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/caution'))));
                         } else {
                             $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'teamworkallocation_scheduled'), get_string('currentstatusexecution3', 'teamworkallocation_scheduled', $strtimeexpected) . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/caution'))));
                         }
                     }
                 }
             }
         }
     }
     parent::definition();
     $mform->addHelpButton('randomallocationsettings', 'randomallocationsettings', 'teamworkallocation_scheduled');
 }