ed-api-client 0.1.7__tar.gz → 0.1.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ed-api-client
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: A client for interacting with the Ed LMS
5
5
  License: MIT
6
6
  Author: David Milne
@@ -473,6 +473,7 @@ class FileSummary(File):
473
473
  _insert_intervals: List[float] = field(default_factory=list)
474
474
  _prev_insert_time: datetime.datetime = None
475
475
  _pending_deletion: str = ""
476
+ _insert_frontier: int = 0
476
477
 
477
478
  def from_file(file: File):
478
479
  fs = FileSummary(file.id, file.path, file.content)
@@ -524,7 +525,6 @@ class WorkspaceSummary:
524
525
  stop_at_first_successful_submission: bool = True,
525
526
  max_idle_seconds=30,
526
527
  min_suspicious_paste_chars=50,
527
- max_continuous_typing_seconds=2,
528
528
  ):
529
529
  """
530
530
  Build a WorkspaceSummary by replaying a workspace event log.
@@ -627,12 +627,8 @@ class WorkspaceSummary:
627
627
 
628
628
  pos = 0
629
629
 
630
- is_uninterrupted = False
631
630
  if file.prev_typing_time is not None:
632
631
  elapsed = event.at - file.prev_typing_time
633
- if elapsed.total_seconds() < max_continuous_typing_seconds:
634
- is_uninterrupted = True
635
-
636
632
  if elapsed.total_seconds() < max_idle_seconds:
637
633
  file.typing_time += elapsed
638
634
 
@@ -654,6 +650,12 @@ class WorkspaceSummary:
654
650
  )
655
651
  )
656
652
 
653
+ delete_end = pos + edit.value
654
+ if delete_end <= file._insert_frontier:
655
+ file._insert_frontier -= edit.value
656
+ elif pos < file._insert_frontier:
657
+ file._insert_frontier = pos # deletion overlaps the frontier
658
+
657
659
  file.content = file.content[:pos] + file.content[pos + edit.value :]
658
660
  file.transcribed_mask = (
659
661
  file.transcribed_mask[:pos]
@@ -673,10 +675,9 @@ class WorkspaceSummary:
673
675
  )
674
676
  )
675
677
 
676
- if (
677
- is_uninterrupted
678
- and get_code_character_count(file.content[pos:]) < 5
679
- ):
678
+ frontier_tolerance = max(10, len(file.content) // 10)
679
+ at_frontier = pos >= file._insert_frontier - frontier_tolerance
680
+ if at_frontier:
680
681
  file.transcribed_mask = (
681
682
  file.transcribed_mask[:pos]
682
683
  + get_masked_section(edit.value)
@@ -688,6 +689,11 @@ class WorkspaceSummary:
688
689
  + edit.value
689
690
  + file.transcribed_mask[pos:]
690
691
  )
692
+ n = len(edit.value)
693
+ if pos < file._insert_frontier:
694
+ file._insert_frontier += n # inserted before frontier — shift it right
695
+ else:
696
+ file._insert_frontier = pos + n # advance frontier to end of this insert
691
697
 
692
698
  if len(edit.value) > min_suspicious_paste_chars:
693
699
  if not selected_content.contains(edit.value):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ed-api-client"
3
- version = "0.1.7"
3
+ version = "0.1.8"
4
4
  description = "A client for interacting with the Ed LMS"
5
5
  authors = ["David Milne <d.n.milne@gmail.com>"]
6
6
  license = "MIT"
File without changes