Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-17126

Automatic resource name when linking to a file

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Inactive
    • Affects Version/s: 1.9.3
    • Fix Version/s: DEV backlog
    • Component/s: Resource
    • Labels:
      None
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      When linking to a file in (Add a resource) the name of the resource is automatically the filename. Of course you can change it to what ever you want, but if you give your files good names this helps a lot. This is tested and works with 1.9.3+ (Build: 20080730)

      Things to do:

      Edit ---> file\index.php
      Change the javascript beginning at line 100 to

      function cleantext(ptxt, pchar1, pchar2){
      var atpos;
      var myArray = ptxt.toLowerCase().split('');
      for (i=0;i<myArray.length;i++)
      {
      atpos = ptxt.indexOf(pchar1);
      if (myArray[i] == pchar1)
      {
      if (atpos > -1)

      { ptxt = ptxt.substring(atpos+1, ptxt.length); }

      }
      }

      var atpos2 = ptxt.indexOf(pchar2);
      if (atpos2 > -1)

      { ptxt = ptxt.substring(0, atpos2); }


      return ptxt;
      }

      function set_value(txt)

      { opener.document.getElementById('<?php echo $chooseparts[0] ?>').value = txt; vtxt1 = cleantext(txt, "/", "."); opener.document.getElementById('name').value = vtxt1; window.close(); }

      This code works with any directory depth.
      Example: when you link to a file from folder xxx/yyy/zzz/file.doc the name of the resource will be (file) without the name of the direcoties and extention.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: