/* Javascript for PeerInstructionXBlock. */
function PeerInstructionXBlock(runtime, element, data) {
    "use strict";

    var handlerUrl = runtime.handlerUrl(element, 'submit_answer');
    var submitButton = $('.ubcpi_submit', element);

    var enableSubmit = function () {
        $('.ubcpi_submit', element).removeAttr('disabled');
    };

    $('input[type="radio"]', element).click(function (eventObject) {
        var clicked = this;
        var answer = clicked.value;
        console.log("Submitting ", answer);
        $.ajax({
            type: "POST",
            url: handlerUrl,
            data: JSON.stringify({"q": answer}),
            success: function (data, textStatus, jqXHR) {
                enableSubmit();
            },
            error: function (jqXHR, textStatus, errorThrown) {
            }
        });
    });

    $(function ($) {
        var app = angular.module('ubcpi', []);
        app.controller('ReviseController', function ($scope) {
            var isThisIsolated = 0;
            $scope.test = isThisIsolated;
            $scope.rnd = Math.random();
            $scope.inc = function () {
                isThisIsolated += 1;
                $scope.test = isThisIsolated;
            };
        });
        angular.bootstrap(element, ['ubcpi']);

        /* Here's where you'd do things on page load. */
        var savedAnswer = data.answer;

        // Handle null case
        if (!savedAnswer) {
            return;
        }
        else {
            enableSubmit();
        }

        $('input[value="' + savedAnswer + '"]', element).prop('checked', 'checked');

    });
}

@@ -37,16 +37,264 @@
 ock. */%0A
+%0Avar generatePIXBlockId;%0Aif (typeof generatePIXBlockId !== %22function%22) %7B%0A    generatePIXBlockId = (function () %7B%0A        %22use strict%22;%0A        var id = 0;%0A        return function () %7B%0A            return %22ubcpi_%22 + (id += 1);%0A        %7D%0A    %7D());%0A%7D%0A%0A
 function
@@ -1104,24 +1104,66 @@
 ction ($) %7B%0A
+        var appId = generatePIXBlockId();%0A
         var 
@@ -1183,23 +1183,21 @@
 .module(
-'ubcpi'
+appId
 , %5B%5D);%0A 
@@ -1565,15 +1565,13 @@
 t, %5B
-'ubcpi'
+appId
 %5D);%0A

Use unique module name per instance