public static function updateSubmission()
 {
     // Process updating submissions
     $submissions = SubmissionsDB::getSubmissionsBy('submissionId', $_SESSION['arguments']);
     if (empty($submissions)) {
         HomeView::show();
         header('Location: /' . $_SESSION['base']);
     } elseif ($_SERVER["REQUEST_METHOD"] == "GET") {
         $_SESSION['submissions'] = $submissions;
         SubmissionView::showUpdate();
     } else {
         $parms = $submissions[0]->getParameters();
         $parms['submissionFile'] = array_key_exists('submissionFile', $_POST) ? $_POST['submissionFile'] : "";
         $newSubmission = new Submission($parms);
         $newSubmission->setSubmissionId($submissions[0]->getSubmissionId());
         $submission = SubmissionsDB::updateSubmission($newSubmission);
         if ($submission->getErrorCount() != 0) {
             $_SESSION['submissions'] = array($newSubmission);
             SubmissionView::showUpdate();
         } else {
             HomeView::show();
             header('Location: /' . $_SESSION['base']);
         }
     }
 }
Esempio n. 2
0
 public function testUpdateSubmission()
 {
     ob_start();
     $validSubmission = array("submitterName" => "krobbins", "assignmentNumber" => "1", "submissionFile" => "myText.apl");
     $s1 = new Submission($validSubmission);
     $s1->setSubmissionId(1);
     $_SESSION = array('submission' => $s1, 'base' => "mvcdbcrud");
     SubmissionView::showUpdate();
     $output = ob_get_clean();
     $this->assertFalse(empty($output), "It should show an update form");
 }
Esempio n. 3
0
<?php 
$validSubmission = array("submitterName" => "krobbins", "assignmentNumber" => "1", "submissionFile" => "myText.apl");
$s1 = new Submission($validSubmission);
$s1->setSubmissionId(1);
$submissions = array($s1, $s1);
$_SESSION = array('submissions' => $submissions, 'headerTitle' => "ClassBash Submissions", 'footerTitle' => "<h3>The footer goes here</h3>", 'base' => "mvcdbcrud");
SubmissionView::showall();
?>
 
 
<h2>It should show a Submission table without a header and a footer</h2>
<?php 
$s1->setSubmissionId(1);
$submissions = array($s1, $s1);
$_SESSION = array('submissions' => $submissions, 'base' => "mvcdbcrud");
SubmissionView::showall();
?>
  

<h2>It should allow updating when a valid submission is passed</h2>
<?php 
$validSubmission = array("submitterName" => "krobbins", "assignmentNumber" => "1", "submissionFile" => "myText.apl");
$s1 = new Submission($validSubmission);
$s1->setSubmissionId(1);
$_SESSION = array('submissions' => array($s1), 'base' => "mvcdbcrud");
echo $s1;
SubmissionView::showUpdate();
?>
</body>
</html>