Problem with Atto editor Record audio and Record video

Re: Problem with Atto editor Record audio and Record video

by AL Rachels -
Number of replies: 3
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Took yesterday off to get caught up on yard-work, and the dog really thanks me for the 💩 cleanup.
Had a thought last night and checked this morning. I have discovered that I really seem to have a context/permission/license problem.
For the past few days, I have only worked on these three files:
  1.  exercises.php - generates a page that shows all the text-to-type and dictation files of each exercise in a lesson, along with links to edit each exercise and dictation file. It's the page shown in my two posts with only 1 exercise each time, but the page can have multiple exercises.
  2.  simplehtml.php - the file that generates the page to edit the text-to-type and it's dictation file, of any selected exercise.
  3.  simplehtml_form.php - the form used by simplehtml.php.
When I create some text-to-type and a dictation audio recording using simplehtml.php, I can immediately play it. Once I save and return to exercises.php I cannot play the file, but the text and player are there. If I go back to simplehtml.php to re-edit the exercise, the text is there and the audio plays as expected.
Now here is the thought I had. I went to another MooYper and another MooTyper in another course, and my file that I can play in the original MooTyper while editing, will NOT play in another MooTyper or another MooTyper in another course.
The little bit I have working is using a context of: $context = context_module::instance($cm->id);
Since MooTyper makes lessons available to the whole Moodle site, am I going to need to
  • change the context to something else, e.g. CONTEXT_SYSTEM, CONTEXT_COURSECAT or CONTEXT_COURSE?
  • figure out some way to give permission for the file to be played by anyone, anywhere in the site?
  • or do something with the license entry for the file so that it can be played by anyone, anywhere in the site?
I think I will have to use CONTEXT_SYSTEM, since I cannot play my own file with CONTEXT_MODULE in the same course in another MooTyper and I am getting, HTTP load failed with status 407, when I try.
Sorry for the long, detailed post.
In reply to AL Rachels

Re: Problem with Atto editor Record audio and Record video

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers
I think Al that the permissions check for the context is handled by you in: function mootyper_pluginfile() in mod/mootyper/lib.php
So its up to you to allow or deny. You are probably denying it unwittingly. Play around with it there.

As to the etiquette of which context you should save it as, I think its the module context. Because its really a part of the lesson.  You just choose to not restrict access to the file based on the users role in the course.
Tim or someone can give you a more definitive answer.
In reply to Justin Hunt

Re: Problem with Atto editor Record audio and Record video

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If you are in an activity, the context is context_module for that activity. This is not something that you can choose. You have to use that in your code.

Section 13.2 here might help? https://www.aosabook.org/en/moodle.html

I repeat my advice above: Work out why and how it is working in mod_page, then compare your code to that.
In reply to AL Rachels

Re: Problem with Atto editor Record audio and Record video

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Progress report. I have tried everything I can think of, (following glossary, diary, journal, question, simple lesson, page resource) but this has got me stumped. In simple terms, to get this so that a recording is made in a textarea, you need the following:

  • a database table
  • in lib.php a function mootyper_format_entry_text($entry, $course = false, $cm = false)
  • a view.php file
  • an edit.php file
  • an edit_form.php file

With only a couple of name changes, I duplicated these items from Journal, and placed them in MooTyper.

  • created mdl_mootyper_entries table with the same fields used in Journal, except field, modified changed to timemodified.
  • in MooTyper's lib.php, I added the function mootyper_format_entry_text($entry, $course = false, $cm = false) with the only differences, mootyper in place of journal, wherever needed.
  • In MooTyper plugin folder, duplicated journal's view.php renamed as simpleview.php with the only differences, mootyper in place of journal, wherever needed.
  • In MooTyper plugin folder, duplicated journal's edit.php renamed as simpleedit.php with the only differences, mootyper in place of journal, wherever needed.
  • In MooTyper plugin folder, duplicated journal's edit_form.php renamed as simpleedit_form.php with the only differences, mootyper in place of journal, wherever needed.
I can add a recording In the Atto editor created by the edit.php and edit_form.php. I can save, then re-edit and play the recording in the editor. I just cannot play the audio from the player in view.php.

Today, I copied these three files and the function into the Journal plugin. Everything, including the audio player in the view.php file WORKS there.

In desperation, I deleted everything in MooTyper except the minimum code needed to get the three files to still work. Still does not work.  There were a couple of other functions I had to keep in MooTyper's lib.php file to get the three files to work, so I plan to work my way through them to see if they are causing my problem.

In simpleview.php, when I look at the output from the Firefox console tab, it is reporting, Media resource could not be decoded. When I had most everything deleted it reported error 407, HTTP load failed with status 407. Load of media resource failed.

Any suggestions?