ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilExcCriteriaFile Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilExcCriteriaFile:
+ Collaboration diagram for ilExcCriteriaFile:

Public Member Functions

 getType ()
 
 getFiles ()
 
 resetReview ()
 
 addToPeerReviewForm ($a_value=null)
 
 importFromPeerReviewForm ()
 
 hasValue ($a_value)
 
 validate ($a_value)
 
 getFileByHash ()
 
 getHTML ($a_value)
 
- Public Member Functions inherited from ilExcCriteria
 __construct ()
 
 getTranslatedType ()
 
 getId ()
 
 getType ()
 
 setParent (?int $a_value)
 
 getParent ()
 
 setTitle (?string $a_value)
 
 getTitle ()
 
 setDescription (?string $a_value)
 
 getDescription ()
 
 setRequired (bool $a_value)
 
 isRequired ()
 
 setPosition (int $a_value)
 
 getPosition ()
 
 importDefinition (string $a_def, string $a_def_json)
 
 save ()
 
 update ()
 
 delete ()
 
 cloneObject (int $a_target_parent_id)
 
 initCustomForm (ilPropertyFormGUI $a_form)
 
 exportCustomForm (ilPropertyFormGUI $a_form)
 
 importCustomForm (ilPropertyFormGUI $a_form)
 
 setPeerReviewContext (ilExAssignment $a_ass, int $a_giver_id, int $a_peer_id, ilPropertyFormGUI $a_form=null)
 
 addToPeerReviewForm ($a_value=null)
 
 importFromPeerReviewForm ()
 
 updateFromAjax ()
 
 validate ($a_value)
 
 hasValue ($a_value)
 
 getHTML ($a_value)
 
 resetReview ()
 

Protected Member Functions

 initStorage ()
 
- Protected Member Functions inherited from ilExcCriteria
 setId (?int $a_id)
 
 setDefinition (?array $a_value=null)
 
 getDefinition ()
 
 importFromDB (array $a_row)
 
 getDBProperties ()
 
 getLastPosition ()
 

Protected Attributes

string $requested_file_hash = ""
 
- Protected Attributes inherited from ilExcCriteria
ilLanguage $lng
 
ilCtrl $ctrl
 
ilDBInterface $db
 
int $id = null
 
int $parent = null
 
string $title = ""
 
string $desc = ""
 
bool $required = false
 
int $pos = 0
 
array $def = null
 
ilPropertyFormGUI $form = null
 
ilExAssignment $ass
 
int $giver_id = 0
 
int $peer_id = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from ilExcCriteria
static getInstanceById (int $a_id)
 
static getInstancesByParentId (int $a_parent_id)
 
static getTypesMap ()
 
static getInstanceByType (string $a_type)
 
static deleteByParent (int $a_parent_id)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilExcCriteriaFile

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 25 of file class.ilExcCriteriaFile.php.

Member Function Documentation

◆ addToPeerReviewForm()

ilExcCriteriaFile::addToPeerReviewForm (   $a_value = null)

Definition at line 66 of file class.ilExcCriteriaFile.php.

References ILIAS\Repository\form(), ilExcCriteria\getDescription(), getFiles(), ilExcCriteria\getId(), ilExcCriteria\getTitle(), and ilExcCriteria\isRequired().

66  : void
67  {
68  $existing = array();
69  foreach ($this->getFiles() as $file) {
70  $existing[] = basename($file);
71  }
72 
73  $files = new ilFileInputGUI($this->getTitle(), "prccc_file_" . $this->getId());
74  $files->setInfo($this->getDescription());
75  $files->setRequired($this->isRequired());
76  $files->setValue(implode("<br />", $existing));
77  $files->setAllowDeletion(true);
78  $this->form->addItem($files);
79  }
This class represents a file property in a property form.
form( $class_path, string $cmd)
+ Here is the call graph for this function:

◆ getFileByHash()

ilExcCriteriaFile::getFileByHash ( )
Returns
false|mixed

Definition at line 130 of file class.ilExcCriteriaFile.php.

References getFiles().

131  {
132  $hash = trim($this->requested_file_hash);
133  if ($hash != "") {
134  foreach ($this->getFiles() as $file) {
135  if (md5($file) == $hash) {
136  return $file;
137  }
138  }
139  }
140  return false;
141  }
+ Here is the call graph for this function:

◆ getFiles()

ilExcCriteriaFile::getFiles ( )

Definition at line 51 of file class.ilExcCriteriaFile.php.

References $path, and initStorage().

Referenced by addToPeerReviewForm(), getFileByHash(), getHTML(), and hasValue().

51  : array
52  {
53  $path = $this->initStorage();
54  return (array) glob($path . "*.*");
55  }
$path
Definition: ltiservices.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHTML()

ilExcCriteriaFile::getHTML (   $a_value)

Definition at line 143 of file class.ilExcCriteriaFile.php.

