public function test_comments_quick_list()
 {
     $this->setUser($this->teachers[0]);
     $comments = comments_quick_list::get_comments();
     $this->assertEmpty($comments);
     $comment = comments_quick_list::add_comment('test', 45, 'red');
     $comments = comments_quick_list::get_comments();
     $this->assertEquals(count($comments), 1);
     $first = reset($comments);
     $this->assertEquals($comment, $first);
     $commentbyid = comments_quick_list::get_comment($comment->id);
     $this->assertEquals($comment, $commentbyid);
     $result = comments_quick_list::remove_comment($comment->id);
     $this->assertTrue($result);
     $comments = comments_quick_list::get_comments();
     $this->assertEmpty($comments);
 }
Example #2
0
         $colour = required_param('colour', PARAM_ALPHA);
         $result = comments_quick_list::add_comment($comment, $width, $colour);
         echo json_encode($result);
         die;
     } else {
         if ($action == 'revertchanges') {
             require_capability('mod/sepl:grade', $context);
             $grade = $seplment->get_user_grade($userid, true);
             $result = page_editor::revert_drafts($gradeid);
             echo json_encode($result);
             die;
         } else {
             if ($action == 'removefromquicklist') {
                 require_capability('mod/sepl:grade', $context);
                 $commentid = required_param('commentid', PARAM_INT);
                 $result = comments_quick_list::remove_comment($commentid);
                 echo json_encode($result);
                 die;
             } else {
                 if ($action == 'deletefeedbackdocument') {
                     require_capability('mod/sepl:grade', $context);
                     $grade = $seplment->get_user_grade($userid, true);
                     $result = document_services::delete_feedback_document($seplment, $userid, $attemptnumber);
                     $result = $result && page_editor::unrelease_drafts($grade->id);
                     echo json_encode($result);
                     die;
                 }
             }
         }
     }
 }