original_string: public function serialize(UserState $state)
      {
          $saveFile = sprintf('%s/%s', $this->path, static::SAVE_FILE);
  
          $data = file_exists($saveFile)
              ? $this->readJson($saveFile)
              : [];
  
          $data[$this->workshopName] = [
              'completed_exercises'   => $state->getCompletedExercises(),
              'current_exercise'      => $state->getCurrentExercise(),
          ];
  
          return file_put_contents($saveFile, json_encode($data));
      }
code: public function serialize(UserState $state)
      {
          $saveFile = sprintf('%s/%s', $this->path, static::SAVE_FILE);
  
          $data = file_exists($saveFile)
              ? $this->readJson($saveFile)
              : [];
  
          $data[$this->workshopName] = [
              'completed_exercises'   => $state->getCompletedExercises(),
              'current_exercise'      => $state->getCurrentExercise(),
          ];
  
          return file_put_contents($saveFile, json_encode($data));
      }
code_tokens: public function serialize ( UserState $ state ) { $ saveFile = sprintf ( '%s/%s' , $ this -> path , static :: SAVE_FILE ) ; $ data = file_exists ( $ saveFile ) ? $ this -> readJson ( $ saveFile ) : [ ] ; $ data [ $ this -> workshopName ] = [ 'completed_exercises' => $ state -> getCompletedExercises ( ) , 'current_exercise' => $ state -> getCurrentExercise ( ) , ] ; return file_put_contents ( $ saveFile , json_encode ( $ data ) ) ; }
docstring: Save the students state for this workshop to disk.
  
  @param UserState $state
  @return int
docstring_tokens: Save the students state for this workshop to disk .