References ilExcCriteria\$ctrl, getFiles(), and ilExcCriteria\getId().

143  : string
144  {
145  $ilCtrl = $this->ctrl;
146 
147  $crit_id = $this->getId()
148  ?: "file";
149  $ilCtrl->setParameterByClass("ilExPeerReviewGUI", "fu", $this->giver_id . "__" . $this->peer_id . "__" . $crit_id);
150 
151  $files = array();
152  foreach ($this->getFiles() as $file) {
153  $ilCtrl->setParameterByClass("ilExPeerReviewGUI", "fuf", md5($file));
154  $dl = $ilCtrl->getLinkTargetByClass("ilExPeerReviewGUI", "downloadPeerReview");
155  $ilCtrl->setParameterByClass("ilExPeerReviewGUI", "fuf", "");
156 
157  $files[] = '<a href="' . $dl . '">' . basename($file) . '</a>';
158  }
159 
160  $ilCtrl->setParameterByClass("ilExPeerReviewGUI", "fu", "");
161 
162  return implode("<br />", $files);
163  }
+ Here is the call graph for this function:

◆ getType()

ilExcCriteriaFile::getType ( )

Definition at line 40 of file class.ilExcCriteriaFile.php.

40  : string
41  {
42  return "file";
43  }

◆ hasValue()

ilExcCriteriaFile::hasValue (   $a_value)

Definition at line 106 of file class.ilExcCriteriaFile.php.

References getFiles().

Referenced by validate().

106  : bool
107  {
108  return count($this->getFiles()) > 0;
109  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importFromPeerReviewForm()

ilExcCriteriaFile::importFromPeerReviewForm ( )
Exceptions
ilException

Definition at line 84 of file class.ilExcCriteriaFile.php.

References $path, ilFileUtils\delDir(), ILIAS\Repository\form(), ilExcCriteria\getId(), initStorage(), and ilFileUtils\moveUploadedFile().

84  : void
85  {
86  $path = $this->initStorage();
87 
88  if ($this->form->getItemByPostVar("prccc_file_" . $this->getId())->getDeletionFlag()) {
90  $this->form->getItemByPostVar("prccc_file_" . $this->getId())->setValue("");
91  }
92 
93  $incoming = $_FILES["prccc_file_" . $this->getId()];
94  if ($incoming["tmp_name"]) {
95  $org_name = basename($incoming["name"]);
96 
98  $incoming["tmp_name"],
99  $org_name,
100  $path . $org_name,
101  false
102  );
103  }
104  }
$path
Definition: ltiservices.php:32
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
form( $class_path, string $cmd)
+ Here is the call graph for this function:

◆ initStorage()

ilExcCriteriaFile::initStorage ( )
protected

Definition at line 45 of file class.ilExcCriteriaFile.php.

References ilExcCriteria\getId(), and ilFSStorageExercise\getPeerReviewUploadPath().

Referenced by getFiles(), and importFromPeerReviewForm().

45  : string
46  {
47  $storage = new ilFSStorageExercise($this->ass->getExerciseId(), $this->ass->getId());
48  return $storage->getPeerReviewUploadPath($this->peer_id, $this->giver_id, $this->getId());
49  }
getPeerReviewUploadPath(int $a_peer_id, int $a_giver_id, ?int $a_crit_id=null)
Get pear review upload path (each peer handled in a separate path)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetReview()

ilExcCriteriaFile::resetReview ( )

Definition at line 57 of file class.ilExcCriteriaFile.php.

References ilFileSystemAbstractionStorage\deleteDirectory().

57  : void
58  {
59  $storage = new ilFSStorageExercise($this->ass->getExerciseId(), $this->ass->getId());
60  $storage->deleteDirectory($storage->getPeerReviewUploadPath($this->peer_id, $this->giver_id, $this->getId()));
61  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ validate()

ilExcCriteriaFile::validate (   $a_value)

Definition at line 111 of file class.ilExcCriteriaFile.php.

References ilExcCriteria\$lng, ILIAS\Repository\form(), ilExcCriteria\getId(), hasValue(), ilExcCriteria\isRequired(), and ilLanguage\txt().

111  : bool
112  {
113  $lng = $this->lng;
114 
115  // because of deletion flag we have to also check ourselves
116  if ($this->isRequired()) {
117  if (!$this->hasValue($a_value)) {
118  if ($this->form) {
119  $this->form->getItemByPostVar("prccc_file_" . $this->getId())->setAlert($lng->txt("msg_input_is_required"));
120  }
121  return false;
122  }
123  }
124  return true;
125  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
form( $class_path, string $cmd)
+ Here is the call graph for this function:

Field Documentation

◆ $requested_file_hash

string ilExcCriteriaFile::$requested_file_hash = ""
protected

Definition at line 27 of file class.ilExcCriteriaFile.php.


The documentation for this class was generated from the following file: