Ejemplo n.º 1
0
 function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     return $data;
 }
Ejemplo n.º 2
0
 function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     if (!isset($data->usecoursegroups)) {
         $data->usecoursegroups = 0;
     }
     return $data;
 }
Ejemplo n.º 3
0
 function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     // Set up completion section even if checkbox is not ticked
     if (empty($data->completionsection)) {
         $data->completionsection = 0;
     }
     return $data;
 }
Ejemplo n.º 4
0
 /**
  * Return submitted data if properly submitted or returns NULL if validation fails or
  * if there is no submitted data.
  *
  * @return stdClass submitted data; NULL if not valid or not submitted or cancelled
  */
 public function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     if (!empty($data->completionunlocked)) {
         // Turn off completion settings if the checkboxes aren't ticked.
         $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
         if (!$autocompletion || empty($data->completionsubmit)) {
             $data->completionsubmit = 0;
         }
     }
     return $data;
 }
 /**
  * Extend get_data() to support completion checkbox behaviour
  * [feature #7]
  */
 function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     // Turn off completion settings if the checkboxes aren't ticked
     if (!empty($data->completionunlocked)) {
         $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
         if (empty($data->completiontotaldurationenabled) || !$autocompletion) {
             $data->completiontotaldurationmins = 0;
         }
     }
     // ... when more tracked values will be supported, set disabled value here
     return $data;
 }
Ejemplo n.º 6
0
 public function get_data($slashed = true)
 {
     $data = parent::get_data($slashed);
     if (!$data) {
         return false;
     }
     // Convert completionstatusrequired to a proper integer, if any.
     $total = 0;
     if (isset($data->completionstatusrequired) && is_array($data->completionstatusrequired)) {
         foreach (array_keys($data->completionstatusrequired) as $state) {
             $total |= $state;
         }
         $data->completionstatusrequired = $total;
     }
     if (!empty($data->completionunlocked)) {
         // Turn off completion settings if the checkboxes aren't ticked.
         $autocompletion = isset($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
         if (!(isset($data->completionstatusrequired) && $autocompletion)) {
             $data->completionstatusrequired = null;
         }
         // Else do nothing: completionstatusrequired has been already converted
         //             into a correct integer representation.
         if (!empty($data->completionscoredisabled) || !$autocompletion) {
             $data->completionscorerequired = null;
         }
     }
     return $data;
 }
Ejemplo n.º 7
0
    function get_data($slashed = true) {
        $data = parent::get_data($slashed);

        if (!$data) {
            return false;
        }

        if (!empty($data->completionunlocked)) {
            // Turn off completion settings if the checkboxes aren't ticked
            $autocompletion = isset($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;

            if (isset($data->completionstatusrequired) &&
                    is_array($data->completionstatusrequired) && $autocompletion) {
                $total = 0;
                foreach (array_keys($data->completionstatusrequired) as $state) {
                    $total |= $state;
                }

                $data->completionstatusrequired = $total;
            } else {
                $data->completionstatusrequired = null;
            }

            if (!empty($data->completionscoredisabled) || !$autocompletion) {
                $data->completionscorerequired = null;
            }
        }

        return $data;
    }
Ejemplo n.º 8
0
 public function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     // Turn off completion settings if the checkboxes aren't ticked.
     if (!empty($data->completionunlocked)) {
         // Weird effect of form resubmission. but why ?
         $data->completionallviewedenabled = @$_POST['completionallviewedenabled'];
         $data->completionallviewed = @$_POST['completionallviewed'];
         $data->completionallgoodenabled = @$_POST['completionallgoodenabled'];
         $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
         if (empty($data->completionallviewedenabled) || !$autocompletion) {
             $data->completionallviewed = 0;
         } else {
             $data->completionallviewed = 999;
         }
         if (empty($data->completionallgoodenabled) || !$autocompletion) {
             $data->completionallgood = 0;
         } else {
             $data->completionallgood = 1;
         }
     }
     return $data;
 }
Ejemplo n.º 9
0
 public function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     // Turn off completion settings if the checkboxes aren't ticked
     $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
     if (empty($data->completionpostsenabled) || !$autocompletion) {
         $data->completionposts = 0;
     }
     if (empty($data->completioncommentsenabled) || !$autocompletion) {
         $data->completioncomments = 0;
     }
     // If maxvisibility is disabled by individual mode, ensure it's limited to course.
     if (isset($data->individual) && ($data->individual == OUBLOG_SEPARATE_INDIVIDUAL_BLOGS || $data->individual == OUBLOG_VISIBLE_INDIVIDUAL_BLOGS)) {
         $data->maxvisibility = OUBLOG_VISIBILITY_COURSEUSER;
     }
     // Set the reportingemail to null if empty so that we have consistency.
     if (empty($data->reportingemail)) {
         $data->reportingemail = null;
     }
     // Set statblockon to null if empty so that we have consistency.
     if (empty($data->statblockon)) {
         $data->statblockon = 0;
     }
     if (empty($data->displayname)) {
         $data->displayname = null;
     }
     if (empty($data->allowimport)) {
         $data->allowimport = 0;
     }
     if (empty($data->introonpost)) {
         $data->introonpost = 0;
     }
     return $data;
 }
