コード例 #1
0
 function parse($value)
 {
     if (is_percentage($value)) {
         return new TextIndentValuePDF(array((int) $value, true));
     } else {
         return new TextIndentValuePDF(array($value, false));
     }
 }
コード例 #2
0
 function parse($value)
 {
     if ($value === 'inherit') {
         return CSS_PROPERTY_INHERIT;
     }
     if (is_percentage($value)) {
         return new TextIndentValuePDF(array((int) $value, true));
     } else {
         return new TextIndentValuePDF(array($value, false));
     }
 }
コード例 #3
0
 function parse_col(&$root, $index)
 {
     if ($root->has_attribute('width')) {
         // The value if 'width' attrubute is "multi-length";
         // it means that it could be:
         // 1. absolute value (10)
         // 2. percentage value (10%)
         // 3. relative value (3* or just *)
         //
         // TODO: support for relative values
         $value = $root->get_attribute('width');
         if (is_percentage($value)) {
             $this->cwc[$index] = new WCFraction((int) $value / 100);
         } else {
             $this->cwc[$index] = new WCConstant(px2pt((int) $value));
         }
     }
 }
コード例 #4
0
 function quick_dump()
 {
     global $CFG;
     require_once $CFG->dirroot . '/lib/excellib.class.php';
     //        $export_tracking = $this->track_exports();
     $strgrades = get_string('grades');
     $accuratetotals = get_user_preferences('accuratepointtotals') == null ? 1 : 0;
     /// Calculate file name
     $downloadfilename = clean_filename("{$this->course->shortname} {$strgrades}.xls");
     /// Creating a workbook
     $workbook = new MoodleExcelWorkbook("-");
     /// Sending HTTP headers
     $workbook->send($downloadfilename);
     /// Adding the worksheet
     $myxls =& $workbook->add_worksheet($strgrades);
     /// Print names of all the fields
     $myxls->write_string(0, 0, get_string("firstname"));
     $myxls->write_string(0, 1, get_string("lastname"));
     $myxls->write_string(0, 2, get_string("idnumber"));
     $myxls->write_string(0, 3, get_string("email"));
     $pos = 4;
     // write out column headers
     foreach ($this->gtree->items as $grade_item) {
         //            $myxls->write_string(0, $pos++, $this->format_column_name($grade_item));
         switch ($grade_item->itemtype) {
             case 'category':
                 $grade_item->item_category = grade_category::fetch(array('id' => $grade_item->iteminstance));
                 //                        $grade_item->load_category();
                 $myxls->write_string(0, $pos++, $grade_item->item_category->fullname . ' Category total');
                 break;
             case 'course':
                 $myxls->write_string(0, $pos++, 'Course total');
                 break;
             default:
                 $myxls->write_string(0, $pos++, $grade_item->itemname);
         }
         /// add a column_feedback column
         if (isset($this->export_feedback) and $this->export_feedback) {
             //                $myxls->write_string(0, $pos++, $this->format_column_name($grade_item, true));
             $myxls->write_string(0, $pos++, $grade_item->itemname);
         }
     }
     // write out range row
     $myxls->write_string(1, 2, 'Maximum grade->');
     $pos = 4;
     foreach ($this->gtree->items as $grade_item) {
         //            $myxls->write_string(0, $pos++, $this->format_column_name($grade_item));
         $myxls->write_number(1, $pos++, $grade_item->grademax);
         //            $myxls->write_number($i,$j++,$gradestr);
         /// add a column_feedback column
         if (isset($this->export_feedback) and $this->export_feedback) {
             //                $myxls->write_string(0, $pos++, $this->format_column_name($grade_item, true));
             $myxls->write_string(1, $pos++, $grade_item->name);
         }
     }
     // write out weights row
     $myxls->write_string(2, 2, 'Weight->');
     $pos = 4;
     foreach ($this->gtree->items as $grade_item) {
         if (isset($this->gtree->parents[$grade_item->id]->id) && $this->gtree->parents[$grade_item->id]->agg == GRADE_AGGREGATE_WEIGHTED_MEAN) {
             $myxls->write_number(2, $pos++, $grade_item->aggregationcoef);
             //                $myxls->write_string(1, $pos++, format_float($grade_item->aggregationcoef,0));
         } else {
             $myxls->write_string(2, $pos++, "");
         }
         /// add a column_feedback column
         if (isset($this->export_feedback) and $this->export_feedback) {
             $myxls->write_string(2, $pos++, $grade_item->name);
         }
     }
     /// Print all the lines of data.
     $i = 2;
     //        $geub = new grade_export_update_buffer();
     //        $gui = new graded_users_iterator($this->course, $this->columns, $this->groupid);
     //        $gui->init();
     foreach ($this->users as $key => $user) {
         $i++;
         //            $user = $userdata->user;
         $myxls->write_string($i, 0, $user->firstname);
         $myxls->write_string($i, 1, $user->lastname);
         $myxls->write_string($i, 2, $user->idnumber);
         $myxls->write_string($i, 3, $user->email);
         //           $myxls->write_string($i,3,$user->institution);
         //            $myxls->write_string($i,4,$user->department);
         //            $myxls->write_string($i,3,$user->email);
         $j = 4;
         foreach ($this->gtree->items as $itemid => $item) {
             //                if ($export_tracking) {
             //                    $status = $geub->track($grade);
             //                }
             $grade = $this->grades[$key][$itemid];
             $gradeval = $grade->finalgrade;
             // if gradeeditalways then we only want the first displaytype (in case multiple displaytypes are requested)
             $gradedisplaytype = (int) substr((string) $item->get_displaytype(), 0, 1);
             // if we have an accumulated total points that's not accurately reflected in the db, then we want to display the ACCURATE number
             if ($gradedisplaytype == GRADE_DISPLAY_TYPE_REAL && isset($this->grades[$userid][$grade->itemid]->cat_item)) {
                 $items = $this->gtree->items;
                 $grade_values = $this->grades[$userid][$grade->itemid]->cat_item;
                 $grade_maxes = $this->grades[$userid][$grade->itemid]->cat_max;
                 $this_cat = $this->gtree->items[$grade->itemid]->get_item_category();
                 limit_item($this_cat, $items, $grade_values, $grade_maxes);
                 $gradeval = array_sum($grade_values);
                 $item->grademax = array_sum($grade_maxes);
             }
             // is calculating accurate totals store the earned_total for this item to its parent, if there is one
             if (!$grade->is_hidden() && $gradeval != null && $this->accuratetotals) {
                 $this->grades[$userid][$this->gtree->parents[$grade->itemid]->id]->cat_item[$grade->itemid] = $gradeval;
                 $this->grades[$userid][$this->gtree->parents[$grade->itemid]->id]->cat_max[$grade->itemid] = $grade->rawgrademax;
             }
             $gradestr = grade_format_gradevalue($gradeval, $item, true, $gradedisplaytype, null);
             /*
             		   		if ($gradedisplaytype == GRADE_DISPLAY_TYPE_REAL && $this->accuratetotals) {
                                 $gradestr = grade_format_gradevalue($grade->earned_total, $item, true, $gradedisplaytype, null);
                             } else {
                                 $gradestr = grade_format_gradevalue($grade->finalgrade, $item, true, $gradedisplaytype, null);
                             }
             */
             if (is_percentage($gradestr)) {
                 $myxls->write_number($i, $j++, $gradestr * 0.01);
                 //                    $myxls->write_number($i,$j++,substr(trim($gradestr),0,strlen(trim($gradestr))-1), array(num_format=>'Percent'));
             } else {
                 if (is_numeric($gradestr)) {
                     $myxls->write_number($i, $j++, $gradestr);
                 } else {
                     $myxls->write_string($i, $j++, $gradestr);
                 }
             }
             /*
                            // writing feedback if requested
                            if ($this->export_feedback) {
                                $myxls->write_string($i, $j++, $this->format_feedback($userdata->feedbacks[$itemid]));
                            }
             * 
             */
         }
     }
     //        $gui->close();
     //        $geub->close();
     /// Close the workbook
     $workbook->close();
     exit;
 }