def build_return_url(self):
if not self.launch_presentation_return_url:<EOL><INDENT>return None<EOL><DEDENT>lti_message_fields = ['<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>']<EOL>messages = dict([(key, getattr(self, key))<EOL>for key in lti_message_fields<EOL>if getattr(self, key, None)])<EOL>original = urlsplit(self.launch_presentation_return_url)<EOL>combined = messages.copy()<EOL>combined.update(dict(parse_qsl(original.query)))<EOL>combined_query = urlencode(combined)<EOL>return urlunsplit((<EOL>original.scheme,<EOL>original.netloc,<EOL>original.path,<EOL>combined_query,<EOL>original.fragment<EOL>))<EOL>
If the Tool Consumer sent a return URL, add any set messages to the
URL.