コード例 #1
0
ファイル: learning_objectives.php プロジェクト: jamesmcq/elis
 function get_options($data)
 {
     if (is_array($data) && isset($data['obj']) && !empty($data['obj']->id)) {
         $dataobject = $data['obj'];
         if (property_exists($dataobject, 'name')) {
             $course = new course($dataobject);
         } else {
             if (property_exists($dataobject, 'courseid')) {
                 $course = new course($dataobject->courseid);
             } else {
                 return array();
             }
         }
         $compelems = $course->get_completion_elements();
     } else {
         // just get ALL completion elements (LOs)
         global $DB;
         $compelems = $DB->get_recordset('local_elisprogram_crs_cmp', null, '', 'id, name, idnumber');
     }
     $result = array('' => get_string('anyvalue', 'filters'));
     foreach ($compelems as $compelem) {
         $result[$compelem->idnumber] = "{$compelem->name} ({$compelem->idnumber})";
     }
     unset($compelems);
     return $result;
 }
コード例 #2
0
 function get_completion_page($crsid)
 {
     global $CFG;
     $output = '';
     $crs = new course($crsid);
     $table = new stdClass();
     $elements = $crs->get_completion_elements();
     if ($elements) {
         $columns = array('idnumber' => get_string('completion_idnumber', 'block_curr_admin'), 'name' => get_string('completion_name', 'block_curr_admin'), 'description' => get_string('completion_description', 'block_curr_admin'), 'completion_grade' => get_string('completion_grade', 'block_curr_admin'), 'required' => get_string('required', 'block_curr_admin'));
         foreach ($columns as $column => $cdesc) {
             $columndir = "ASC";
             $columnicon = $columndir == "ASC" ? "down" : "up";
             $columnicon = " <img src=\"{$CFG->pixpath}/t/{$columnicon}.gif\" alt=\"\" />";
             ${$column} = $cdesc;
             $table->head[] = ${$column};
             $table->align[] = "left";
             $table->wrap[] = false;
         }
         $table->head[] = "";
         $table->align[] = "center";
         $table->wrap[] = true;
         foreach ($elements as $element) {
             $deletebutton = '<a href="index.php?s=crs&amp;section=curr&amp;action=delem&amp;id=' . $crs->id . '&amp;elemid=' . $element->id . '">' . '<img src="pix/delete.gif" alt="Delete" title="Delete" /></a>';
             $editbutton = '<a href="index.php?s=crs&amp;section=curr&amp;action=eelem&amp;id=' . $crs->id . '&amp;elemid=' . $element->id . '">' . '<img src="pix/edit.gif" alt="Edit" title="Edit" /></a>';
             $newarr = array();
             foreach ($columns as $column => $cdesc) {
                 if ($column == 'required') {
                     $newarr[] = empty($element->required) ? get_string('no') : get_string('yes');
                 } else {
                     $newarr[] = $element->{$column};
                 }
             }
             $newarr[] = $editbutton . ' ' . $deletebutton;
             $table->data[] = $newarr;
         }
         $output .= print_table($table, true);
     } else {
         $output .= '<div align="center">' . get_string('no_completion_elements', 'block_curr_admin') . '</div>';
     }
     $output .= '<br clear="all" />' . "\n";
     $output .= '<div align="center">';
     $options = array('s' => 'crs', 'section' => 'curr', 'action' => 'celem', 'id' => $crs->id);
     $output .= print_single_button('index.php', $options, 'Add Element', 'get', '_self', true, 'Add New Element');
     $output .= '</div>';
     return $output;
 }
コード例 #3
0
ファイル: coursepage.class.php プロジェクト: jamesmcq/elis
 function get_completion_page($crsid)
 {
     global $CFG, $OUTPUT;
     $output = '';
     $crs = new course($crsid);
     $table = new stdClass();
     $elements = $crs->get_completion_elements();
     if (!empty($elements) && $elements->valid() === true) {
         $columns = array('idnumber' => array('header' => get_string('completion_idnumber', 'local_elisprogram')), 'name' => array('header' => get_string('completion_name', 'local_elisprogram')), 'description' => array('header' => get_string('completion_description', 'local_elisprogram')), 'completion_grade' => array('header' => get_string('completion_grade', 'local_elisprogram')), 'required' => array('header' => get_string('required', 'local_elisprogram')));
         if ($this->can_do_edit()) {
             $columns['actions'] = array('header' => '', 'display_function' => 'htmltab_display_function', 'sortable' => false);
         }
         foreach ($columns as $column => $cdesc) {
             $columndir = "ASC";
             $columnicon = $columndir == "ASC" ? "down" : "up";
             $columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
             ${$column} = $cdesc;
             $table->head[] = ${$column};
             $table->align[] = "left";
             $table->wrap[] = false;
         }
         $table->head[] = "";
         $table->align[] = "center";
         $table->wrap[] = true;
         $newarr = array();
         $editstr = get_string('edit');
         $editiconattrs = array('class' => 'elisicon-edit elisicon', 'alt' => $editstr, 'title' => $editstr);
         $delstr = get_string('delete');
         $deliconattrs = array('class' => 'elisicon-remove elisicon', 'alt' => $delstr, 'title' => $delstr);
         foreach ($elements as $element) {
             $editurl = 'index.php?s=crs&section=curr&action=eelem&id=' . $crs->id . '&elemid=' . $element->id;
             $editbutton = html_writer::link($editurl, '', $editiconattrs);
             $delurl = 'index.php?s=crs&section=curr&action=delem&id=' . $crs->id . '&elemid=' . $element->id;
             $deletebutton = html_writer::link($delurl, '', $deliconattrs);
             $newobj = new stdClass();
             foreach ($columns as $column => $cdesc) {
                 if ($column == 'required') {
                     $newobj->required = empty($element->required) ? get_string('no') : get_string('yes');
                 } else {
                     if ($column == 'actions') {
                         $newobj->actions = $editbutton . ' ' . $deletebutton;
                     } else {
                         $newobj->{$column} = $element->{$column};
                     }
                 }
             }
             $newarr[] = $newobj;
         }
         $table = new display_table($newarr, $columns);
         $output .= $table->get_html();
     } else {
         $output .= '<div align="center">' . get_string('no_completion_elements', 'local_elisprogram') . '</div>';
     }
     unset($elements);
     $output .= '<br clear="all" />' . "\n";
     if ($this->can_do_edit()) {
         $options = array('s' => 'crs', 'section' => 'curr', 'action' => 'celem', 'id' => $crs->id);
         $addelement = get_string('add_element', 'local_elisprogram');
         $button = new single_button(new moodle_url('index.php', $options), $addelement, 'get', array('disabled' => false, 'title' => $addelement, 'id' => ''));
         $output .= html_writer::tag('div', $OUTPUT->render($button), array('align' => 'center'));
     }
     return $output;
 }
コード例 #4
0
ファイル: pmclass.class.php プロジェクト: jamesmcq/elis
 /**
  * Update enrolment status of users enroled in the current class, completing and locking
  * records where applicable based on class grade and required completion elements
  *
  * @param int $pmuserid  optional userid to update, default(0) updates all users
  */
 function update_enrolment_status($pmuserid = 0)
 {
     //information about which course this belongs to may not have been
     //loaded due to lazy-loading
     $this->load();
     //        if (isset($this->course) && (get_class($this->course) == 'course')) {
     if (isset($this->courseid)) {
         $course = new course($this->courseid);
         $elements = $course->get_completion_elements();
     } else {
         $elements = false;
     }
     $timenow = time();
     if (!empty($elements) && $elements->valid() === true) {
         // for each student, find out how many required completion elements are
         // incomplete, and when the last completion element was graded
         $sql = 'SELECT s.*, grades.incomplete, grades.maxtime
                   FROM {' . student::TABLE . '} s
                   JOIN (SELECT s.userid, COUNT(CASE WHEN grades.id IS NULL AND cc.required = 1 THEN 1
                                                     ELSE NULL END) AS incomplete,
                                 MAX(timegraded) AS maxtime
                           FROM {' . student::TABLE . '} s
                           JOIN {' . coursecompletion::TABLE . '} cc
                                ON cc.courseid = :courseid
                      LEFT JOIN {' . student_grade::TABLE . '} grades
                                ON grades.userid = s.userid
                                   AND grades.completionid = cc.id
                                   AND grades.classid = :joinclassid
                                   AND grades.grade >= cc.completion_grade
                          WHERE s.classid = :innerclassid AND s.locked = 0
                       GROUP BY s.userid
                        ) grades ON grades.userid = s.userid
                  WHERE s.classid = :outerclassid AND s.locked = 0';
         $params = array('courseid' => $this->courseid, 'joinclassid' => $this->id, 'innerclassid' => $this->id, 'outerclassid' => $this->id);
         if ($pmuserid) {
             $sql .= ' AND s.userid = :userid';
             $params['userid'] = $pmuserid;
         }
         $rs = $this->_db->get_recordset_sql($sql, $params);
         foreach ($rs as $rec) {
             if ($rec->incomplete == 0 && $rec->grade > 0 && $rec->grade >= $this->course->completion_grade) {
                 $student = new student($rec);
                 $student->completestatusid = STUSTATUS_PASSED;
                 $student->completetime = $rec->maxtime;
                 $student->credits = $this->course->credits;
                 $student->locked = 1;
                 $student->complete();
             }
         }
     } else {
         /// We have no completion elements so just make sure the user's grade is at least the
         /// minimum value required for the course.
         /// Get all unlocked enrolments
         $stufilters = array(new field_filter('classid', $this->id), new field_filter('locked', 0));
         if ($pmuserid) {
             $stufilters[] = new field_filter('userid', $pmuserid);
         }
         $rs = student::find($stufilters);
         foreach ($rs as $rec) {
             if ($rec->grade > 0 && $rec->grade >= $this->course->completion_grade) {
                 $rec->completestatusid = STUSTATUS_PASSED;
                 $rec->completetime = $timenow;
                 $rec->credits = $this->course->credits;
                 $rec->locked = 1;
                 $rec->complete();
             }
         }
     }
     unset($elements);
 }