public function test_arrays_same_at_key_integer()
 {
     $this->assertTrue(question_utils::arrays_same_at_key_integer(array(), array(), 'key'));
     $this->assertFalse(question_utils::arrays_same_at_key_integer(array(), array('key' => 1), 'key'));
     $this->assertFalse(question_utils::arrays_same_at_key_integer(array('key' => 1), array(), 'key'));
     $this->assertTrue(question_utils::arrays_same_at_key_integer(array('key' => 1), array('key' => 1), 'key'));
     $this->assertFalse(question_utils::arrays_same_at_key_integer(array('key' => 1), array('key' => 2), 'key'));
     $this->assertTrue(question_utils::arrays_same_at_key_integer(array('key' => 1), array('key' => '1'), 'key'));
     $this->assertTrue(question_utils::arrays_same_at_key_integer(array('key' => '0'), array('key' => ''), 'key'));
     $this->assertTrue(question_utils::arrays_same_at_key_integer(array(), array('key' => 0), 'key'));
 }
Example #2
0
 public function is_same_response(array $prevresponse, array $newresponse)
 {
     foreach ($this->places as $place => $notused) {
         $fieldname = $this->field($place);
         if (!question_utils::arrays_same_at_key_integer($prevresponse, $newresponse, $fieldname)) {
             return false;
         }
     }
     return true;
 }
Example #3
0
 /** This function is used by the question engine to prevent regrading of
  *  unchanged submissions.
  *
  * @param array $prevresponse
  * @param array $newresponse
  * @return boolean
  */
 public function is_same_response(array $prevresponse, array $newresponse)
 {
     if (!question_utils::arrays_same_at_key_missing_is_blank($prevresponse, $newresponse, 'answer') || !question_utils::arrays_same_at_key_integer($prevresponse, $newresponse, 'rating')) {
         return false;
     }
     return true;
 }