예제 #1
0
 /**
  *
  */
 public static function execute($df)
 {
     global $DB;
     // Get gradebook users.
     if (!($users = $df->grade_manager->get_gradebook_users())) {
         return;
     }
     // Construct entries data.
     $data = (object) array('eids' => array());
     $entryid = -1;
     foreach ($users as $userid => $unused) {
         $data->eids[$entryid] = $entryid;
         $data->{"entry_{$entryid}_userid"} = $userid;
         $entryid--;
     }
     // Add entries.
     $em = new mod_dataform_entry_manager($df->id);
     $processed = $em->process_entries('update', $data->eids, $data, true);
     if (is_array($processed)) {
         list($strnotify, $processedeids) = $processed;
         if ($entriesprocessed = $processedeids ? count($processedeids) : 0) {
             return array('success', $strnotify);
         }
     }
     return array('problem', get_string('entriesupdated', 'dataform', get_string('no')));
 }
예제 #2
0
 /**
  * Returns the view's dataform-entries manager.
  *
  * @return mod_dataform_entry_manager
  */
 public function get_entry_manager()
 {
     return \mod_dataform_entry_manager::instance($this->dataid, $this->id);
 }
예제 #3
0
 /**
  * Deletes all user data in the activity.
  *
  * @return bool Always true.
  */
 public function reset_user_data($userid = null)
 {
     // Must have manage templates capability.
     require_capability('mod/dataform:managetemplates', $this->context);
     $entryman = new mod_dataform_entry_manager($this->id);
     $entryman->delete_entries($userid);
     return true;
 }