Moodle App - Assignment Submission Type

Moodle App - Assignment Submission Type

autor Maximilian Hraschan -
Počet odpovedí: 19

I'm trying to build a plugin for the Moodle App where the user is able to submit multiple text files in one assigment.

My problem ist, I can only add content to the assigment view (The orange submission button) but im not able add the submission as the app is telling me in the last section of the following image.

Does sombody know how i can edit the content of the assignment. Same as it is possible in the moodle web version?


Priemer hodnotení : -
V odpovedi na Maximilian Hraschan

Re: Moodle App - Assignment Submission Type

autor Dani Palou -
Obrázok: Core developers Obrázok: Moodle HQ Obrázok: Particularly helpful Moodlers Obrázok: Peer reviewers Obrázok: Plugin developers

Hi,

you need to adapt your plugin to work in the Moodle app. Here's a guide on how to do it:

https://docs.moodle.org/dev/Moodle_App_Plugins_Development_Guide

Since you're developing an assign submission plugin you want to use AddonModAssignSubmissionDelegate. Please notice this type of plugins aren't as easy to adapt as others like activities.

You will have to use the Javascript API (see this section of the guide) to override the default functions of the handler in the app. Please click here to see the definition of the functions your handler can implement. The functions getComponent and getPluginName are automatically implemented for your plugin, but you will need to implement the other functions: prepareSubmissionData, isEnabledForEdit, hasDataChanged, getSizeForEdit, etc.

Good luck!

Dani

V odpovedi na Dani Palou

Re: Moodle App - Assignment Submission Type

autor maxi hraschan -

I tried to implement the plugin as u said. For any reason the isEnabledForEdit function does not work. As you can see in my added JS File I implemented the componentInit function which works fine and the isEnabledForEdit which don't works. Do have any further advice?  I'm still facing the issue that the user is not able to see the "Add Submission" Button.

Am I doing something completly wrong?

Greatings


V odpovedi na maxi hraschan

Re: Moodle App - Assignment Submission Type

autor Dani Palou -
Obrázok: Core developers Obrázok: Moodle HQ Obrázok: Particularly helpful Moodlers Obrázok: Peer reviewers Obrázok: Plugin developers
Hi,

can you please test it using the integration branch of the Moodle app? If you're using the webapp to test you can use the integration webapp.

There was a bug in the app that caused overrides not to work properly, it should be fixed in the integration branch. Hopefully that will fix your issue.

Cheers,
Dani
V odpovedi na Dani Palou

Re: Moodle App - Assignment Submission Type

autor maxi hraschan -

I used the master branch of the app.

Is this good enough? Otherwise I'll try the integration branch. 

V odpovedi na maxi hraschan

Re: Moodle App - Assignment Submission Type

autor Dani Palou -
Obrázok: Core developers Obrázok: Moodle HQ Obrázok: Particularly helpful Moodlers Obrázok: Peer reviewers Obrázok: Plugin developers
The master branch doesn't have the fix yet. Master branch is v3.9.5 of the app, in the integration branch we have the code for v4.0 (next version). Please try with the integration branch and let me know if the problem persists Úsmev
V odpovedi na Dani Palou

Re: Moodle App - Assignment Submission Type

autor maxi hraschan -
Sadly i cant connect with my server on the integration branch. Is their a reason why?

My server: https://moodle.develop-modular.com/moodle-3.9/
V odpovedi na maxi hraschan

Re: Moodle App - Assignment Submission Type

autor Dani Palou -
Obrázok: Core developers Obrázok: Moodle HQ Obrázok: Particularly helpful Moodlers Obrázok: Peer reviewers Obrázok: Plugin developers
I was able to reach the credentials screen using the integration webapp and your URL. If you're using the webapp or "ionic serve", please make sure you start Chrome/Chromium with the flags explained in this guide:



V odpovedi na Dani Palou

Re: Moodle App - Assignment Submission Type

autor maxi hraschan -
It works fine on the integration branch now. Thanks for your detailed help!!!

Do you maybe know when version 4.0 of the Moodle App gets released? 


V odpovedi na maxi hraschan

Re: Moodle App - Assignment Submission Type

autor Dani Palou -
Obrázok: Core developers Obrázok: Moodle HQ Obrázok: Particularly helpful Moodlers Obrázok: Peer reviewers Obrázok: Plugin developers
The 4.0 app should be released the same week as Moodle LMS 4.0. Currently the expected release date for Moodle LMS 4.0 is March 28.
V odpovedi na Dani Palou

Re: Moodle App - Assignment Submission Type

autor maxi hraschan -
Thanks for the info. Do you maybe have a github link for a finished assignment submussion type plugin? The documentation is so poor on information about how to get data from db ect.

For someone who starts the first time developing such a moodle app plugin the documentation isn't the best. Smutný 
V odpovedi na maxi hraschan

Re: Moodle App - Assignment Submission Type

