Skip to content

Commit

Permalink
Revert "Ignore questions that have a different author when editing"
Browse files Browse the repository at this point in the history
This reverts commit cf2eb12.
  • Loading branch information
gikaragia committed Feb 22, 2021
1 parent 1adb963 commit 0bcd5a4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 64 deletions.
Expand Up @@ -215,14 +215,6 @@ public function save_quiz( WP_REST_Request $request ) {

$question_ids = [];
foreach ( $json_params['questions'] as $question ) {
if ( isset( $question['id'] ) ) {
$question_post = get_post( $question['id'] );

if ( wp_get_current_user()->ID !== (int) $question_post->post_author ) {
continue;
}
}

$question_id = $this->save_question( $question );

if ( is_wp_error( $question_id ) ) {
Expand Down
Expand Up @@ -702,62 +702,6 @@ public function testQuestionValidationFails() {
$this->assertEquals( $response->get_status(), 400 );
}

/**
* Tests editing multiple choice question properties.
*/
public function testTeacherCanPostMultipleChoiceQuestion() {
$this->login_as_teacher();

list( $quiz_id ) = $this->create_lesson_with_quiz();
$first_teacher_question_id = $this->factory->question->create(
[
'question_type' => 'multiple-choice',
'quiz_id' => $quiz_id,
]
);

$this->login_as_teacher_b();
list( $lesson_id ) = $this->create_lesson_with_quiz();

$body = [
'options' => [],
'questions' => [
[
'title' => 'Will it blend?',
'description' => 'That is the question.',
'grade' => 30,
'type' => 'multiple-choice',
'options' => [
[
'label' => 'Yes.',
'correct' => false,
],
[
'label' => 'Definitely.',
'correct' => true,
],
],
'random_order' => true,
'answer_feedback' => 'Don\'t breathe this!',
],
[
'id' => $first_teacher_question_id,
'title' => 'Updated title',
'type' => 'multiple-choice',
],
],
];

$this->send_post_request( $lesson_id, $body );

$questions = Sensei()->quiz->get_questions( Sensei()->lesson->lesson_quizzes( $lesson_id ) );

$this->assertCount( 1, $questions );

$this->assertEquals( 'Will it blend?', $questions[0]->post_title );
$this->assertEquals( 'That is the question.', $questions[0]->post_content );
}

/**
* Helper method to send and validate a GET request.
*
Expand Down

0 comments on commit 0bcd5a4

Please sign in to comment.