Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Javascript-interface for repeat elements function: Difference between revisions

From MoodleDocs
Line 59: Line 59:


Blanks moving is available by dragging them with move button
Blanks moving is available by dragging them with move button
[[Image:move.jpg]]
At any moment you can set all your blanks in default positions, using button "Restore order"
At any moment you can set all your blanks in default positions, using button "Restore order"

Revision as of 19:47, 11 October 2010

GOAL: improve usability by using dynamic form editing.

At this moment form editing, especially adding new blank answers, units, choices and fields requires page reloading. Editing blanks order or blank removing is not possible without page reloading.

TASK: The main task is development of JavaScript-interface for repeat_elemens function. Other task is make ADD, REMOVE and MOVE actions without page reloading. If JavaScript is not available in user's browser this actions must work with page reloading, like it works now.


Where it will be.

Here, there are some pages, where this function uses, in the list below :

  • Course editing -> Adding a new Choice - Adding fields to form;
  • Course editing -> Adding a new Quiz - Adding new feedback fields;
  • Course editing -> Editing Quiz-> Editing a calculated question - Adding Blanks for choices;
  • Course editing -> Editing Quiz-> Editing a calculated question - Adding Blanks for Units;
  • Course editing -> Editing Quiz-> Editing a Calculated Multichoice question - Adding Blanks for choices;
  • Course editing -> Editing Quiz-> Editing a Simple Calculated question - Adding Blanks for choices;
  • Course editing -> Editing Quiz-> Editing a Simple Calculated question Adding Blanks for Units;
  • Course editing -> Editing Quiz-> Editing a Matching question - Adding Blanks for choices;
  • Course editing -> Editing Quiz-> Editing a Multiple choice question - Adding Blanks for choices;
  • Course editing -> Editing Quiz-> Editing a Numerical question - Adding Blanks for choices;
  • Course editing -> Editing Quiz-> Editing a Numerical question - Adding Blanks for choices;
  • Course editing -> Editing Quiz-> Adding a short answer question - Adding Blanks for choices;

etc. As repeat_elements is core function, it should work anywhere.

This core patch will add new buttons to the form interface. http://imglink.ru/pictures/21-09-10/f85258328f02d65164e6a15644e5d8a9.jpg 7.jpg

Adding new blanks

Adding new blanks realize by pushing "Add blanks for SMTH" button. There will be a hidden empty blank. When user will push the button, it's duplicate will be added in the end of blank's list.

Removing blanks.

It's possible to remove only 'Empty' blanks. Empty blank is that blank, where all key-fields are empty or have default values. List of elements, which will be check:

  • FILE.

File upload input box with browse button. Empty, when filepath is empty.

  • FILEPICKER

General replacement of file element in Moodle 2.0 . Empty, when filepath is empty.

  • HTMLEDITOR

Empty when it doesn't contains eny content.

  • PASSWORD and PASSWORDUNMASK

A password element. Empty, when it doesn't contains any text.

  • TEXT

Simple text input element. Empty, when it doesn't contains any text.

  • TEXTAREA

A textarea element. Empty, when it doesn't contains any text.

Other form elements like DATEPICKER, RECAPTCHA, SELECT, HIDDEN and others can contain's any values, becuse they won't be check.

Blank's removing realize by pushind remove button(see screenshot) and confirming your choise. If blank's removing isn't possible user will get allert with reason. remove.jpg

Moving blanks

Blanks moving is available by dragging them with move button At any moment you can set all your blanks in default positions, using button "Restore order"