Commit 8ac0305c by Xavier Antoviaque

Merge pull request #30 from edx-solutions/message-incomplete

message-incomplete: Add "incomplete" message type for errors
parents 86c53315 b7e795fa
...@@ -72,6 +72,9 @@ Second XBlock instance: ...@@ -72,6 +72,9 @@ Second XBlock instance:
All is good now... All is good now...
<html><p>Congratulations!</p></html> <html><p>Congratulations!</p></html>
</message> </message>
<message type="incomplete">
<html><p>Still some work to do...</p></html>
</message>
</mentoring> </mentoring>
``` ```
...@@ -95,6 +98,9 @@ Second XBlock instance: ...@@ -95,6 +98,9 @@ Second XBlock instance:
All is good now... All is good now...
<html><p>Congratulations!</p></html> <html><p>Congratulations!</p></html>
</message> </message>
<message type="incomplete">
<html><p>Still some work to do...</p></html>
</message>
</mentoring> </mentoring>
``` ```
...@@ -124,7 +130,8 @@ Second XBlock instance: ...@@ -124,7 +130,8 @@ Second XBlock instance:
### Maximum Attempts ### Maximum Attempts
You can set the number of maximum attempts for the unit completion: You can set the number of maximum attempts for the unit completion, as well as
a feedback message when the maximum number of attempts is reached:
```xml ```xml
<mentoring url_name="mcq_1" enforce_dependency="false" max_attempts="3"> <mentoring url_name="mcq_1" enforce_dependency="false" max_attempts="3">
<mrq name="mrq_1_1" type="choices" hide_results="true"> <mrq name="mrq_1_1" type="choices" hide_results="true">
...@@ -136,6 +143,9 @@ You can set the number of maximum attempts for the unit completion: ...@@ -136,6 +143,9 @@ You can set the number of maximum attempts for the unit completion:
All is good now... All is good now...
<html><p>Congratulations!</p></html> <html><p>Congratulations!</p></html>
</message> </message>
<message type="max_attempts_reached">
<html><p>Maximum number of attempts reached</p></html>
</message>
</mentoring> </mentoring>
``` ```
......
...@@ -143,13 +143,15 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -143,13 +143,15 @@ class MentoringBlock(XBlockWithLightChildren):
completed = True completed = True
# server-side check to not set completion if the max_attempts is reached # server-side check to not set completion if the max_attempts is reached
if self.max_attempts > 0 and self.num_attempts >= self.max_attempts: if self.max_attempts_reached:
completed = False completed = False
if completed: if completed:
message = self.get_message_html('completed') message = self.get_message_html('completed')
elif self.max_attempts_reached:
message = self.get_message_html('max_attempts_reached')
else: else:
message = '' message = self.get_message_html('incomplete')
if self.has_missing_dependency: if self.has_missing_dependency:
completed = False completed = False
...@@ -180,6 +182,10 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -180,6 +182,10 @@ class MentoringBlock(XBlockWithLightChildren):
'num_attempts': self.num_attempts 'num_attempts': self.num_attempts
} }
@property
def max_attempts_reached(self):
return self.max_attempts > 0 and self.num_attempts >= self.max_attempts
def get_message_fragment(self, message_type): def get_message_fragment(self, message_type):
for child in self.get_children_objects(): for child in self.get_children_objects():
if isinstance(child, MentoringMessageBlock) and child.type == message_type: if isinstance(child, MentoringMessageBlock) and child.type == message_type:
......
...@@ -42,4 +42,7 @@ ...@@ -42,4 +42,7 @@
<message type="completed"> <message type="completed">
<html><p>Congratulations!</p></html> <html><p>Congratulations!</p></html>
</message> </message>
<message type="incomplete">
<html><p>Still some work to do...</p></html>
</message>
</mentoring> </mentoring>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment