Moodle
  1. Moodle
  2. MDL-38317

Grade item mappings when importing grade needs translation

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.6, 2.5.2
    • Fix Version/s: 2.4.7, 2.5.3
    • Component/s: Gradebook
    • Labels:
    • Testing Instructions:
      Hide
      1. Add a second language of your choice in your site.
      2. Temporarily update manually (In AMOS after integration) the following strings for this language in "Site administration > Language > Language customisation" (file grades.php) :
        • feedbacks
        • feedbackforgradeitems
        • ignore
        • others
        • userid
      3. Create a new course and enroll some students in it.
      4. Add 1 assignment in the course.
      5. Add 1 new grade item in "Grade administration > Categories and items > Simple view", "Add grade item" button.
      6. Update grades of the assignment and grade item for some students.
      7. Export grades to CSV file (Plain text file with tab separator).
      8. Re-update or erase grades of the assignment and grade item for the same students updated above.
      9. Import grades from the CSV file exported: go to "Grade administration > Import > CSV file", upload file and click on "Upload grades" button.
      10. Assert that the values are displayed correctly in the following dropdown lists :
        • Identify user by > Map to
        • Grade item mappings (Any list)
      11. Map values like this :
        • Identify user by > Map from : Username
        • Identify user by > Map to : Username
        • Grade item mappings > Assignment: (Name of the assignment): Assignment: (Name of the assignment)
        • Grade item mappings > (Name of the grade item) : (Name of the grade item)
      12. Click on "Upload grades" button
        Import should be a success
      13. Redo 8 to 12 but with the other language selected.
      Show
      Add a second language of your choice in your site. Temporarily update manually (In AMOS after integration) the following strings for this language in "Site administration > Language > Language customisation" (file grades.php) : feedbacks feedbackforgradeitems ignore others userid Create a new course and enroll some students in it. Add 1 assignment in the course. Add 1 new grade item in "Grade administration > Categories and items > Simple view", "Add grade item" button. Update grades of the assignment and grade item for some students. Export grades to CSV file (Plain text file with tab separator). Re-update or erase grades of the assignment and grade item for the same students updated above. Import grades from the CSV file exported: go to "Grade administration > Import > CSV file", upload file and click on "Upload grades" button. Assert that the values are displayed correctly in the following dropdown lists : Identify user by > Map to Grade item mappings (Any list) Map values like this : Identify user by > Map from : Username Identify user by > Map to : Username Grade item mappings > Assignment: (Name of the assignment): Assignment: (Name of the assignment) Grade item mappings > (Name of the grade item) : (Name of the grade item) Click on "Upload grades" button Import should be a success Redo 8 to 12 but with the other language selected.
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull from Repository:
    • Pull 2.4 Branch:
      MDL-38317-moodle24
    • Pull 2.5 Branch:
      MDL-38317-moodle25
    • Pull Master Branch:
      MDL-38317-master
    • Rank:
      48183

      Description

      In the gradebook, the item mapping section when importing grades is not translated. The following labels are hardcoded in the grade_import_mapping_form:

      • comments for
      • others
      • ignore
      • newgradeitem
      • comments

      The related code, in /grade/import/grade_import_form.php:

              $comments = array();
              if ($gradeitems = $this->_customdata['gradeitems']) {
                  foreach ($gradeitems as $itemid => $itemname) {
                      $comments['feedback_'.$itemid] = 'comments for '.$itemname;
                  }
              }
      
              if ($header) {
                  $i = 0; // index
                  foreach ($header as $h) {
                      $h = trim($h);
                      // this is what each header maps to
                      $mform->addElement('selectgroups', 'mapping_'.$i, s($h),
                          array('others'=>array('0'=>'ignore', 'new'=>'new gradeitem'),
                          'gradeitems'=>$gradeitems,
                          'comments'=>$comments));
                      $i++;
                  }
              }
      

        Issue Links

          Activity

          Hide
          Jean-Daniel Descoteaux added a comment -

          Suggesting adding the following into /lang/en/grades.php:

          $string['others'] = 'Others';
          $string['newgradeitem'] = 'new grade item';
          $string['comments'] = 'Comments';
          $string['commentsfor'] = 'Comments for';
          $string['ignore'] = 'ignore';
          

          and changing code from /grade/import/grade_import_form.php to add get_string() calls:

          
                  $comments = array();
                  if ($gradeitems = $this->_customdata['gradeitems']) {
                      foreach ($gradeitems as $itemid => $itemname) {
                           $comments['feedback_'.$itemid] = get_string('commentsfor','grades').' '.$itemname;
                      }
                  }
          
                  if ($header) {
                      $i = 0; // index
                      foreach ($header as $h) {
                          $h = trim($h);
                          // this is what each header maps to
                          $mform->addElement('selectgroups', 'mapping_'.$i, s($h),
                              array(get_string('others','grades')=>array('0'=>get_string('ignore','grades'), 'new'=>get_string('newgradeitem','grades')),
                              get_string('gradeitems','grades')=>$gradeitems,
                              get_string('comments','grades')=>$comments));
                          $i++;
                      }
                  }
          
          
          Show
          Jean-Daniel Descoteaux added a comment - Suggesting adding the following into /lang/en/grades.php: $string['others'] = 'Others'; $string['newgradeitem'] = ' new grade item'; $string['comments'] = 'Comments'; $string['commentsfor'] = 'Comments for '; $string['ignore'] = 'ignore'; and changing code from /grade/import/grade_import_form.php to add get_string() calls: $comments = array(); if ($gradeitems = $ this ->_customdata['gradeitems']) { foreach ($gradeitems as $itemid => $itemname) { $comments['feedback_'.$itemid] = get_string('commentsfor','grades').' '.$itemname; } } if ($header) { $i = 0; // index foreach ($header as $h) { $h = trim($h); // this is what each header maps to $mform->addElement('selectgroups', 'mapping_'.$i, s($h), array(get_string('others','grades')=>array('0'=>get_string('ignore','grades'), ' new '=>get_string('newgradeitem','grades')), get_string('gradeitems','grades')=>$gradeitems, get_string('comments','grades')=>$comments)); $i++; } }
          Hide
          Andrew Davis added a comment -

          This issue was assigned to me automatically, however I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue.

          For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment

          Show
          Andrew Davis added a comment - This issue was assigned to me automatically, however I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue. For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment
          Hide
          Jean-Philippe Gaudreau added a comment -

          Here's a patch to fix translation for the strings in the drop down lists of the Grade item mappings in grade import to CSV. I also did those of the "Identify user by > Map to" drop down list, as it was the same problem.

          I'm still unsure about what is the right way to call the "userid" field in "Identify user by > Map to" drop down list. I hesitated between "User ID" or simply "ID". I ended putting "User ID". If anyone has anything better in mind, I'm willing to make the change without problem.

          Thx!

          Show
          Jean-Philippe Gaudreau added a comment - Here's a patch to fix translation for the strings in the drop down lists of the Grade item mappings in grade import to CSV. I also did those of the "Identify user by > Map to" drop down list, as it was the same problem. I'm still unsure about what is the right way to call the "userid" field in "Identify user by > Map to" drop down list. I hesitated between "User ID" or simply "ID". I ended putting "User ID". If anyone has anything better in mind, I'm willing to make the change without problem. Thx!
          Hide
          Jean-Philippe Gaudreau added a comment -

          It seems the appropriate terminology for "comments" in grades is "Feedbacks". Putting back to "development in progress" to fix this.

          Show
          Jean-Philippe Gaudreau added a comment - It seems the appropriate terminology for "comments" in grades is "Feedbacks". Putting back to "development in progress" to fix this.
          Hide
          Rajesh Taneja added a comment -

          Thanks for fixing this Jean-Daniel.

          Patch looks spot-on. Pushing for integration review.

          Show
          Rajesh Taneja added a comment - Thanks for fixing this Jean-Daniel. Patch looks spot-on. Pushing for integration review.
          Hide
          Jean-Philippe Gaudreau added a comment -

          It's Jean-Philippe but thx anyway ! And thx to Jean-Daniel for reporting this and providing hints on the fix!

          Show
          Jean-Philippe Gaudreau added a comment - It's Jean-Philippe but thx anyway ! And thx to Jean-Daniel for reporting this and providing hints on the fix!
          Hide
          Rajesh Taneja added a comment -

          Aha, Sorry Jean-Philippe

          Thanks for correcting me ....

          Show
          Rajesh Taneja added a comment - Aha, Sorry Jean-Philippe Thanks for correcting me ....
          Hide
          Sam Hemelryk added a comment -

          Hi Jean-Philippe,

          The changes here look really good. I noted just a single issue that needs to be addressed before this can be integrated.
          The Moodle 25 branch has an error, it appears you've removed the mapto element.
          It looks like a trivial fix so I'll leave this in integration review in progress. Could you please fix that up and let me know when its done so I can pull this in.

          Many thanks
          Sam

          Show
          Sam Hemelryk added a comment - Hi Jean-Philippe, The changes here look really good. I noted just a single issue that needs to be addressed before this can be integrated. The Moodle 25 branch has an error, it appears you've removed the mapto element. It looks like a trivial fix so I'll leave this in integration review in progress. Could you please fix that up and let me know when its done so I can pull this in. Many thanks Sam
          Hide
          Jean-Philippe Gaudreau added a comment -

          Hi Sam,

          Sorry my bad... It is fixed now!

          Thx!

          Show
          Jean-Philippe Gaudreau added a comment - Hi Sam, Sorry my bad... It is fixed now! Thx!
          Hide
          Sam Hemelryk added a comment -

          Thanks Jean-Philippe, this has been integrated now

          Show
          Sam Hemelryk added a comment - Thanks Jean-Philippe, this has been integrated now
          Hide
          Mark Nelson added a comment -

          Works as expected, passing.

          Thanks for your contribution Jean-Philippe and Jean-Daniel.

          Show
          Mark Nelson added a comment - Works as expected, passing. Thanks for your contribution Jean-Philippe and Jean-Daniel.
          Hide
          Sam Hemelryk added a comment -

          Yarrr me 'arties, good job done. Yer code 'as landed and the weeklies ave been released with your contributions in tow.
          The brethren thank ya for yer 'ard work and if there'd been treasure to ave ya would ave got yer cut.

          Thanks for the effort everyone, another successful weekly release has been rolled.
          Please keep in mind code freeze is just around the corner now, get your new features and improvements in ASAP.

          Many thanks
          Sam

          Show
          Sam Hemelryk added a comment - Yarrr me 'arties, good job done. Yer code 'as landed and the weeklies ave been released with your contributions in tow. The brethren thank ya for yer 'ard work and if there'd been treasure to ave ya would ave got yer cut. Thanks for the effort everyone, another successful weekly release has been rolled. Please keep in mind code freeze is just around the corner now, get your new features and improvements in ASAP. Many thanks Sam

            People

            • Votes:
              5 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: