Repository: learningequality/kolibri

Issue:
Question image/text is sometimes not visible on server and tablets
### Observed behavior

**a.**

Some questions of MagoGenie (mostly questions with images) are visible on the server in the lesson and quiz created but they are incomplete or the image is missing when viewed through the tablet.

Named the error screenshots (taken for the same question) as  MG_lesson_error#_server or MG_lesson_error#_tablet.

**b.**

Some questions of Khan Academy (mostly questions with images) are visible on the server in the lesson and quiz created but they are incomplete or the image is missing when viewed through the tablet.

**c.** 

Some questions/options of Khan Academy are not visible on the server in the lesson and quiz created and they are incomplete or the image is missing when viewed through the tablet.

Named the error screenshots (taken for the same question) as  KA_lesson_error#_server or KA_lesson_error#

**d.**

There are some questions (with or without images) which do not show any error both in the server and in the tablets.

Named the screenshots (taken for the same question) as  KA_lesson_no error#_server or KA_lesson_no error#_tablet.   


### Expected behavior

Images and texts of all the questions/ options must be visible.

### User-facing consequences


Users will not be able to read and answer the questions on the tabs.

### Errors and logs

### Steps to reproduce

1. Import the channel 

Channel name: Maharashtra State class 3 to 9(English medium) 
Channel ID : 8fc515793aad4e52b490b03c48ad21de
Channel token : mizam-zoruk

2. Create a lesson and a quiz using the chapters (MG and KA resources) of geometry, statistics, Time (that contain images) from grade 8, 7, 6.

3. Login as a student from the tab and try and solve the questions. The image/ text/ options would not be visible for many questions. You can cross check it with the same questions in the lesson created on the server using the preview feature.


### Context

Tell us about your environment, including:
 * Kolibri version - 0.12.5
 * Operating system ubuntu-14.04 version
 * Browser-Google chrome
 * Channel-  Channel name: Maharashtra State class 3 to 9(English medium) Channel ID : 8fc515793aad4e52b490b03c48ad21de

