| | 1 | == Writer Edits an Existing Chapter |
| | 2 | |
| | 3 | === Actor: **Writer** |
| | 4 | A writer edits the content of an already published chapter, for example to apply corrections or improvements. |
| | 5 | |
| | 6 | **1.** The writer navigates to their story and selects a chapter to edit. |
| | 7 | |
| | 8 | **2.** The system retrieves the current chapter content. |
| | 9 | {{{#!sql |
| | 10 | SELECT chapter_id, chapter_number, chapter_name, title, |
| | 11 | content, word_count, updated_at |
| | 12 | FROM CHAPTER |
| | 13 | WHERE chapter_id = 1 AND story_id = 1; |
| | 14 | }}} |
| | 15 | |
| | 16 | **3.** The writer modifies the chapter content and submits the changes. |
| | 17 | |
| | 18 | **4.** The system updates the chapter record with the new content and recalculates the word count. |
| | 19 | {{{#!sql |
| | 20 | UPDATE CHAPTER |
| | 21 | SET content = 'The ground trembled beneath the Crystal Mountains. Updated content here...', |
| | 22 | word_count = 3500, |
| | 23 | updated_at = CURRENT_TIMESTAMP |
| | 24 | WHERE chapter_id = 1 AND story_id = 1; |
| | 25 | }}} |
| | 26 | |
| | 27 | **5.** The system checks if there are any pending AI suggestions for this chapter that may now be outdated. |
| | 28 | {{{#!sql |
| | 29 | SELECT ai.suggestion_id, ai.original_text, ai.suggested_text |
| | 30 | FROM AI_SUGGESTION ai |
| | 31 | JOIN NEED_APPROVAL na ON ai.suggestion_id = na.suggestion_id |
| | 32 | WHERE na.chapter_id = 1 AND ai.accepted = FALSE; |
| | 33 | }}} |
| | 34 | |
| | 35 | **6.** The system notifies the writer of any pending unreviewed suggestions that may be affected by the edit. |
| | 36 | |
| | 37 | **7.** The system confirms the chapter was updated successfully and displays the updated version. |