00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action/Form.php';
00026
00027
00028
00029
00040
00041 class FF_Action_Form_Assignment extends FF_Action_Form {
00042
00043
00050 function renderAdditionalLinks()
00051 {
00052 $this->o_output->o_tpl->append('page_links', $this->o_output->link(
00053 FastFrame::selfURL(array('actionId' => ACTION_LIST)),
00054 sprintf(_('Return to %s List'), $this->getSingularText())));
00055 }
00056
00057
00058
00059
00067 function createFormElements()
00068 {
00069 $this->o_form->addElement('hidden', 'actionId');
00070 $this->o_form->addElement('hidden', 'objectId');
00071 $this->o_form->addElement('submit', 'submitbutton');
00072 $this->o_form->addElement('text', 'name', null, array('maxlength' => 150, 'size' => 30));
00073 $this->o_form->addElement('date', 'open_time', null,
00074 array('format' => 'd M Y H : i',
00075 'minYear' => date('Y') - 1,
00076 'maxYear' => date('Y') + 1,
00077 'addEmptyOption' => true));
00078 $this->o_form->addElement('date', 'late_time', null,
00079 array('format' => 'd M Y H : i',
00080 'minYear' => date('Y') - 1,
00081 'maxYear' => date('Y') + 1));
00082 $this->o_form->addElement('date', 'close_time', null,
00083 array('format' => 'd M Y H : i',
00084 'minYear' => date('Y') - 1,
00085 'maxYear' => date('Y') + 1,
00086 'addEmptyOption' => true));
00087
00088 $this->o_form->addElement('select', 'session', null, $this->o_model->getSessionOptions());
00089 $this->o_form->addElement('select', 'course_code', null, $this->o_model->getClassOptions());
00090 $this->o_form->addRule('name', _('Name cannot be blank.'), 'required', null, 'client');
00091 }
00092
00093
00094
00095
00102 function getSingularText()
00103 {
00104 return _('Assignment');
00105 }
00106
00107
00108
00109
00117 function getPluralText()
00118 {
00119 return _('Assignments');
00120 }
00121
00122
00123
00124
00133 function getTableData()
00134 {
00135 $a_headers = array();
00136 $a_headers[] = array(
00137 'title' => '* ' . _('Name:'),
00138 'titleStyle' => 'style="font-weight: bold;"',
00139 'data' => $this->o_renderer->elementToHtml('name'),
00140 );
00141 $a_headers[] = array(
00142 'title' => '* ' . _('Course Code:'),
00143 'titleStyle' => 'style="font-weight: bold;"',
00144 'data' => $this->o_renderer->elementToHtml('course_code'),
00145 );
00146 $a_headers[] = array(
00147 'title' => '* ' . _('Session:'),
00148 'titleStyle' => 'style="font-weight: bold;"',
00149 'data' => $this->o_renderer->elementToHtml('session'),
00150 );
00151 $tmp_help = _('Setting this date will make it so this assignment does not show up in the FTP program for you or the student until the date you set.');
00152 $a_headers[] = array(
00153 'title' => sprintf(_('Open Date %s:'), $this->o_output->getHelpLink($tmp_help)),
00154 'data' => $this->o_renderer->elementToHtml('open_time'),
00155 );
00156 $a_headers[] = array(
00157 'title' => '* ' . _('Due Date:'),
00158 'titleStyle' => 'style="font-weight: bold;"',
00159 'data' => $this->o_renderer->elementToHtml('late_time'),
00160 );
00161 $tmp_help = _('Setting this date will make it so that this assignment disappears in the FTP program for the student after this date.');
00162 $a_headers[] = array(
00163 'title' => sprintf(_('Close Date %s:'), $this->o_output->getHelpLink($tmp_help)),
00164 'data' => $this->o_renderer->elementToHtml('close_time'),
00165 );
00166 return $a_headers;
00167 }
00168
00169
00170
00171
00179 function getFormConstants()
00180 {
00181 $a_fields = array();
00182 if ($this->currentActionId == ACTION_ADD && FF_Request::getParam('submitWasSuccess', 'g', false)) {
00183 $a_fields['objectId'] = '';
00184 $a_fields['name'] = '';
00185 }
00186
00187 return array_merge(parent::getFormConstants(), $a_fields);
00188 }
00189
00190
00191
00192
00200 function getFormDefaults()
00201 {
00202 $a_fields = array();
00203 $a_fields['objectId'] = $this->o_model->getId();
00204 $a_fields['name'] = $this->o_model->getName();
00205 $a_fields['open_time'] = $this->o_model->getOpenTime();
00206 $a_fields['late_time'] = $this->o_model->getLateTime();
00207 $a_fields['close_time'] = $this->o_model->getCloseTime();
00208 $a_fields['session'] = $this->o_model->getSession();
00209 $a_fields['course_code'] = $this->o_model->getCourseCode();
00210 return $a_fields;
00211 }
00212
00213
00214
00215
00222 function checkPerms()
00223 {
00224 if (!$this->o_perms->hasPerm('can_use_homework') ||
00225 ($this->currentActionId == ACTION_EDIT && $this->o_model->getOwnerId() != FF_Auth::getCredential('userId'))) {
00226 $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00227 $this->o_output->setMessage(_('You cannot edit this assignment.'), FASTFRAME_ERROR_MESSAGE);
00228 return false;
00229 }
00230
00231 return true;
00232 }
00233
00234
00235 }
00236 ?>