Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The fourth use case in the /wiki/spaces/CONNECTORS/pages/48465394is course discussions and collaboration. This page describes the relevant tasks and the operations you use in the Canvas connector and the other ESB connectors.

Overview

The flow for course collaboration is illustrated in the following diagram. The ESB connectors for Disqus will be used to connect to each service. Disqus is a service that helps you build a community of active readers and commenters.

...

  1. Create discussions in Canvas using the createDiscussionTopic operation, and create a corresponding thread in Disqus using the createThread operation.

  2. Retrieve enrolled students from Canvas using the listCourseUsers operation. When users are subscribed in Disqus using the subscribe operation, they are notified about the discussion via email and are allowed to collaborate on discussions in the thread.
  3. The comments (posts) on this thread in Disqus can be voted as the best. Each vote is considered as a point. You can retreive the post with the maximum points using the listEntries operation and can update or delete using the updateEntry and deleteEntry operations respectively. You use createEntry to create a new entry.

  4. You can retrieve all posts from Disqus using the listPosts operation.

Canvas operations
Disqus operations
Samples
Code Block
languagexml
titleSample proxy for creating a discussion topic in Canvas (title and message provided along with the request)
	<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="canvas_createDiscussionAndThread" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
    <target>
        <inSequence onError="faultHandlerSeq">
            <!--Canvas Properties-->
            <property name="canvas.apiUrl" expression="json-eval($.canvasApiUrl)" />
            <property name="canvas.accessToken" expression="json-eval($.canvasAccessToken)" />
            <property name="canvas.courseId" expression="json-eval($.canvasCourseId)" />
            <property name="canvas.title" expression="json-eval($.canvasTitle)" />
            <property name="canvas.message" expression="json-eval($.canvasMessage)" />
            <property name="canvas.discussionType" expression="json-eval($.canvasDiscussionType)" />
			
            <!--Disqus Properties-->
            <property name="disqus.apiUrl" expression="json-eval($.disqusApiUrl)" />
            <property name="disqus.apiKey" expression="json-eval($.disqusApiKey)" />
            <property name="disqus.accessToken" expression="json-eval($.disqusAccessToken)" />
            <property name="disqus.forumId" expression="json-eval($.disqusForumId)" />
            <property name="responseString" value="" scope="operation" />
			
            <!--Create the discussion topic in Canvas.-->
            <canvas.init>
                <apiUrl>{$ctx:canvas.apiUrl}</apiUrl>
                <accessToken>{$ctx:canvas.accessToken}</accessToken>
            </canvas.init>
            <canvas.createDiscussionTopic>
                <discussionType>{$ctx:canvas.discussionType}</discussionType>
                <courseId>{$ctx:canvas.courseId}</courseId>
                <message>{$ctx:canvas.message}</message>
                <title>{$ctx:canvas.title}</title>
                <published>true</published>
            </canvas.createDiscussionTopic>			
			<sequence key="removeResponseHeaders" />
			
            <property name="canvas.discussionTopicId" expression="json-eval($.id)" />
			
			<!--If the createDiscussionTopic method of Canvas fails, return an error message as response to the user and loop back. Else, continue with the scenario.-->
            <filter source="boolean(get-property('canvas.discussionTopicId'))" regex="false">
                <then>
                    <!--Since there is no ID to be returned, the ID is set to an empty JSON object - {}-->
					<property name="id" value="{}" />
                    <property name="message" expression="json-eval($)" />
					
                    <!--Call the responseHandler template.-->
                    <call-template target="responseHandlerTemplate">
						<with-param name="activity" value="canvas_createNewDiscussionTopiInCanvas" />
                        <with-param name="id" value="{$ctx:id}" />
                        <with-param name="status" value="Failed" />
                        <with-param name="message" value="{$ctx:message}" />
                    </call-template>
                    <loopback />
                </then>
                <else>
                    <property name="canvas.discussionTitle" expression="json-eval($.title)" />
                    <property name="canvas.user" expression="json-eval($.user_name)" />
					
                    <!--Invalidate uri.var.accessToken which was set in the canvas.createDiscussionTopic template to prevent ambiguity.-->
                    <property name="uri.var.accessToken" value="" action="remove" />
					
                    <!--Create the thread in Disqus.-->
                    <disqus.init>
                        <apiUrl>{$ctx:disqus.apiUrl}</apiUrl>
                        <apiKey>{$ctx:disqus.apiKey}</apiKey>
                        <accessToken>{$ctx:disqus.accessToken}</accessToken>
                    </disqus.init>
                    <disqus.createThread>
                        <forumId>{$ctx:disqus.forumId}</forumId>
                        <title>{$ctx:canvas.title}</title>
                        <message>{$ctx:canvas.message}</message>
                    </disqus.createThread>					
					<sequence key="removeResponseHeaders" />
					
					<property name="disqus.threadId" expression="json-eval($.response.id)" />
					
					<!--If the thread CANNOT be created in Disqus, return an error message as response to the user and loop back. Else, continue with the scenario.-->
                    <filter source="boolean(get-property('disqus.threadId'))" regex="false">
                        <then>
                            <property name="id" expression="fn:concat('canvas_discussionTopicId:', get-property('canvas.discussionTopicId'))" />
                            <property name="message" expression="json-eval($)" />
                            <call-template target="responseHandlerTemplate">
								<with-param name="activity" value="canvas_createNewThreadInDisqus" />
                                <with-param name="id" value="{$ctx:id}" />
                                <with-param name="status" value="Failed" />
                                <with-param name="message" value="{$ctx:message}" />
                            </call-template>
                            <loopback />
                        </then>
                        <else>
							<!--Send the success message to the user.-->
							<property name="disqus.threadLink" expression="json-eval($.response.link)" />
                            <property name="disqus.threadTitle" expression="json-eval($.response.title)" />
                            <property name="disqus.forum" expression="json-eval($.response.forum)" />
							
                            <property name="id" expression="fn:concat('canvas_discussionTopicId:', get-property('canvas.discussionTopicId'), ',disqus_threadId:', get-property('disqus.threadId'))" />
                            <property name="message" expression="fn:concat('Discussion topic was created in Canvas by ', get-property('canvas.user'), '. Thread [Link: ', get-property('disqus.threadLink'), '] was created in ', get-property('disqus.forum'), ' forum in Disqus.')" />
                            
							<!--Call the responseHandler template.-->
							<call-template target="responseHandlerTemplate">
								<with-param name="activity" value="canvas_disqus_createNewDiscussionTopicAndThread" />
                                <with-param name="id" value="{$ctx:id}" />
                                <with-param name="status" value="Created" />
                                <with-param name="message" value="{$ctx:message}" />
                            </call-template>
							
                            <!--List students enrolled for courses.-->
                            <canvas.init>
                                <apiUrl>{$ctx:canvas.apiUrl}</apiUrl>
                                <accessToken>{$ctx:canvas.accessToken}</accessToken>
                            </canvas.init>
                            <canvas.listCourseUsers>
                                <enrollmentType>student</enrollmentType>
                                <include>email</include>
                                <page>1</page>
                                <perPage>200</perPage>
                                <courseId>{$ctx:canvas.courseId}</courseId>
                            </canvas.listCourseUsers>		
							<sequence key="removeResponseHeaders" />
							
                            <!--Invalidate uri.var.accessToken which was set in the canvas.createDiscussionTopic template to prevent ambiguity.-->
                            <property name="uri.var.accessToken" value="" action="remove" />
							
                            <property name="noOfStudents" expression="count(//jsonArray/jsonElement)" scope="operation" />
                            <property name="studentIndex" expression="0" scope="operation" />
							
                            <!--FOR EACH Student: BEGIN-->
                            <iterate continueParent="false" id="students" expression="//jsonArray/jsonElement" sequential="true">
                                <target>
                                    <sequence>
										<!--Store student details.-->
                                        <property name="canvas.studentEmail" expression="//jsonElement/email/text()" />
										
										<!--Subscribe the student to the thread in Disqus.-->
                                        <disqus.init>
                                            <apiUrl>{$ctx:disqus.apiUrl}</apiUrl>
                                            <apiKey>{$ctx:disqus.apiKey}</apiKey>
                                        </disqus.init>
                                        <disqus.subscribe>
                                            <threadId>{$ctx:disqus.threadId}</threadId>
                                            <email>{$ctx:canvas.studentEmail}</email>
                                            <subscribe>true</subscribe>
                                        </disqus.subscribe>										
										<sequence key="removeResponseHeaders" />
										
										<!--Since the API doesn't return a meaningful message for the success scenario, Status Code of the response is used to infer successful subscription.-->
                                        <property name="statusCode" expression="$axis2:HTTP_SC" />	
                                        <property name="id" expression="fn:concat('canvas_studentEmail:', get-property('canvas.studentEmail'))" />									
                                        <filter source="get-property('statusCode')" regex="2[0-9][0-9]">
                                            <then>
                                                <property name="status" value="Added" />
                                                <property name="message" expression="fn:concat('Student has been added to the subscribers list of the thread [', get-property('disqus.threadTitle'), '].')" />
                                            </then>
                                            <else>
												<property name="apiErrorResponse" expression="json-eval($)" />
                                                <property name="status" value="Failed" />
                                                <property name="message" expression="json-eval($)" />
                                            </else>
                                        </filter>
										
                                        <!--Call the response handler template.-->
                                        <call-template target="responseHandlerTemplate">
											<with-param name="activity" value="disqus_subscribeStudentToThread" />
                                            <with-param name="id" value="{$ctx:id}" />
                                            <with-param name="status" value="{$ctx:status}" />
                                            <with-param name="message" value="{$ctx:message}" />
                                        </call-template>
										
										<!--Increment the student count.-->
                                        <property name="studentIndex" expression="get-property('operation', 'studentIndex') + 1" scope="operation" />
                                    </sequence>
                                </target>
                            </iterate>							
                            <!--FOR EACH Student: END-->
							
                            <filter xpath="get-property('operation', 'noOfStudents') = get-property('operation', 'studentIndex')">
                                <then>
                                    <loopback />
                                </then>
                            </filter>
							
                        </else>						
                    </filter>
					
                </else>				
            </filter>
			
        </inSequence>
        <outSequence>
            <payloadFactory media-type="json">
                <format>{
					"Response":{
						"process":"canvas_createDiscussionAndThread",
						"activityResponse": [$1]
					}
				}</format>
                <args>
                    <arg expression="get-property('operation','responseString')" />
                </args>
            </payloadFactory>
            <property name="messageType" value="application/json" scope="axis2" />
            <send />
        </outSequence>
    </target>
    <description />
