Commit b7e795fa by Xavier Antoviaque

Add `max_attempt_reached` message type & update README

parent a4d401bd
......@@ -72,6 +72,9 @@ Second XBlock instance:
All is good now...
<html><p>Congratulations!</p></html>
</message>
<message type="incomplete">
<html><p>Still some work to do...</p></html>
</message>
</mentoring>
```
......@@ -95,6 +98,9 @@ Second XBlock instance:
All is good now...
<html><p>Congratulations!</p></html>
</message>
<message type="incomplete">
<html><p>Still some work to do...</p></html>
</message>
</mentoring>
```
......@@ -124,7 +130,8 @@ Second XBlock instance:
### 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
<mentoring url_name="mcq_1" enforce_dependency="false" max_attempts="3">
<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:
All is good now...
<html><p>Congratulations!</p></html>
</message>
<message type="max_attempts_reached">
<html><p>Maximum number of attempts reached</p></html>
</message>
</mentoring>
```
......
......@@ -143,11 +143,13 @@ class MentoringBlock(XBlockWithLightChildren):
completed = True
# 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
if completed:
message = self.get_message_html('completed')
elif self.max_attempts_reached:
message = self.get_message_html('max_attempts_reached')
else:
message = self.get_message_html('incomplete')
......@@ -180,6 +182,10 @@ class MentoringBlock(XBlockWithLightChildren):
'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):
for child in self.get_children_objects():
if isinstance(child, MentoringMessageBlock) and child.type == message_type:
......
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