Ejemplo n.º 10
0
 function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     // Bit of a hack, but this is done to maintain consistency between the module and the forum modifications
     $data->anonymous = true;
     // Turn off completion settings if the checkboxes aren't ticked
     if (!empty($data->completionunlocked)) {
         $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
         if (empty($data->completiondiscussionsenabled) || !$autocompletion) {
             $data->completiondiscussions = 0;
         }
         if (empty($data->completionrepliesenabled) || !$autocompletion) {
             $data->completionreplies = 0;
         }
         if (empty($data->completionpostsenabled) || !$autocompletion) {
             $data->completionposts = 0;
         }
     }
     return $data;
 }
 function get_data($slashed = true)
 {
     $data = parent::get_data($slashed);
     if (!$data) {
         return false;
     }
     // Set the reportingemail to null if empty so that they are consistency
     if (empty($data->reportingemail)) {
         $data->reportingemail = null;
     }
     // Set the removeto to null if the default option 'Delete permanently' was select
     if (empty($data->removeto)) {
         $data->removeto = null;
     }
     // Turn off ratings/limit if required
     if (empty($data->enableratings)) {
         $data->ratingscale = 0;
     }
     if (empty($data->limitgroup['enablelimit'])) {
         $data->maxpostsperiod = 0;
         $data->maxpostsblock = 0;
     } else {
         $data->maxpostsperiod = $data->limitgroup['maxpostsperiod'];
         $data->maxpostsblock = $data->limitgroup['maxpostsblock'];
     }
     // Turn off completion settings if the checkboxes aren't ticked
     $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
     if (empty($data->completiondiscussionsenabled) || !$autocompletion) {
         $data->completiondiscussions = 0;
     }
     if (empty($data->completionrepliesenabled) || !$autocompletion) {
         $data->completionreplies = 0;
     }
     if (empty($data->completionpostsenabled) || !$autocompletion) {
         $data->completionposts = 0;
     }
     return $data;
 }
Ejemplo n.º 12
0
 public function get_data()
 {
     $data = parent::get_data();
     if ($data) {
         $data->page_after_submitformat = $data->page_after_submit_editor['format'];
         $data->page_after_submit = $data->page_after_submit_editor['text'];
         if (!empty($data->completionunlocked)) {
             // Turn off completion settings if the checkboxes aren't ticked
             $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
             if (!$autocompletion || empty($data->completionsubmit)) {
                 $data->completionsubmit = 0;
             }
         }
     }
     return $data;
 }
 public function get_data()
 {
     $data = parent::get_data();
     if ($data) {
         $data->bookingpolicyformat = $data->bookingpolicy['format'];
         $data->bookingpolicy = $data->bookingpolicy['text'];
     }
     return $data;
 }
