vlead / vlabs-openedx-platform

Other
1 stars 0 forks source link

Set vlabs-utils( feedback and usage analytics) for OpenedX platform #22

Open sivashankerN opened 6 years ago

sivashankerN commented 6 years ago

Set vlabs-utils( feedback and usage analytics) for OpenedX platform.

For this

  1. Delete following lines in each experiment of the course

var server_url = "http://analytics-api.vlabs.ac.in/" var xhttp = new XMLHttpRequest(); var urlstr = server_url + user_id + "," + lab_id + "," + lab_name + "," + exp_id + "," + exp_name xhttp.open("GET", urlstr, true); xhttp.send();

  1. Replace the line xhttp.send() with submitUsage(lab_id, exp_name, lab_name, user_id, exp_id); in every experiment of the course.

  2. Replace the string submit_feedback with submitFeedback in every course.

  3. Delete the line <p><!-- <script src="https://vlabs.ac.in:5959/feedback_utils.js"></script> --> in every course.

So that later, add the utils.html in OpenedX platform.

sivashankerN commented 6 years ago

For testing utils.html file contains. For Production, need to change usgaeUrl and feedbackUrl


<html>
  <head>
    <script>
      var usageUrl = "http://analytics.base1.vlabs.ac.in/";
      var feedbackBaseUrl = "http://feedback.base1.vlabs.ac.in"
      var key = "defaultkey";

      var submitUsage = function(labId, expName, labName, userId, expId) {
      var xhttp = new XMLHttpRequest();
      var urlstr = usageUrl + userId + "," + labId + "," + labName + "," + expId + "," + expName;
      xhttp.open("GeT", urlstr, true);
      xhttp.send();
      };

      var submitFeedback = function(labId, labName, expId, expName, userId) {
      if (expId == "" || expName == "")
      {
      feedback_url = feedbackBaseUrl + "/feedback?lab_name=" + labName + "&key=" + key + "&user_id=" + userId;
      window.open(feedback_url, '_blank');
      }
      else {
      ///Experiment wise feedback
      feedback_url = feedbackBaseUrl + "/feedback?lab_name=" + labName + "&exp_name=" + expName + "&key=" + key + "&user_id=" + userId;
      window.open(feedback_url, '_blank');
      }
      };
    </script>
  </head>
</html>
sivashankerN commented 6 years ago

To delete following lines in every experiment of every course

var server_url = "http://analytics-api.vlabs.ac.in/" var xhttp = new XMLHttpRequest(); var urlstr = server_url + user_id + "," + lab_id + "," + lab_name + "," + exp_id + "," + exp_name xhttp.open("GET", urlstr, true);

Used following shell script 'delete.sh' after cloning all repository from https://github.com/vlabs-on-openedx using GitHub API


DEST="edx_repos/*/html/*.html"
sed -i '/var server_url/d;/var xhttp/d;/var urlstr/d;/xhttp.open/d' $DEST
sed -i 's/xhttp.send\(\).*/submitUsage\(lab_id\, exp_name\, lab_name\, user_id\, exp_id\)\;/g' $DEST
sed -i 's/submit_feedback/submitFeedback/g' $DEST
sed -i '/vlabs.ac.in:5959\/feedback_utils.js/d' $DEST
sivashankerN commented 6 years ago

Above shell script also does other tasks(2 to 4) mentioned in the first comment of this issue.

sivashankerN commented 6 years ago

Tagged every repository with version v1.1.0 before committing the changes

and then committed the latest changes( that are made with the above shell script delete.sh).

sivashankerN commented 6 years ago

utils.html file content should be added in /edx/var/nginx/server-static/utils.html

Add the following line add_after_body /server/utils.html; to /edx/app/nginx/sites-available/lms at location @proxy_to_lms_app location in lms file.

restart nginx service.

sivashankerN commented 6 years ago

You may have to restart edx services too.

sudo /edx/bin/supervisorctl restart all