Ejemplo n.º 1
0
 /**
  * Rewrite plugin file urls so they resolve correctly in an exported zip.
  *
  * @param string $text - The replacement text
  * @param stdClass $user - The user record
  * @param setask_plugin $plugin - The setaskment plugin
  */
 public function download_rewrite_pluginfile_urls($text, $user, $plugin)
 {
     $groupmode = groups_get_activity_groupmode($this->get_course_module());
     $groupname = '';
     if ($groupmode) {
         $groupid = groups_get_activity_group($this->get_course_module(), true);
         $groupname = groups_get_group_name($groupid) . '-';
     }
     if ($this->is_blind_marking()) {
         $prefix = $groupname . get_string('participant', 'setask');
         $prefix = str_replace('_', ' ', $prefix);
         $prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($user->id) . '_');
     } else {
         $prefix = $groupname . fullname($user);
         $prefix = str_replace('_', ' ', $prefix);
         $prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($user->id) . '_');
     }
     $subtype = $plugin->get_subtype();
     $type = $plugin->get_type();
     $prefix = $prefix . $subtype . '_' . $type . '_';
     $result = str_replace('@@PLUGINFILE@@/', $prefix, $text);
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Write the plugin summary with an optional link to view the full feedback/submission.
  *
  * @param setask_plugin $plugin Submission plugin or feedback plugin
  * @param stdClass $item Submission or grade
  * @param string $returnaction The return action to pass to the
  *                             view_submission page (the current page)
  * @param string $returnparams The return params to pass to the view_submission
  *                             page (the current page)
  * @return string The summary with an optional link
  */
 private function format_plugin_summary_with_link(setask_plugin $plugin, stdClass $item, $returnaction, $returnparams)
 {
     $link = '';
     $showviewlink = false;
     $summary = $plugin->view_summary($item, $showviewlink);
     $separator = '';
     if ($showviewlink) {
         $viewstr = get_string('view' . substr($plugin->get_subtype(), strlen('setask')), 'setask');
         $icon = $this->output->pix_icon('t/preview', $viewstr);
         $urlparams = array('id' => $this->setaskment->get_course_module()->id, 'sid' => $item->id, 'gid' => $item->id, 'plugin' => $plugin->get_type(), 'action' => 'viewplugin' . $plugin->get_subtype(), 'returnaction' => $returnaction, 'returnparams' => http_build_query($returnparams));
         $url = new moodle_url('/mod/setask/view.php', $urlparams);
         $link = $this->output->action_link($url, $icon);
         $separator = $this->output->spacer(array(), true);
     }
     return $link . $separator . $summary;
 }
Ejemplo n.º 3
0
 /**
  * Does this file exist in any of the current files supported by this plugin for this user?
  *
  * @param setask $setaskment - The setaskment instance
  * @param stdClass $user The user matching this uploaded file
  * @param setask_plugin $plugin The matching plugin from the filename
  * @param string $filename The parsed filename from the zip
  * @param stored_file $fileinfo The info about the extracted file from the zip
  * @return bool - True if the file has been modified or is new
  */
 public function is_file_modified($setaskment, $user, $plugin, $filename, $fileinfo)
 {
     $sg = null;
     if ($plugin->get_subtype() == 'setasksubmission') {
         $sg = $setaskment->get_user_submission($user->id, false);
     } else {
         if ($plugin->get_subtype() == 'setaskfeedback') {
             $sg = $setaskment->get_user_grade($user->id, false);
         } else {
             return false;
         }
     }
     if (!$sg) {
         return true;
     }
     foreach ($plugin->get_files($sg, $user) as $pluginfilename => $file) {
         if ($pluginfilename == $filename) {
             // Extract the file and compare hashes.
             $contenthash = '';
             if (is_array($file)) {
                 $content = reset($file);
                 $contenthash = sha1($content);
             } else {
                 $contenthash = $file->get_contenthash();
             }
             if ($contenthash != $fileinfo->get_contenthash()) {
                 return true;
             } else {
                 return false;
             }
         }
     }
     return true;
 }