コード例 #1
0
 /**
  * Test projectFunctions
  * Testing the functions in the project- and submissionclass
  * @author Fredrik Andersson
  * @small
  * @test
  */
 public function projectFunctions()
 {
     // Create new user class
     $sub = new Submission(self::$subid);
     //Project::
     // Create new project class
     $pro = new Project(self::$proid);
     // Check if the object was created
     $this->assertNotNull($pro);
     //Here we test if the updateStage() function works!
     $this->assertEquals(2, $pro->stage);
     $pro->updateStage();
     $this->assertEquals(3, $pro->stage);
     //Submission::
     //Create a submission to the project
     $pro->createSubmission();
     //Get the latest submission in the project
     $sub;
     foreach ($pro->getSubmission() as $key => $value) {
         $sub = new Submission($value);
     }
     //Test to see if the grades are saved.
     $sub->grade = 2;
     $this->assertEquals(2, $sub->grade);
     //Comments::
     //Write a comment to the submission
     $submissionCommentIndex = array();
     $comment = "Some comment..";
     $commentId = new Comment(null, $comment);
     if ($commentId->id != -1) {
         $sub->comments[] = $commentId->id;
         $submissionCommentIndex[] = $commentId->id;
         $submissionCommentIndex = serialize($submissionCommentIndex);
         $ssth = self::$dbh->prepare(SQL_UPDATE_SUBMISSION_COMMENTGRADE_WHERE_ID);
         $ssth->bindParam(":comments", $submissionCommentIndex, PDO::PARAM_STR);
         $ssth->bindParam(":grade", $sub->grade, PDO::PARAM_INT);
         $ssth->bindParam(":id", $sub->id, PDO::PARAM_INT);
         $ssth->execute();
     }
     //See if the comment was added
     foreach ($sub->getComments() as $key => $value) {
         $this->assertEquals('Some comment..', $value->data);
     }
 }
コード例 #2
0
// Get project id
$pid = getPID();
// Get the course
$course = $GLOBALS['user']->getCourse($cid);
// Get project
$project = $course->getProject($pid);
echo '<div class="row">';
echo '<div class="col-md-3">';
echo '<h2>  Project overview  </h2>';
// List all submissions
foreach (array_reverse($project->getSubmission()) as $key => $value) {
    // Get the submission
    $submission = new Submission($value);
    echo '<h4>' . $stages[$submission->stage] . '</h4>';
    echo 'Date: ' . $submission->date->format('Y-m-d H:i');
    foreach ($submission->getComments() as $key => $value) {
        echo '</br>Comment: ' . $value->data;
    }
    if ($submission->grade > 0 && $submission->grade < count($grades)) {
        echo '</br>Grade: ' . $grades[$submission->grade];
    } else {
        if ($submission->grade == 0) {
            if ($GLOBALS['user']->hasPrivilege("canGradeProjects")) {
                echo '<br><a href="?view=examinatorgrading&pid=' . $project->id . '&sid=' . $submission->id . '">Grade this submission</a>';
            }
            if ($submission->userHasReviewed()) {
                echo '<br><a href="?view=projectreviews&sid=' . $submission->id . '">View reviews</a>';
            }
            if ($stages[$submission->stage] == STAGE_PLAN && $GLOBALS['user']->hasPrivilege("canReview")) {
                echo '<br><a href="?view=reviewplan&sid=' . $submission->id . '">Review this submission</a>';
            } else {