exit; } // Namespaces to use use PFBC\Form; use PFBC\Element; use PFBC\Validation; // If form is submitted and correct if (!empty($_POST) && Form::isValid("assignExaminator", false)) { $uid = findUser($_POST['username']); // Get current Course $course = $user->getCourse($cid); if ($uid == -1) { Form::setError('assignExaminator', 'Error: Unable to find that user.'); header("Location: ?view=assignexaminator&cid={$cid}"); exit; } else { Form::clearValues('assignExaminator'); } // Add user to examinators $course->addExaminator($uid); echo '<h3>Success!</h3><a href="?view=course&cid=' . $cid . '"><button class="btn btn-success">Go back</button></a>'; } else { $form = new Form("assignExaminator"); $form->configure(array("action" => "?view=assignexaminator&cid={$cid}")); $form->addElement(new Element\HTML('<legend>Assign new examinator</legend>')); $form->addElement(new Element\Hidden("form", "assignExaminator")); $form->addElement(new Element\Textbox('Username:'******'username', array('validation' => new Validation\RegExp('/^[a-z\\d]{2,64}$/', 'Error: The %element% field must contain a username.'), 'required' => 1, 'longDesc' => 'This user will be added as an examinator to the course'))); $form->addElement(new Element\Button("Add user")); $form->addElement(new Element\Button("Cancel", "button", array("onclick" => "history.go(-1);"))); $form->render(); }
} // Get course id $cid = getCID(); // Namespaces to use use PFBC\Form; use PFBC\Element; use PFBC\Validation; // If form is submitted and correct if (!empty($_POST) && Form::isValid("assignCourseAdmin", false)) { $uid = findUser($_POST['username']); // Get current Course $course = $user->getCourse($cid); if ($uid == -1) { Form::setError('assignCourseAdmin', 'Error: Unable to find that user.'); header("Location: ?view=assigncourseadmin&cid={$cid}"); } else { Form::clearValues('assignCourseAdmin'); } // Add user to admins $course->addAdmin($uid); echo '<h3>Success!</h3><a href="?view=course&cid=' . $cid . '"><button class="btn btn-success">Go back</button></a>'; } else { $form = new Form("assignCourseAdmin"); $form->configure(array("action" => "?view=assigncourseadmin&cid={$cid}")); $form->addElement(new Element\HTML('<legend>Assign new course administrator</legend>')); $form->addElement(new Element\Hidden("form", "assignCourseAdmin")); $form->addElement(new Element\Textbox('Username:'******'username', array('validation' => new Validation\RegExp('/^[a-z\\d]{2,64}$/', 'Error: The %element% field must contain a username.'), 'required' => 1, 'longDesc' => 'This user will be added as a course admin to the course'))); $form->addElement(new Element\Button("Add user")); $form->addElement(new Element\Button("Cancel", "button", array("onclick" => "history.go(-1);"))); $form->render(); }
// If form is submitted and correct if (!empty($_POST) && Form::isValid("addUser", false)) { $uid = findUser($_POST['username']); // Get current Course $course = $user->getCourse($cid); if ($uid == -1) { Form::setError('addUser', 'Error: Unable to find that user.'); header("Location: ?view=addusertocourse&cid={$cid}"); exit; } else { if ($course->userIsAssigned($uid)) { Form::setError('addUser', 'Error: That user is already assigned to this course.'); header("Location: ?view=addusertocourse&cid={$cid}"); exit; } else { Form::clearValues('addUser'); } } // Add course to user $newUser = new User($uid); $newUser->addCourse($course->id); // Add user to course $course->addUser($uid); echo '<h3>Success!</h3><a href="?view=course&cid=' . $cid . '"><button class="btn btn-success">Go back</button></a>'; } else { $form = new Form("addUser"); $form->configure(array("action" => "?view=addusertocourse&cid={$cid}")); $form->addElement(new Element\HTML('<legend>Add user to course</legend>')); $form->addElement(new Element\Hidden("form", "addUser")); $form->addElement(new Element\Textbox('Username:'******'username', array('validation' => new Validation\RegExp('/^[a-z\\d]{2,64}$/', 'Error: The %element% field must contain a username.'), 'required' => 1, 'longDesc' => 'This user will be added to the course'))); $form->addElement(new Element\Button("Add user"));
exit; } // Namespaces to use use PFBC\Form; use PFBC\Element; use PFBC\Validation; // If form is submitted and correct if (!empty($_POST) && Form::isValid("assignReviewer", false)) { $uid = findUser($_POST['username']); // Get current Course $course = $user->getCourse($cid); if ($uid == -1) { Form::setError('assignReviewer', 'Error: Unable to find that user.'); header("Location: ?view=assignreviewer&cid={$cid}"); exit; } else { Form::clearValues('assignReviewer'); } // Add user to examinators $course->addReviewer($uid); echo '<h3>Success!</h3><a href="?view=course&cid=' . $cid . '"><button class="btn btn-success">Go back</button></a>'; } else { $form = new Form("assignReviewer"); $form->configure(array("action" => "?view=assignreviewer&cid={$cid}")); $form->addElement(new Element\HTML('<legend>Assign new reviewer</legend>')); $form->addElement(new Element\Hidden("form", "assignReviewer")); $form->addElement(new Element\Textbox('Username:'******'username', array('validation' => new Validation\RegExp('/^[a-z\\d]{2,64}$/', 'Error: The %element% field must contain a username.'), 'required' => 1, 'longDesc' => 'This user will be added as a reviewer to the course'))); $form->addElement(new Element\Button("Add user")); $form->addElement(new Element\Button("Cancel", "button", array("onclick" => "history.go(-1);"))); $form->render(); }