</proxy>
Code Block
languagexml
titleSample request for creating a discussion topic in Canvas (title and message provided along with the request)
{
	"canvasApiUrl":"https://orion-city.acme.instructure.com",
	"canvasAccessToken":"51451~fwK08jirhrTKFiuyua8H3rpFVQtZJu7D7rf3mi7pecuHxMglbY24XOxQ42UWTvam",
	"canvasCourseId":"121",
	"canvasTitle":"Enterprise Java Beans 2.1",
	"canvasMessage":"Why is Enterprise Javabeans 2.1 preferred more?",
	"canvasDiscussionType":"side_comment",
	"disqusApiUrl": "https://disqus.com",
    "disqusApiKey": "hNCiYG7sBpsyavTbpysXNgHKJ8YDb9IFr3LpcVGj3eEZTPCicTJxNBoHub4etovu",
    "disqusAccessToken": "e208cc08128f480597fdf91cc0708187",
    "disqusForumId": "canvas-scenario"
}
Code Block
languagexml
titleSample proxy for updating the entries of a particular discussion topic in Canvas, with the top posts (filtered by no. of votes) from the corresponding thread created in Disqus
	<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="canvas_updateDiscussionTopicWithTopPosts" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
    <target>
        <inSequence onError="faultHandlerSeq">
		
            <!--Canvas Properties-->
            <property name="canvas.apiUrl" expression="json-eval($.canvasApiUrl)" />
            <property name="canvas.accessToken" expression="json-eval($.canvasAccessToken)" />
            <property name="canvas.courseId" expression="json-eval($.canvasCourseId)" />
			
            <!--Disqus Properties-->
            <property name="disqus.apiUrl" expression="json-eval($.disqusApiUrl)" />
            <property name="disqus.apiKey" expression="json-eval($.disqusApiKey)" />
            <property name="disqus.topPosts" expression="json-eval($.disqusTopPosts)" />
            <property name="disqus.forumId" expression="json-eval($.disqusForumId)" />
			
            <!--Array of ID Map Objects-->
            <property name="canvas.disqus.idMap" expression="json-eval($.canvasDisqusIdMap)" />
			
            <property name="responseString" value="" scope="operation" />
			
            <property name="noOfDiscussions" expression="count(//jsonObject/canvasDisqusIdMap)" scope="operation" />
            <property name="discussionIndex" expression="0" scope="operation" />
            <property name="noOfEntries" expression="0" scope="operation" />
            <property name="entryIndex" expression="0" scope="operation" />
			
			<!--If the canvasDisqusIdMap array is empty, send an error message to the user and loop back.-->
            <filter xpath="get-property('operation', 'noOfDiscussions') = get-property('operation', 'discussionIndex')">
				<!--If no entries are found in canvasDisqusIdMap, respond immediately.-->
                <then>
                    <payloadFactory media-type="json">
                        <format>{
							"Response":{
								"activity":"canvas_updateDiscussionTopicsWithTopPosts",
								"activityResponse":"canvasDisqusIdMap is empty - No entries to process."
							}
						}</format>
                        <args>
                            <arg expression="get-property('operation','responseString')" />
                        </args>
                    </payloadFactory>
                    <property name="messageType" value="application/json" scope="axis2" />
                    <respond />
                </then>
                <else>
                    <!--FOR EACH DiscussionID Map - Delete Loop: BEGIN-->
                    <iterate continueParent="false" id="discussions" expression="//jsonObject/canvasDisqusIdMap" sequential="true">
                        <target>
                            <sequence>
								<!--Increment the discussion count by 1.-->
                                <property name="discussionIndex" expression="get-property('operation', 'discussionIndex') + 1" scope="operation" />
								
                                <!--Store the discussion and thread details.-->
                                <property name="canvas.discussionId" expression="//canvasDisqusIdMap/canvas_discussionTopicId/text()" />
                                <property name="disqus.threadId" expression="//canvasDisqusIdMap/disqus_threadId/text()" />
								
                                <!--First, check whether there are any featured posts for the thread in Disqus.-->
                                <disqus.init>
                                    <apiUrl>{$ctx:disqus.apiUrl}</apiUrl>
                                    <apiKey>{$ctx:disqus.apiKey}</apiKey>
                                </disqus.init>
                                <disqus.listPosts>
                                    <forumId>{$ctx:disqus.forumId}</forumId>
                                    <limit>{$ctx:disqus.topPosts}</limit>
                                    <popular>true</popular>
                                    <include>unapproved,approved,highlighted</include>
                                    <order>best</order>
                                    <related>thread</related>
                                    <threadId>{$ctx:disqus.threadId}</threadId>
                                </disqus.listPosts>								
                                <sequence key="removeResponseHeaders" />
								
								<property name="noOfPosts" expression="count(//jsonObject/response)" />
								<property name="postIndex" expression="0" />
								
                                <!--Process only if there are any posts to update.-->
                                <filter xpath="get-property('noOfPosts') != get-property('postIndex')">
                                    <then>			
									
                                        <!--List all entries that are added to the discussion topic.-->
                                        <canvas.init>
                                            <apiUrl>{$ctx:canvas.apiUrl}</apiUrl>
                                            <accessToken>{$ctx:canvas.accessToken}</accessToken>
                                        </canvas.init>
                                        <canvas.listEntries>
                                            <topicId>{$ctx:canvas.discussionId}</topicId>
                                            <perPage>100</perPage>
                                            <courseId>{$ctx:canvas.courseId}</courseId>
                                        </canvas.listEntries>										
                                        <sequence key="removeResponseHeaders" />
										
										<property name="noOfEntries" expression="count(//jsonArray/jsonElement)" />
                                        <property name="entryIndex" expression="0" />
										
                                        <!--If there are any entries to be deleted, delete them.-->
                                        <filter xpath="get-property('noOfEntries') != get-property('entryIndex')">
                                            <then>				
											
                                                <!--Increment the no. of entries to be deleted by the appropriate no.-->
                                                <property name="noOfEntries" expression="get-property('operation','noOfEntries') + count(//jsonArray/jsonElement)" scope="operation" />
                                                
												<!--FOR EACH Entry: BEGIN-->
                                                <iterate continueParent="false" id="entries" expression="//jsonArray/jsonElement" sequential="true">
                                                    <target>
                                                        <sequence>
                                                            <property name="canvas.entryId" expression="//jsonElement/id/text()" />
															
                                                            <!--Delete the entry.-->
                                                            <canvas.init>
                                                                <apiUrl>{$ctx:canvas.apiUrl}</apiUrl>
                                                                <accessToken>{$ctx:canvas.accessToken}</accessToken>
                                                            </canvas.init>
                                                            <canvas.deleteEntry>
                                                                <topicId>{$ctx:canvas.discussionId}</topicId>
                                                                <courseId>{$ctx:canvas.courseId}</courseId>
                                                                <entryId>{$ctx:canvas.entryId}</entryId>
                                                            </canvas.deleteEntry>															
                                                            <sequence key="removeResponseHeaders" />
															
                                                            <!--Increment the entry count.-->
                                                            <property name="entryIndex" expression="get-property('operation','entryIndex') + 1" scope="operation" />
                                                        </sequence>
                                                    </target>
                                                </iterate>
                                                <!--FOR EACH Entry: END-->
												
                                            </then>
                                        </filter>
										
                                    </then>
                                </filter>
								
                            </sequence>
                        </target>
                    </iterate>					
                    <!--FOR EACH DiscussionID Map - Delete Loop: END-->
					
					<!--Start adding posts.-->
                    <filter xpath="(get-property('operation', 'noOfDiscussions') = get-property('operation', 'discussionIndex')) and
										(get-property('operation', 'noOfEntries') = get-property('operation', 'entryIndex'))">
                        <then>
                            <property name="discussionIndex" expression="0" scope="operation" />
                            <property name="noOfPosts" expression="0" scope="operation" />
                            <property name="postIndex" expression="0" scope="operation" />
							
                            <!--Set the User Payload for the iteration.-->
                            <payloadFactory media-type="json">
                                <format>{
											"idmap": $1
										}
								</format>
                                <args>
                                    <arg expression="get-property('canvas.disqus.idMap')" />
                                </args>
                            </payloadFactory>
							
                            <!--FOR EACH DiscussionID Map: BEGIN-->
                            <iterate continueParent="false" id="discussions" expression="//jsonObject/idmap" sequential="true">
                                <target>
                                    <sequence>				
									
                                        <!--Increment the discussion count.-->
                                        <property name="discussionIndex" expression="get-property('operation', 'discussionIndex') + 1" scope="operation" />
										
                                        <!--Store the discussion and thread details.-->
                                        <property name="canvas.discussionId" expression="//idmap/canvas_discussionTopicId/text()" />
                                        <property name="disqus.threadId" expression="//idmap/disqus_threadId/text()" />
										
										<!--Invalidate uri.var.accessToken which was set in the canvas.createDiscussionTopic template to prevent ambiguity.-->
										<property name="uri.var.accessToken" value="" action="remove" />
										<property name="uri.var.query" value="" action="remove" />
										
                                        <!--List and check whether there are any featured posts for the thread in Disqus.-->
                                        <disqus.init>
                                            <apiUrl>{$ctx:disqus.apiUrl}</apiUrl>
                                            <apiKey>{$ctx:disqus.apiKey}</apiKey>
                                        </disqus.init>
                                        <disqus.listPosts>
                                            <forumId>{$ctx:disqus.forumId}</forumId>
                                            <limit>{$ctx:disqus.topPosts}</limit>
                                            <popular>true</popular>
                                            <include>unapproved,approved,highlighted</include>
                                            <order>best</order>
                                            <related>thread</related>
                                            <threadId>{$ctx:disqus.threadId}</threadId>
                                        </disqus.listPosts>										
                                        <sequence key="removeResponseHeaders" />
										
										<property name="noOfPosts" expression="count(//jsonObject/response)" />
                                        <property name="postIndex" expression="0" />
										
                                        <!--If the thread doesn't have any posts, send a message to the user. Else, continue with the iteration.-->
                                        <filter xpath="get-property('noOfPosts') = get-property('postIndex')">
                                            <!---->
                                            <then>
                                                <property name="id" expression="fn:concat('canvas_discussionTopicId:', get-property('canvas.discussionId'), ',disqus_threadId:', get-property('disqus.threadId'))" />
                                                <property name="status" value="Empty" />
                                                <property name="message" expression="fn:concat('No posts were found in Disqus for Thread ID: ', get-property('disqus.threadId'))" />
                                                <call-template target="responseHandlerTemplate">
                                                    <with-param name="activity" value="disqus_listPopularThreads" />
                                                    <with-param name="id" value="{$ctx:id}" />
                                                    <with-param name="status" value="{$ctx:status}" />
                                                    <with-param name="message" value="{$ctx:message}" />
                                                </call-template>
                                            </then>
                                            <else>
                                                <!--Increment the no. of entries to be deleted.-->
                                                <property name="noOfPosts" expression="get-property('operation','noOfPosts') + count(//jsonObject/response)" scope="operation" />
												
                                                <iterate continueParent="false" id="entries" expression="//jsonObject/response" sequential="true">
                                                    <target>
                                                        <sequence>
															<property name="disqus.post.id" expression="//response/id/text()" />
                                                            <property name="disqus.message" expression="//response/raw_message/text()" />
															<property name="disqus.commentor" expression="//response/author/name/text()" />
															<property name="disqus.likes" expression="//response/points/text()" />
															<property name="messageToUpdate" expression="fn:concat(get-property('disqus.message'), ' - ', get-property('disqus.commentor'), ' [', get-property('disqus.likes'), ' Point(s)]')" />
															
															<!--Build the ID string.-->
															<property name="id" expression="fn:concat('canvas_discussionTopicId:', get-property('canvas.discussionId'), ',disqus_threadId:', get-property('disqus.threadId'), ',disqus_postId:', get-property('disqus.post.id'))" />
															
                                                            <!--Add Entry. Message would be null as the API expects multipart/form-data.-->
                                                            <canvas.init>
                                                                <apiUrl>{$ctx:canvas.apiUrl}</apiUrl>
                                                                <accessToken>{$ctx:canvas.accessToken}</accessToken>
                                                            </canvas.init>
                                                            <canvas.createEntry>
                                                                <topicId>{$ctx:canvas.discussionId}</topicId>
                                                                <courseId>{$ctx:canvas.courseId}</courseId>
                                                            </canvas.createEntry>															
                                                            <sequence key="removeResponseHeaders" />
															
                                                            <property name="canvas.updatEntryId" expression="json-eval($.id)" />
															
															<!--If creation is unsuccessful, set an error message to be sent to the user. Else, continue with the process.-->
															<filter source="boolean(get-property('canvas.updatEntryId'))" regex="false">
																<then>
																	<property name="status" value="Failure" />
																	<property name="message" expression="json-eval($)" />
																</then>
																<else>
																
																	<!--Update the entry with the message.-->
																	<canvas.init>
																		<apiUrl>{$ctx:canvas.apiUrl}</apiUrl>
																		<accessToken>{$ctx:canvas.accessToken}</accessToken>
																	</canvas.init>
																	<canvas.updateEntry>
																		<topicId>{$ctx:canvas.discussionId}</topicId>
																		<courseId>{$ctx:canvas.courseId}</courseId>
																		<message>{$ctx:messageToUpdate}</message>
																		<entryId>{$ctx:canvas.updatEntryId}</entryId>
																	</canvas.updateEntry>																	
																	<sequence key="removeResponseHeaders" />
																	
																	<property name="canvas.updatEntryId" expression="json-eval($.id)" />
																	
																	<!--If updation is unsuccessful, set an error message to be sent to the user. Else, set a success message for the user.-->
																	<filter source="boolean(get-property('canvas.updatEntryId'))" regex="true">
																		<!--If the update is successful.-->
																		<then>
																			<property name="status" value="Success" />
																			<property name="message" value="Canvas discussion topic entries successfully synchronized with Disqus thread posts." />
																		</then>
																		<!--If the update is unsuccessful.-->
																		<else>
																			<property name="apiErrorResponse" expression="json-eval($)" />
																			<property name="status" value="Failure" />
																			<property name="message" expression="json-eval($)" />
																		</else>
																	</filter>
																	
																</else>
															</filter>
															
															<!--Call the response handler template.-->
															<call-template target="responseHandlerTemplate">
																<with-param name="activity" value="canvas_updateDiscussionTopicWithTopPosts" />
																<with-param name="id" value="{$ctx:id}" />
																<with-param name="status" value="{$ctx:status}" />
																<with-param name="message" value="{$ctx:message}" />
															</call-template>
                                                            
															
                                                            <!--Increment the post count.-->
                                                            <property name="postIndex" expression="get-property('operation','postIndex') + 1" scope="operation" />
															
                                                        </sequence>
                                                    </target>
                                                </iterate>
												
                                            </else>
                                        </filter>
										
                                    </sequence>
                                </target>
                            </iterate>
                            <!--FOR EACH  DiscussionID Map: END-->
							
							<filter xpath="(get-property('operation', 'noOfDiscussions') = get-property('operation', 'discussionIndex')) and
										(get-property('operation', 'noOfPosts') = get-property('operation', 'postIndex'))">
								<then>
									<loopback />
								</then>
							</filter>
                        </then>
                    </filter>
					
                </else>                
            </filter>
			
        </inSequence>
        <outSequence>
            <payloadFactory media-type="json">
                <format>{
					"Response":{
						"activity":"canvas_updateDiscussionTopicsWithTopPosts",
						"activityResponse":[$1]
					}
				}</format>
                <args>
                    <arg expression="get-property('operation','responseString')" />
                </args>
            </payloadFactory>
            <property name="messageType" value="application/json" scope="axis2" />
            <send />
        </outSequence>
    </target>
    <description />
</proxy>
Code Block
languagexml
titleSample request for updating the entries of a particular discussion topic in Canvas, with the top posts (filtered by no. of votes) from the corresponding thread created in Disqus
{
	"canvasApiUrl":"https://orion-city.acme.instructure.com",
	"canvasAccessToken":"51451~fwK08jirhrTKFiuyua8H3rpFVQtZJu7D7rf3mi7pecuHxMglbY24XOxQ42UWTvam",
	"canvasCourseId":"121",
	"canvasDisqusIdMap":[{
            "canvas_discussionTopicId": "185",
            "disqus_threadId": "3285923058"
         }],
	"disqusApiUrl": "https://disqus.com",
    	"disqusApiKey": "hNCiYG7sBpsyavTbpysXNgHKJ8YDb9IFr3LpcVGj3eEZTPCicTJxNBoHub4etovu",
    	"disqusTopPosts": 2,
    	"disqusForumId": "canvas-scenario"
}