Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add new feature #10

Closed
wants to merge 1 commit into from

2 participants

@chillofoctober

now grades may be in percent form or in original mark form

@andreev-artem
Collaborator

Rejected due gradebook problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
3  db/install.xml
@@ -9,7 +9,8 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" COMMENT="id of the table, please edit me" NEXT="course"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="course" NEXT="grade"/>
- <FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="100" SEQUENCE="false" COMMENT="This is maximum grade for instance" PREVIOUS="name"/>
+ <FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="100" SEQUENCE="false" COMMENT="This is maximum grade for instance" PREVIOUS="name" NEXT="num_percent"/>
+ <FIELD NAME="num_percent" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="grade in gradebook in numbers or percents" PREVIOUS="grade"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attforblock"/>
View
10 db/upgrade.php
@@ -326,6 +326,16 @@ function xmldb_attforblock_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2011061800, 'attforblock');
}
+ if ($oldversion < 2012011300)
+ {
+ $table = new xmldb_table('attforblock');
+
+ $field = new xmldb_field('num_percent');
+ $field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'grade');
+ $dbman->add_field($table, $field);
+
+ upgrade_mod_savepoint(true, 2012011300, 'attforblock');
+ }
return $result;
}
View
1  lang/en/attforblock.php
@@ -112,6 +112,7 @@
$string['nosessionexists'] = 'No Session exists for this course';
$string['nosessionsselected'] = 'No sessions selected';
$string['notfound'] = 'Attendance activity not found in this course!';
+$string['num_percent'] = 'Mark, not percent';
$string['olddate'] = 'Old date';
$string['period'] = 'Frequency';
$string['pluginname'] = 'Attendance';
View
1  lang/ru/attforblock.php
@@ -98,6 +98,7 @@
$string['nosessionexists'] = 'В данном курсе отсутствуют занятия. Сначала добавьте их';
$string['nosessionsselected'] = 'Не выбрано ни одного занятия';
$string['notfound'] = 'Элемент курса - \"Посещаемость\" не найден в данном курсе!';
+$string['num_percent'] = 'Баллы, не проценты';
$string['olddate'] = 'Старая дата';
$string['period'] = 'Периодичность';
$string['pluginname'] = 'Посещаемость';
View
22 locallib.php
@@ -477,6 +477,9 @@ class attforblock {
/** @var float number (10, 5) unsigned, the maximum grade for attendance */
public $grade;
+/** new object for various grading */
+ public $num_percent;
+
/** current page parameters */
public $pageparams;
@@ -983,7 +986,7 @@ public function update_users_grade($userids) {
foreach ($userids as $userid) {
$grades[$userid]->userid = $userid;
- $grades[$userid]->rawgrade = att_calc_user_grade_percent($this->get_user_grade($userid), $this->get_user_max_grade($userid));
+ $grades[$userid]->rawgrade = att_calc_user_grade_percent($this->get_user_grade($userid), $this->get_user_max_grade($userid),$this->num_percent);
}
return grade_update('mod/attforblock', $this->course->id, 'mod', 'attforblock',
@@ -1229,7 +1232,8 @@ function att_get_user_courses_attendances($userid) {
list($usql, $uparams) = $DB->get_in_or_equal(array_keys($usercourses), SQL_PARAMS_NAMED, 'cid0');
$sql = "SELECT att.id as attid, att.course as courseid, course.fullname as coursefullname,
- course.startdate as coursestartdate, att.name as attname, att.grade as attgrade
+ course.startdate as coursestartdate, att.name as
+attname, att.grade as attgrade
FROM {attforblock} att
JOIN {course} course
ON att.course = course.id
@@ -1241,11 +1245,17 @@ function att_get_user_courses_attendances($userid) {
return $DB->get_records_sql($sql, $params);
}
-function att_calc_user_grade_percent($grade, $maxgrade) {
- if ($maxgrade == 0)
+function att_calc_user_grade_percent($grade, $maxgrade, $num_percent) {
+ if ($maxgrade == 0)
return 0;
- else
- return $grade / $maxgrade * 100;
+ else
+ if ($num_percent==1) {
+ return $grade;
+ }
+ else
+ {
+ return $grade / $maxgrade * 100;
+ }
}
function att_update_all_users_grades($attid, $course, $context) {
View
2  mod_form.php
@@ -23,6 +23,8 @@ function definition() {
$mform->addElement('modgrade', 'grade', get_string('grade'));
$mform->setDefault('grade', 100);
+ $mform->addElement('advcheckbox','num_percent', get_string('num_percent','attforblock'));
+ $mform->setDefault('num_percent',0);
//-------------------------------------------------------------------------------
View
4 version.php
@@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2011071600; // The current module version (Date: YYYYMMDDXX)
-$module->release = '2.4.0';
+$module->version = 2012011300; // The current module version (Date: YYYYMMDDXX)
+$module->release = '2.4.1';
$module->cron = 0; // Period for cron to check this module (secs)
?>
Something went wrong with that request. Please try again.