Ejemplo n.º 14
0
 public function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     // Turn off completion settings if the checkboxes aren't ticked
     $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
     if (empty($data->completionpagesenabled) || !$autocompletion) {
         $data->completionpages = 0;
     }
     if (empty($data->completioneditsenabled) || !$autocompletion) {
         $data->completionedits = 0;
     }
     if (empty($data->allowimport)) {
         $data->allowimport = 0;
     }
     return $data;
 }
Ejemplo n.º 15
0
 /**
  *
  */
 public function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     if (empty($data->timeavailable)) {
         unset($data->timeinterval);
         $data->intervalcount = 1;
     }
     if (empty($data->timeinterval)) {
         $data->intervalcount = 1;
     }
     // Turn off completion settings if the checkboxes aren't ticked.
     if (!empty($data->completionunlocked)) {
         $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
         if (empty($data->completionentriesenabled) or !$autocompletion) {
             $data->completionentries = 0;
         }
         if (empty($data->completionspecificgradeenabled) or !$autocompletion) {
             $data->completionspecificgrade = 0;
         }
         if (empty($data->grade) and !empty($data->completionspecificgradeenabled)) {
             unset($data->completionspecificgradeenabled);
             $data->completionspecificgrade = 0;
         }
         if (!empty($data->grade) and !empty($data->completionspecificgrade)) {
             if ($data->grade > 0) {
                 if ($data->completionspecificgrade > $data->grade) {
                     $data->completionspecificgrade = $data->grade;
                 }
             } else {
                 // Custom scale.
                 $scale = grade_scale::fetch(array('id' => -$data->grade));
                 $numitems = count($scale->load_items());
                 if ($data->completionspecificgrade > $numitems) {
                     $data->completionspecificgrade = $numitems;
                 }
             }
         }
     }
     // Grade items.
     $gradeitems = array();
     if ($this->_instance) {
         $gradeitems = \mod_dataform_dataform::instance($this->_instance)->grade_items;
     }
     $gradeitems[0] = empty($gradeitems[0]) ? array() : $gradeitems[0];
     $updategradeitems = false;
     // Check grade calc change.
     $thiscalc = !empty($gradeitems[0]['ca']) ? $gradeitems[0]['ca'] : null;
     $gradecalc = !empty($data->gradecalc) ? $data->gradecalc : null;
     if ($thiscalc != $gradecalc) {
         if (!$gradecalc) {
             unset($gradeitems[0]['ca']);
         } else {
             $gradeitems[0]['ca'] = $gradecalc;
         }
         $updategradeitems = true;
     }
     // Check grade guide change.
     $thisguide = !empty($gradeitems[0]['ru']) ? $gradeitems[0]['ru'] : null;
     $gradeguide = !empty($data->gradeguide) ? $data->gradeguide : null;
     if ($thisguide != $gradeguide) {
         if (!$gradeguide) {
             unset($gradeitems[0]['ru']);
         } else {
             $gradeitems[0]['ru'] = $gradeguide;
         }
         $updategradeitems = true;
     }
     if ($updategradeitems) {
         $data->gradeitems = $gradeitems[0] ? serialize($gradeitems) : null;
     }
     return $data;
 }