autor Dani Palou -
Obrázok: Core developers Obrázok: Moodle HQ Obrázok: Particularly helpful Moodlers Obrázok: Peer reviewers Obrázok: Plugin developers

Unfortunately I don't know any assign submission plugin with app support, sorry. You can check how the core ones work, maybe that can help you understand what does each function do:

File submission handler
File submission template
Online text submission handler
Online text submission template

Right now we don't have enough resources to document step by step how to create each type of plugin, but feel free to edit the wiki to improve the documentation and help other developers Úsmev Usually devs learn more from an existing example rather than documentation, it's a shame in this case there is no existing example. Maybe your plugin can be the example to check once you're done!

V odpovedi na Dani Palou

Re: Moodle App - Assignment Submission Type

autor Marcus Green -
Obrázok: Core developers Obrázok: Particularly helpful Moodlers Obrázok: Plugin developers Obrázok: Testers
Hi Dani, for me working examples are of ore use than documentation, though well commented code is even better. Is there a list of plugin types that can be created for the App, or have we reached the stage where it would be a list that is not supported by the app?
V odpovedi na Marcus Green

Re: Moodle App - Assignment Submission Type

autor Dani Palou -
Obrázok: Core developers Obrázok: Moodle HQ Obrázok: Particularly helpful Moodlers Obrázok: Peer reviewers Obrázok: Plugin developers
Hi Marcus,

you can check the Delegates section of the guide. Each delegate belongs to either a Moodle feature (e.g. question type, assign submission, etc.) or a place of the app where you can add your plugin (without being strictly related to a Moodle feature, like the app's main menu). We try to keep that list up to date, but you can always check the source code that treats it just in case: this switch.

Cheers,
Dani
V odpovedi na Dani Palou

Re: Moodle App - Assignment Submission Type

autor maxi hraschan -
Hello Dani! I was able to build my plugin with the use of the original "onlinetext" submission type plugin. I got one last question left: I'm only able to use the editor of moodle as a field type. Otherwise I'm not possible to get the data of my fields in the Moodle App. Is their any way to use other field types ? If so, how do i get the data of these fields in the app?
V odpovedi na maxi hraschan

Re: Moodle App - Assignment Submission Type

autor Dani Palou -
Obrázok: Core developers Obrázok: Moodle HQ Obrázok: Particularly helpful Moodlers Obrázok: Peer reviewers Obrázok: Plugin developers
Hi,

sorry, I don't understand the question. Can you please share some code so I can see what you're trying to do?

Cheers,
Dani
V odpovedi na Dani Palou

Re: Moodle App - Assignment Submission Type

autor maxi hraschan -
Yes ofc.

When you look at the php part of a submission plugin, you need to define funktions like:

  • get_editor_fields
  • get_editor_text
  • get_editor_format
  • get_form_elements

When I use that functions and add a editor field in my get_form_elements() function like:

```php

$data = file_prepare_standard_editor($data,
                                             'field0',
                                             $editoroptions,
                                             $this->assignment->get_context(),
                                             'assignsubmission_fieldtext',
                                             ASSIGNSUBMISSION_fieldTEXT_FILEAREA,
                                             $submissionid);
        $mform->addElement('editor', 'field0_editor', get_string("field0", "assignsubmission_fieldtext" ), null, $editoroptions);

```

I'm able to view that editor in my webversion of the plugin. I'm also able to view the same editor in the moodle app by using the "<core-rich-text-editor>". I can get all the submission data for the editor in my javascript by using the plugins editorfields:

 

In my componentInit function i can use "this.plugin.editorfields" to get my data.

Later on in my prepareSubmissionData function I can save the users changes with

```php
pluginData["field"+i+"_editor"] = {
                    text: inputData["field"+i+"_editor_text"],
                    format: 1,
                    itemid: 0, // Can't add new files yet, so we use a fake itemid.
                };
```

My question now is how to use other types of fields instead of using the editor. By other types i mean something like a Date input. If so, I really don't know how to gather my data in my javascript for other types of inputs.

i hope you can understand what I try to do.




V odpovedi na maxi hraschan

Re: Moodle App - Assignment Submission Type

autor Dani Palou -
Obrázok: Core developers Obrázok: Moodle HQ Obrázok: Particularly helpful Moodlers Obrázok: Peer reviewers Obrázok: Plugin developers
Thanks for the examples sonrisa

In the app, when the user is editing the assign we put all the plugin's HTML inside a form. When the user submits, we get all the data from the form (using 
form.elements) and that's the data that is then passed to prepareSubmissionData. The data is indexed by the name you set to the input.

So for example if you add this text input:

<ion-item>
<ion-label position="stacked">My label</ion-label>
    <ion-input type="text" name="mytext" autocorrect="off"></ion-input>
</ion-item>

Then I think the prepareSubmissionData should receive an object containing a "mytext" entry with the value the user entered in the text input. For simple types maybe you don't need to convert the data inside prepareSubmissionData.

Cheers,
Dani