![KA_quiz_error5-server](https://user-images.githubusercontent.com/38091824/60014485-c96eed00-969e-11e9-9904-017396d90007.png)
![KA_quiz_error3-server](https://user-images.githubusercontent.com/38091824/60014486-ca078380-969e-11e9-9bf8-fd0c85810f96.png)
![KA_quiz_error2-server](https://user-images.githubusercontent.com/38091824/60014487-ca078380-969e-11e9-8904-6b463c390576.png)
![KA_lesson_no error-server](https://user-images.githubusercontent.com/38091824/60014488-ca078380-969e-11e9-9b13-a3d079875383.png)
![KA_lesson_error2-server](https://user-images.githubusercontent.com/38091824/60014489-caa01a00-969e-11e9-9f9a-e00bb6dba80b.png)
![KA_quiz_error1-server](https://user-images.githubusercontent.com/38091824/60014490-caa01a00-969e-11e9-95f4-e8b273948454.png)
![KA_lesson_error3-server](https://user-images.githubusercontent.com/38091824/60014491-caa01a00-969e-11e9-8212-aac322b94d86.png)
![KA_lesson_error4-server](https://user-images.githubusercontent.com/38091824/60014492-caa01a00-969e-11e9-83a7-3a8323039c28.png)
![KA_lesson_error1-server](https://user-images.githubusercontent.com/38091824/60014493-cb38b080-969e-11e9-9e4d-c4c76428025e.png)
![MG_quiz_no error-server](https://user-images.githubusercontent.com/38091824/60014495-cb38b080-969e-11e9-88a2-cadc5eba32fa.png)
![MG_quiz_no error2-server](https://user-images.githubusercontent.com/38091824/60014496-cb38b080-969e-11e9-9742-5e16aaf10189.png)
![MG_quiz_error4-server](https://user-images.githubusercontent.com/38091824/60014497-cbd14700-969e-11e9-965c-9ade5ce999c7.png)
![MG_quiz_error5-server](https://user-images.githubusercontent.com/38091824/60014498-cbd14700-969e-11e9-9bd2-00a9959d958c.png)
![MG_quiz_error1-server](https://user-images.githubusercontent.com/38091824/60014500-cc69dd80-969e-11e9-8ddb-be78beec2cdb.png)
![MG_quiz_error3-server](https://user-images.githubusercontent.com/38091824/60014503-cc69dd80-969e-11e9-8e00-8a119d0b7030.png)
![MG_quiz_error2-server](https://user-images.githubusercontent.com/38091824/60014505-cd027400-969e-11e9-89bb-d377283bfe29.png)
![MG_lesson_no error-server](https://user-images.githubusercontent.com/38091824/60014506-cd027400-969e-11e9-89cc-bb461479d156.png)
![MG_lesson_error1-server](https://user-images.githubusercontent.com/38091824/60014507-cd027400-969e-11e9-9bd9-e8f2e8c7fa34.png)
![KA_quiz_error4-server](https://user-images.githubusercontent.com/38091824/60014508-cd9b0a80-969e-11e9-9492-b1b7e73bb8bb.png)
![MG_lesson_error2-server](https://user-images.githubusercontent.com/38091824/60014509-cd9b0a80-969e-11e9-93c8-4a924a18e577.png)
![MG_quiz_error3-tablet](https://user-images.githubusercontent.com/38091824/60014532-db509000-969e-11e9-97b2-704444c1e268.png)
![MG_quiz_error4-tablet](https://user-images.githubusercontent.com/38091824/60014534-dbe92680-969e-11e9-9c60-f38dc750d607.png)
![MG_quiz_error5-tablet](https://user-images.githubusercontent.com/38091824/60014535-dc81bd00-969e-11e9-9e25-11c9fb1c8163.png)
![MG_quiz_no error2-tablet](https://user-images.githubusercontent.com/38091824/60014537-dc81bd00-969e-11e9-870a-e8563f8f96e9.png)
![MG_quiz_noerror1-tablet](https://user-images.githubusercontent.com/38091824/60014538-dc81bd00-969e-11e9-8acc-de81f5d095e1.png)
![KA_lesson_error1-tablet](https://user-images.githubusercontent.com/38091824/60014539-dd1a5380-969e-11e9-8b17-c7cadb661868.png)
![KA_lesson_error2-tablet](https://user-images.githubusercontent.com/38091824/60014540-dd1a5380-969e-11e9-9418-fe782b465d0f.png)
![KA_lesson_error3-tablet](https://user-images.githubusercontent.com/38091824/60014541-dd1a5380-969e-11e9-9af5-66de059699c9.png)
![KA_lesson_error4-tablet](https://user-images.githubusercontent.com/38091824/60014542-ddb2ea00-969e-11e9-817a-a413c8a5e3a0.png)
![KA_lesson_no error1-tablet](https://user-images.githubusercontent.com/38091824/60014543-ddb2ea00-969e-11e9-90d6-f75a50ec65a8.png)
![KA_quiz_error1-tablet](https://user-images.githubusercontent.com/38091824/60014545-ddb2ea00-969e-11e9-9650-579b39435a32.png)
![KA_quiz_error2-tablet](https://user-images.githubusercontent.com/38091824/60014546-ddb2ea00-969e-11e9-93b2-89d4bcf54fe1.png)
![KA_quiz_error3-tablet](https://user-images.githubusercontent.com/38091824/60014547-de4b8080-969e-11e9-80e9-7e5096a6f98e.png)
![KA_quiz_error4-tablet](https://user-images.githubusercontent.com/38091824/60014548-de4b8080-969e-11e9-9f47-bc35d6e9afa6.png)
![KA_quiz_error5-tablet](https://user-images.githubusercontent.com/38091824/60014549-de4b8080-969e-11e9-82ad-009d4d742e76.png)
![MG_lesson_error1-tablet](https://user-images.githubusercontent.com/38091824/60014550-dee41700-969e-11e9-9773-7e53a545b9f3.png)
![MG_lesson_error2-tablet](https://user-images.githubusercontent.com/38091824/60014551-dee41700-969e-11e9-9440-b52733d27b43.png)
![MG_lesson_no error1-tablet](https://user-images.githubusercontent.com/38091824/60014552-dee41700-969e-11e9-86cd-bd9270c50762.png)
![MG_quiz_error1-tablet](https://user-images.githubusercontent.com/38091824/60014553-df7cad80-969e-11e9-9ff1-98b7fd655304.png)
![MG_quiz_error2-tablet](https://user-images.githubusercontent.com/38091824/60014554-df7cad80-969e-11e9-9d35-9154f57264d1.png)
<!--
…
-->



Discussion:
@rtibbles 
@Miyer03

I'm able to reproduce this with certain questions from this channel. For example,
 with "Angle relationships with parallel lines" (b0e38d49db804a19a3ac4a0d03f3a4ca), I get these errors

```
svg-image.jsx:297 Data load failed: http://localhost:8000/zipcontent/d130f335d6c2e7e9a83c0f8783a84bfc.perseus/images/8c654ea08faf318e360dfcddba5a0a58c8e9e688-data.json undefined
```

And a 404 trying to get this image

```
ttp://localhost:8000/zipcontent/d130f335d6c2e7e9a83c0f8783a84bfc.perseus/images/8c654ea08faf318e360dfcddba5a0a58c8e9e688.svg
```
looks like a duplicate of #5094, which was identified to be an upstream content issue
The channel was republished and tested the same kind of issues are re-appearing.

1. Images of KA- grade 8, 7, are not appearing on the server as well as the tablets. 

2. The images of MG questions are appearing in the server but not on the tablets in the quiz feature. It is appearing in the lessons.

![Screenshot_20190626-232817](https://user-images.githubusercontent.com/8583367/60288049-03572200-9931-11e9-9d32-a59588e4f33f.png)
![Screenshot_20190626-232744](https://user-images.githubusercontent.com/8583367/60288050-03572200-9931-11e9-9910-7a740cf3ec2d.png)
![Screenshot_20190626-232523](https://user-images.githubusercontent.com/8583367/60288051-03efb880-9931-11e9-9bcb-e89670df700f.png)
![IMG_20190626_232825995](https://user-images.githubusercontent.com/8583367/60288052-03efb880-9931-11e9-8624-7380e8b6cfb3.jpg)
![IMG_20190626_232749148](https://user-images.githubusercontent.com/8583367/60288055-03efb880-9931-11e9-82a0-1ef7780688d0.jpg)
![IMG_20190626_232536036](https://user-images.githubusercontent.com/8583367/60288058-03efb880-9931-11e9-9301-e173c5bcd867.jpg)
![IMG_20190626_230432660](https://user-images.githubusercontent.com/8583367/60288059-04884f00-9931-11e9-91e1-d5ab31bd6f33.jpg)
![IMG_20190626_230315781](https://user-images.githubusercontent.com/8583367/60288060-04884f00-9931-11e9-8da0-0af780ddcbfe.jpg)
![IMG_20190626_230202136](https://user-images.githubusercontent.com/8583367/60288061-04884f00-9931-11e9-8910-a0096fdcd033.jpg)

We tried installing 0.12.4 deb and tried testing the same and it seems to have existed in it as well.
> The images of MG questions are appearing in the server but not on the tablets in the quiz feature. It is appearing in the lessons.

this sounds like a potential Kolibri issue
Trying to look into this on Studio, but the following question has *3561 different copies* on Studio (likely from being imported all over the place, scraped by scripts from Magogenie multiple times in multiple ways, etc):

![](https://user-images.githubusercontent.com/38091824/60014547-de4b8080-969e-11e9-80e9-7e5096a6f98e.png)

This makes diagnosing the issues (most of which are likely caused by issues in the ways the content was brought into Studio) difficult. We also don't have access to the various versions of the scripts your team used to import the Magogenie content, which makes diagnosis more difficult as well.

To help with this, when reporting content issues, if you could always be sure to provide a copy-paste of the full URL for the content item, that can help with determining which item you're having trouble with. Thanks!
I have run "Sync" to update the nodes from their source channels, and then republished. This seems to have resolved the issue at least for the KA exercise I checked. Magogenie can be more problematic because it was badly scripted for import, and then cloned from many different source channels that may not themselves have been updated. Please try re-downloading into Kolibri and see if you're still seeing issues.
>Please try re-downloading into Kolibri and see if you're still seeing issues.

Bump. Please let us know what is happening.
Any word? We want to make sure this has been resolved.
Sorry for the delay in update as we are busy deploying and testing 12.5. This has been definitely observed for Magogenie questions. Will share the update tomorrow.
Thanks. When reporting issues you're seeing on content, please include:
1. The channel _version_ (e.g. "37") as can be seen on the local device at: http://127.0.0.1:8080/en/device/#/content
2. The full URL of the content item you're seeing issues on.
I tried creating a quiz and observed that the all the content is visible on the laptop but some of the images/ content missing on the tab.

The channel Version 39.

The URLs

http://127.0.0.1:8008/en/coach/#/286e4b88b0cea28d11fc576217712d7e/reports/quizzes/d74ed6a46e05372e290f182ba4725b1f/learners/07348dbede8ea4065dc249f7788df7d4/questions/1/interactions/0


http://127.0.0.1:8008/en/coach/#/286e4b88b0cea28d11fc576217712d7e/reports/quizzes/d74ed6a46e05372e290f182ba4725b1f/learners/07348dbede8ea4065dc249f7788df7d4/questions/4/interactions/0


http://127.0.0.1:8008/en/coach/#/286e4b88b0cea28d11fc576217712d7e/reports/quizzes/d74ed6a46e05372e290f182ba4725b1f/learners/07348dbede8ea4065dc249f7788df7d4/questions/6/interactions/0

http://127.0.0.1:8008/en/coach/#/286e4b88b0cea28d11fc576217712d7e/reports/quizzes/d74ed6a46e05372e290f182ba4725b1f/learners/07348dbede8ea4065dc249f7788df7d4/questions/7/interactions/0

http://127.0.0.1:8008/en/coach/#/286e4b88b0cea28d11fc576217712d7e/reports/quizzes/d74ed6a46e05372e290f182ba4725b1f/learners/07348dbede8ea4065dc249f7788df7d4/questions/10/interactions/0


http://127.0.0.1:8008/en/coach/#/286e4b88b0cea28d11fc576217712d7e/reports/quizzes/d74ed6a46e05372e290f182ba4725b1f/learners/07348dbede8ea4065dc249f7788df7d4/questions/13/interactions/0

![Screenshot_2019-07-11-16-01-53](https://user-images.githubusercontent.com/8583367/61046148-0c002b80-a3fa-11e9-99cc-0dc0c3d6bdf9.png)
![Screenshot_2019-07-11-16-02-09](https://user-images.githubusercontent.com/8583367/61046150-0c002b80-a3fa-11e9-9d6b-17555edcda98.png)
![Screenshot_2019-07-11-16-02-20](https://user-images.githubusercontent.com/8583367/61046151-0c002b80-a3fa-11e9-9bbd-5e5b09ef7ba4.png)
![Screenshot_2019-07-11-16-02-30](https://user-images.githubusercontent.com/8583367/61046152-0c98c200-a3fa-11e9-989a-8b0c7f1c7809.png)
![Screenshot_2019-07-11-16-02-52](https://user-images.githubusercontent.com/8583367/61046153-0c98c200-a3fa-11e9-971a-1b3b36a8b3bf.png)
![Screenshot_2019-07-11-16-03-36](https://user-images.githubusercontent.com/8583367/61046154-0c98c200-a3fa-11e9-8b35-abe708e28d29.png)
![Screenshot from 2019-07-11 15-51-41](https://user-images.githubusercontent.com/8583367/61046248-4a95e600-a3fa-11e9-8bc1-f79057d172b6.png)
![Screenshot from 2019-07-11 16-00-24](https://user-images.githubusercontent.com/8583367/61046250-4a95e600-a3fa-11e9-9da5-3718770c884d.png)
![Screenshot from 2019-07-11 16-00-33](https://user-images.githubusercontent.com/8583367/61046251-4a95e600-a3fa-11e9-89ef-4bc23b40c1b0.png)
![Screenshot from 2019-07-11 16-00-41](https://user-images.githubusercontent.com/8583367/61046253-4a95e600-a3fa-11e9-8d1f-b1289beefac5.png)
![Screenshot from 2019-07-11 16-00-59](https://user-images.githubusercontent.com/8583367/61046255-4b2e7c80-a3fa-11e9-9e17-e338b123795a.png)

![Screenshot from 2019-07-11 16-01-19](https://user-images.githubusercontent.com/8583367/61046258-4b2e7c80-a3fa-11e9-949f-6083fe3e3b61.png)


http://127.0.0.1:8008/en/coach/#/286e4b88b0cea28d11fc576217712d7e/plan/quizzes/a896854f941dd475f96dc2cd1160ca96

![Screenshot from 2019-07-11 18-28-56](https://user-images.githubusercontent.com/8583367/61053556-681f7b80-a40b-11e9-85f2-c17dc95c86bf.png)
![Screenshot from 2019-07-11 18-30-02](https://user-images.githubusercontent.com/8583367/61053557-681f7b80-a40b-11e9-99e0-730e85155a2e.png)
![Screenshot from 2019-07-11 18-30-12](https://user-images.githubusercontent.com/8583367/61053559-681f7b80-a40b-11e9-9784-5f17f1b451f6.png)
![Screenshot_2019-07-11-18-28-42](https://user-images.githubusercontent.com/8583367/61053591-74a3d400-a40b-11e9-930b-278ad9b1725a.png)
![Screenshot_2019-07-11-18-28-50](https://user-images.githubusercontent.com/8583367/61053592-753c6a80-a40b-11e9-9976-feb9e9f5977a.png)
![Screenshot_2019-07-11-18-29-03](https://user-images.githubusercontent.com/8583367/61053593-753c6a80-a40b-11e9-86a8-ec7e8ec81793.png)

Does this only happen in quizzes? Can you replicate on the tablets by navigating to the exercises directly, too?
Seems to be prevalent in quizzes. 

Question in Studio :- https://studio.learningequality.org/channels/8fc515793aad4e52b490b03c48ad21de/edit/dac7eeb/03b1b41

![Screenshot from 2019-07-12 19:17:35](https://user-images.githubusercontent.com/8583367/61132803-bbf89600-a4d9-11e9-9bde-bc8de1802573.png)

In Laptop server

![Laptop](https://user-images.githubusercontent.com/8583367/61132837-d03c9300-a4d9-11e9-9a45-544e49d171e1.png)

In Tablet
![Screenshot_2015-02-01-04-30-08](https://user-images.githubusercontent.com/8583367/61132885-e9ddda80-a4d9-11e9-9ba9-f84f8b60be96.png)

From your screenshots, it looks as if it's happening both in quizzes and in exercises.

The common factor for the issue seems to be the tablet browser. Is that Chrome? If so, can you use [remote Chrome debugging](https://medium.com/anantha-krishnan-k-g/how-to-debug-your-website-in-android-chrome-29ee031b24e3) to see what errors might be showing up in the Console or Network tab, or if it's not, can you try using Google Chrome instead (and let us know the details of the problematic browser)?

As an additional data point, Chrome on my Android phone renders that exercise correctly:

![image](https://user-images.githubusercontent.com/618416/61255026-bab6ab80-a71b-11e9-9545-e7793d44b12b.png)

I tried in a swipe tablets and seems to be an issue but when I tried in a different LG tablets the images seems to be rendering. Not sure if this is device specific. All the tab have google chrome as the browser in the latest version. Tried in firefox as well and seems to be a problem for swipe tablets there as well.

Ok, it sounds like it may be something particular to that tablet (did you try on other "swipe tablets" also, or just the one device?). We don't have any of those tablets here, so we can't replicate on our side, and rely on your debugging. Could you still try the suggestion below, to see if there are any errors in the Network or Console tabs? It could provide a good indication of where the problem lies.

>can you use [remote Chrome debugging](https://medium.com/anantha-krishnan-k-g/how-to-debug-your-website-in-android-chrome-29ee031b24e3) to see what errors might be showing up in the Console or Network tab
As for now, found out the following-
For some cases where the images are not rendered,  the image is accessible through IP address but localhost is being passed in the response. Attaching the screenshot for the same.

We are able to access same question with images in local machine but images are not loading on remote machine.
Hope this helps in finding out the actual problem. Will try out remote Chrome debugging.

![Screenshot from 2019-07-18 13-12-34](https://user-images.githubusercontent.com/34458132/61447574-d2d23900-a96e-11e9-9771-8f9c458b7ddf.png)
 
Thanks @Divya-Sodha - I think the attempt to access the images from the localhost is the key thing here.

My hypothesis is that this is a caching issue.

When the exercises are first accessed from the browser of the server itself, then the page is initially rendered with a URL that is from localhost for the image.

This is then cached by Kolibri and/or Nginx.

When a tablet user accesses via the IP address, the cached file is served, but still referencing the localhost URL, which is not appropriate for the user. This means the images are missing.

My hypothesis is that if you clear the nginx cache and restart the Kolibri server, then the tablets should be able to load the images, as long as they are the first to do so.

If you can see if this is the case, that would be helpful, and we can work out how to fix this caching issue.
Tried remote debugging and attached are the screen shots. Please let me know if these screen shots help
![Screenshot from 2019-07-19 16-30-51](https://user-images.githubusercontent.com/8583367/61530828-cddeb980-aa42-11e9-90a6-e9dce32f4b8c.png)
![Screenshot from 2019-07-19 16-31-01](https://user-images.githubusercontent.com/8583367/61530829-cddeb980-aa42-11e9-97f2-093f5e8c9391.png)


Tried clearing the nginx cache from .kolibri folder and restarting the nginx server as suggested by @rtibbles . Images are able to be loaded on tablets now after doing this. Hope this helps in figuring out the solution.  
Thanks @Divya-Sodha - it seems that this is an issue caused by caching, I will submit a fix to prevent this issue arising, targeted for 0.12.6.
@rtibbles I cleared the cache and its seems to be working, but still could find the issue in few places. Attached is a screen shot.

Quiz link on the laptop

http://127.0.0.1:8008/en/coach/#/63a33cb55e7e35672032b4fd8ebd6d62/plan/quizzes/b26b4e058735ae7f5e64096503abfc30
![Screenshot from 2019-07-20 13-33-54](https://user-images.githubusercontent.com/8583367/61576125-62a0f000-aaf3-11e9-8b6c-5d44734a3317.png)

Thanks @miyer03 - this may be persisting due to client side caching, but I still see the `localhost` in the address, so I think we are still on the right track here.

Resolving patch:
diff --git a/kolibri/core/content/views.py b/kolibri/core/content/views.py
--- a/kolibri/core/content/views.py
+++ b/kolibri/core/content/views.py
@@ -20,17 +20,13 @@
 from django.http.response import HttpResponseNotModified
 from django.template import loader
 from django.templatetags.static import static
-from django.urls import reverse
 from django.utils.decorators import method_decorator
 from django.views.decorators.clickjacking import xframe_options_exempt
 from django.views.decorators.http import etag
 from django.views.generic.base import View
-from le_utils.constants import exercises
-from six.moves.urllib.parse import urlunparse
 
 from .api import cache_forever
 from .decorators import add_security_headers
-from .decorators import get_referrer_url
 from .models import ContentNode
 from .utils.paths import get_content_storage_file_path
 from kolibri import __version__ as kolibri_version
@@ -56,19 +52,6 @@ def get_hashi_filename():
     return HASHI_FILENAME
 
 
-def generate_image_prefix_url(request, zipped_filename):
-    parsed_referrer_url = get_referrer_url(request)
-    # Remove trailing slash
-    zipcontent = reverse(
-        "kolibri:core:zipcontent",
-        kwargs={"zipped_filename": zipped_filename, "embedded_filepath": ""},
-    )[:-1]
-    if parsed_referrer_url:
-        # Reconstruct the parsed URL using a blank scheme and host + port(1)
-        zipcontent = urlunparse(("", parsed_referrer_url[1], zipcontent, "", "", ""))
-    return zipcontent.encode()
-
-
 def calculate_zip_content_etag(request, *args, **kwargs):
     return hashlib.md5(
         kolibri_version.encode("utf-8") + get_hashi_filename().encode("utf-8")
@@ -207,7 +190,7 @@ def get_h5p(zf, embedded_filepath):
     return response
 
 
-def get_embedded_file(request, zf, zipped_filename, embedded_filepath):
+def get_embedded_file(zf, zipped_filename, embedded_filepath):
     # if no path, or a directory, is being referenced, look for an index.html file
     if not embedded_filepath or embedded_filepath.endswith("/"):
         embedded_filepath += "index.html"
@@ -234,18 +217,10 @@ def get_embedded_file(request, zf, zipped_filename, embedded_filepath):
         html = parse_html(content)
         response = HttpResponse(html, content_type=content_type)
         file_size = len(response.content)
-    elif not os.path.splitext(embedded_filepath)[1] == ".json":
+    else:
         # generate a streaming response object, pulling data from within the zip  file
         response = FileResponse(zf.open(info), content_type=content_type)
         file_size = info.file_size
-    else:
-        image_prefix_url = generate_image_prefix_url(request, zipped_filename)
-        # load the stream from json file into memory, replace the path_place_holder.
-        content = zf.open(info).read()
-        str_to_be_replaced = ("$" + exercises.IMG_PLACEHOLDER).encode()
-        content_with_path = content.replace(str_to_be_replaced, image_prefix_url)
-        response = HttpResponse(content_with_path, content_type=content_type)
-        file_size = len(response.content)
 
     # set the content-length header to the size of the embedded file
     if file_size:
@@ -284,9 +259,7 @@ def get(self, request, zipped_filename, embedded_filepath):
             ):
                 response = get_h5p(zf, embedded_filepath)
             else:
-                response = get_embedded_file(
-                    request, zf, zipped_filename, embedded_filepath
-                )
+                response = get_embedded_file(zf, zipped_filename, embedded_filepath)
 
         # ensure the browser knows not to try byte-range requests, as we don't support them here
         response["Accept-Ranges"] = "none"


Test patch:
diff --git a/kolibri/core/content/test/test_zipcontent.py b/kolibri/core/content/test/test_zipcontent.py
--- a/kolibri/core/content/test/test_zipcontent.py
+++ b/kolibri/core/content/test/test_zipcontent.py
@@ -6,7 +6,6 @@
 from bs4 import BeautifulSoup
 from django.test import Client
 from django.test import TestCase
-from le_utils.constants import exercises
 from mock import patch
 
 from ..models import LocalFile
@@ -43,10 +42,6 @@ class ZipContentTestCase(TestCase):
     test_str_1 = "This is a test!"
     test_name_2 = "testfile2.txt"
     test_str_2 = "And another test..."
-    test_name_3 = "testfile3.json"
-    test_str_3 = "A test of image placeholder replacement ${placeholder}".format(
-        placeholder=exercises.IMG_PLACEHOLDER
-    )
 
     def setUp(self):
 
@@ -71,7 +66,6 @@ def setUp(self):
             zf.writestr(self.empty_html_name, self.empty_html_str)
             zf.writestr(self.test_name_1, self.test_str_1)
             zf.writestr(self.test_name_2, self.test_str_2)
-            zf.writestr(self.test_name_3, self.test_str_3)
 
         self.zip_file_obj = LocalFile(
             id=self.hash, extension=self.extension, available=True
@@ -166,30 +160,6 @@ def test_access_control_allow_headers(self, filename_patch):
         )
         self.assertEqual(response.get("Access-Control-Allow-Headers", ""), headerval)
 
-    def test_json_image_replacement_http_referer_header(self, filename_patch):
-        server_name = "http://testserver"
-        response = self.client.get(
-            self.zip_file_base_url + self.test_name_3, HTTP_REFERER=server_name
-        )
-        self.assertEqual(
-            response.content.decode("utf-8"),
-            self.test_str_3.replace(
-                "$" + exercises.IMG_PLACEHOLDER,
-                (server_name.replace("http:", "") + self.zip_file_base_url),
-            ).strip("/"),
-        )
-
-    def test_json_image_replacement_no_http_referer_header(self, filename_patch):
-        server_name = "http://testserver"
-        response = self.client.get(self.zip_file_base_url + self.test_name_3)
-        self.assertEqual(
-            response.content.decode("utf-8"),
-            self.test_str_3.replace(
-                "$" + exercises.IMG_PLACEHOLDER,
-                (server_name.replace("http:", "") + self.zip_file_base_url),
-            ).strip("/"),
-        )
-
     def test_request_for_html_no_head_return_hashi_modified_html(self, filename_patch):
         response = self.client.get(self.zip_file_base_url)
         content = '<html><head></head><body><script src="/static/content/hashi123.js"></script></body></html>'