Moodle
  1. Moodle
  2. MDL-17126

Automatic resource name when linking to a file

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor 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

          Activity

          Hide
          Séverin Terrier added a comment -

          It could be usefull

          Just have to be sure not to update the name of the resource if something is already typed in

          Show
          Séverin Terrier added a comment - It could be usefull Just have to be sure not to update the name of the resource if something is already typed in
          Hide
          Khaled Zamani added a comment -

          It is good idea. I'll update the code and post it,

          Cheers

          Show
          Khaled Zamani added a comment - It is good idea. I'll update the code and post it, Cheers
          Hide
          Marina Glancy added a comment -

          We have detected that this issue has been inactive for over two years and also did not collect many votes. It is possible that it has been already implemented in a more recent version of Moodle, or it is not highly demanded. There are unlimited number of ways Moodle functinality can be expanded and improved but we would like to concentrate on the features that will benefit majority of users, and which can not be implemented as plugins. If you have a suggestion for improving Moodle core, and there is no open issue for it in the tracker, please start a new forum discussion to see how many other users agree with you, and then create a new issue providing as many details as possible.

          ==BLK2YIMP20141121==

          Show
          Marina Glancy added a comment - We have detected that this issue has been inactive for over two years and also did not collect many votes. It is possible that it has been already implemented in a more recent version of Moodle, or it is not highly demanded. There are unlimited number of ways Moodle functinality can be expanded and improved but we would like to concentrate on the features that will benefit majority of users, and which can not be implemented as plugins. If you have a suggestion for improving Moodle core, and there is no open issue for it in the tracker, please start a new forum discussion to see how many other users agree with you, and then create a new issue providing as many details as possible. ==BLK2YIMP20141121==

            People

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

              Dates

              • Created:
                Updated:
                Resolved: