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); }
} echo json_encode($response); die; } else { if ($action == 'loadquicklist') { require_capability('mod/setask:grade', $context); $result = comments_quick_list::get_comments(); echo json_encode($result); die; } else { if ($action == 'addtoquicklist') { require_capability('mod/setask:grade', $context); $comment = required_param('commenttext', PARAM_RAW); $width = required_param('width', PARAM_INT); $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/setask:grade', $context); $grade = $setaskment->get_user_grade($userid, true); $result = page_editor::revert_drafts($gradeid); echo json_encode($result); die; } else { if ($action == 'removefromquicklist') { require_capability('mod/setask:grade', $context); $commentid = required_param('commentid', PARAM_INT); $result = comments_quick_list::remove_comment($commentid); echo json_encode($result);