Ejemplo n.º 16
0
 public function get_data()
 {
     global $CFG;
     require_once dirname(__FILE__) . '/locallib.php';
     $data = parent::get_data();
     if (empty($data)) {
         return false;
     }
     //For Completion Rules
     if (!empty($data->completionunlocked)) {
         // Turn off completion settings if the checkboxes aren't ticked
         $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
         if (empty($data->completiontimeenabled) || !$autocompletion) {
             $data->requiredtime = 0;
         }
     }
     //File manager always creata a Files folder, so certimages is never empty.
     //I must check if it has a file or it's only a empty files folder reference
     if (isset($data->certificateimage) && !empty($data->certificateimage)) {
         if (!$this->check_has_files('certificateimage')) {
             $data->certificateimage = null;
         }
     }
     if (isset($data->secondimage) && !empty($data->secondimage)) {
         if (!$this->check_has_files('secondimage')) {
             $data->secondimage = null;
         }
     }
     return $data;
 }
Ejemplo n.º 17
0
 function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     if (!empty($data->completionunlocked)) {
         // Turn off completion settings if the checkboxes aren't ticked
         $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
         if (empty($data->completionentriesenabled) || !$autocompletion) {
             $data->completionentries = 0;
         }
     }
     return $data;
 }
Ejemplo n.º 18
0
 function get_data()
 {
     global $CFG, $COURSE, $USER;
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     if (isset($data->usecsvimport)) {
         // Set options from csv
         $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
         $fs = get_file_storage();
         if (!($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $data->csvfile, 'sortorder, id', false))) {
             return false;
         }
         if (count($files) != 1) {
             return false;
         }
         $csvfile = reset($files);
         $csv = readCSV($csvfile->get_content_file_handle(), true);
         // Manipulate $data to reflect form content (options, limit, grouping, optionid)
         $data = options_from_csv($data, $COURSE->id, $csv);
     }
     // Set up completion section even if checkbox is not ticked
     if (empty($data->completionsection)) {
         $data->completionsection = 0;
     }
     return $data;
 }
Ejemplo n.º 19
0
 public function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     // Turn off completion setting if the checkbox is not ticked.
     if (!empty($data->completionunlocked)) {
         $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
         if (empty($data->completiontimespentenabled) || !$autocompletion) {
             $data->completiontimespent = 0;
         }
     }
     return $data;
 }
Ejemplo n.º 20
0
 public function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     // Set the reportingemail to null if empty so that they are consistency
     if (empty($data->reportingemail)) {
         $data->reportingemail = null;
     }
     // Set the canpostanon to 0 if empty so that they are consistency
     if (empty($data->canpostanon)) {
         $data->canpostanon = 0;
     }
     // Set the tags to 0 if empty so that they are consistency.
     if (empty($data->tags)) {
         $data->tags = 0;
     }
     // Set the removeto to null if the default option 'Delete permanently' was select
     if (empty($data->removeto)) {
         $data->removeto = null;
     }
     // Set the removeto to null if option 'Automatically lock' was selected and removeafter is empty.
     if ($data->removeto == -1 && empty($data->removeafter)) {
         $data->removeto = null;
     }
     // Turn off ratings/limit if required
     if (empty($data->enableratings)) {
         $data->ratingscale = 0;
     }
     if (empty($data->limitgroup['enablelimit'])) {
         $data->maxpostsperiod = 0;
         $data->maxpostsblock = 0;
     } else {
         $data->maxpostsperiod = $data->limitgroup['maxpostsperiod'];
         $data->maxpostsblock = $data->limitgroup['maxpostsblock'];
     }
     // Turn off completion settings if the checkboxes aren't ticked
     $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
     if (empty($data->completiondiscussionsenabled) || !$autocompletion) {
         $data->completiondiscussions = 0;
     }
     if (empty($data->completionrepliesenabled) || !$autocompletion) {
         $data->completionreplies = 0;
     }
     if (empty($data->completionpostsenabled) || !$autocompletion) {
         $data->completionposts = 0;
     }
     // Add in fake form data for clone forums, so core functions expecting it works OK.
     if ($this->clone && !isset($data->introeditor)) {
         // Add fake intro text - is ignored anyway for clones as master is shown.
         $data->introeditor = array('itemid' => 0, 'text' => '', 'format' => FORMAT_MOODLE);
     }
     return $data;
 }