Skip to content
GitLab
Explore
Sign in
Commits on Source (4)
Show max point penalty only in STYLECHECKER tools, corrected strings
· ba8e1e7e
Justus Dieckmann
authored
Nov 28, 2019
ba8e1e7e
Use 1 point per testcase as default
· a20ed94e
Justus Dieckmann
authored
Nov 18, 2019
a20ed94e
Hide Stylechecker settings and set max pointloss = 0
· 2753205d
Justus Dieckmann
authored
Nov 28, 2019
2753205d
Fix error when trying to edit assignment mit no grades yet
· 6c9d6b99
Justus Dieckmann
authored
Nov 28, 2019
6c9d6b99
Hide whitespace changes
Inline
Side-by-side
init2_form.php
View file @
6c9d6b99
...
...
@@ -59,81 +59,80 @@ class mod_cas_init2_form extends moodleform {
),
$sort
=
''
,
$fields
=
'*'
);
$lang
=
$lang
[
$mycas
->
lang
];
$factor
=
"10.00"
;
//in optionen vorgeben
$assignment
=
new
Assignment
(
$mycas
->
id
);
$mform
=
$this
->
_form
;
foreach
(
$tools
as
$tool
)
{
if
(
$tool
->
type
==
'TESTCASEBASED'
||
$tool
->
type
==
'STYLECHECKER'
)
{
$mform
->
addElement
(
'header'
,
'general'
,
$tool
->
name
);
$mform
->
addElement
(
'text'
,
'weight_'
.
$tool
->
name
,
get_string
(
'weight'
,
'cas'
),
null
);
$mform
->
setDefault
(
'weight_'
.
$tool
->
name
,
$factor
);
//standard gewichtung
// Stylechecker-Tools werden versteckt.
if
(
$tool
->
type
==
'STYLECHECKER'
)
{
$mform
->
addElement
(
'hidden'
,
'weight_'
.
$tool
->
name
,
get_string
(
'weight'
,
'cas'
),
null
);
$mform
->
setDefault
(
'weight_'
.
$tool
->
name
,
0
);
// Keine Punkte abziehen.
$mform
->
setType
(
'weight_'
.
$tool
->
name
,
PARAM_FLOAT
);
$mform
->
addElement
(
'html'
,
'<br>'
);
foreach
(
CommentSeverity
::
values
()
as
$ctype
)
{
$mform
->
addElement
(
'hidden'
,
$tool
->
name
.
'_'
.
$ctype
,
get_string
(
$ctype
,
'cas'
)
.
': '
.
get_string
(
"decrease"
,
'cas'
),
null
);
$mform
->
setDefault
(
$tool
->
name
.
'_'
.
$ctype
,
"0.00"
);
$mform
->
setType
(
$tool
->
name
.
'_'
.
$ctype
,
PARAM_FLOAT
);
}
if
(
$tool
->
conf
)
{
$mform
->
addElement
(
'textarea'
,
'conf_'
.
$tool
->
name
,
get_string
(
'conf'
,
'cas'
),
'wrap="virtual" rows="10" cols="66"'
);
$mform
->
setDefault
(
'conf_'
.
$tool
->
name
,
$tool
->
conf
);
//standard gewichtung
$mform
->
addElement
(
'hidden'
,
'conf_'
.
$tool
->
name
,
get_string
(
'conf'
,
'cas'
));
$mform
->
setDefault
(
'conf_'
.
$tool
->
name
,
$tool
->
conf
);
$mform
->
setType
(
'conf_'
.
$tool
->
name
,
PARAM_RAW
);
}
/* $configs = $DB->get_records('cas_rel2toolconfig', array('cas' => $cas->get_instance()->id, 'tool' => $tool->id), $sort='', $fields = '*');
foreach ($configs as $config) {
$mform->addElement('text', $tool->name.'_'.$config->type, get_string($config->type, 'cas'), null);
$mform->setDefault($tool->name.'_'.$config->type, $config->factor);
} */
if
(
$tool
->
type
==
'TESTCASEBASED'
)
{
$testcases
=
$assignment
->
getTestCases
(
true
);
// Enrich the testcases with the information stored in the database.
$tests_from_db
=
$DB
->
get_records
(
'cas_tests'
,
array
(
'cas'
=>
$mycas
->
id
));
foreach
(
$tests_from_db
as
$test
)
{
foreach
(
$testcases
as
$testcase
)
{
if
(
$test
->
name
==
$testcase
->
getName
()
&&
$test
->
type
==
$testcase
->
getType
()){
$testcase
->
setDescr
(
$test
->
descr
);
$testcase
->
setFactor
(
$test
->
factor
);
}
}
}
continue
;
}
if
(
$tool
->
type
==
'TESTCASEBASED'
)
{
$mform
->
addElement
(
'header'
,
'general'
,
$tool
->
name
);
$k
=
0
;
if
(
$tool
->
conf
)
{
$mform
->
addElement
(
'textarea'
,
'conf_'
.
$tool
->
name
,
get_string
(
'conf'
,
'cas'
),
'wrap="virtual" rows="10" cols="66"'
);
$mform
->
setDefault
(
'conf_'
.
$tool
->
name
,
$tool
->
conf
);
// Standardgewichtung
$mform
->
setType
(
'conf_'
.
$tool
->
name
,
PARAM_RAW
);
}
$testcases
=
$assignment
->
getTestCases
(
true
);
// Enrich the testcases with the information stored in the database.
$tests_from_db
=
$DB
->
get_records
(
'cas_tests'
,
array
(
'cas'
=>
$mycas
->
id
));
foreach
(
$tests_from_db
as
$test
)
{
foreach
(
$testcases
as
$testcase
)
{
if
(
$testcase
->
getType
()
==
"EVALUATION"
)
{
$k
++
;
if
(
$test
->
name
==
$testcase
->
getName
()
&&
$test
->
type
==
$testcase
->
getType
())
{
$testcase
->
setDescr
(
$test
->
descr
);
$testcase
->
setFactor
(
$test
->
factor
);
}
}
}
$quanti
=
(
$k
==
0
)
?
"0.00"
:
(
round
(
$factor
/
$k
,
0
)
.
".00"
);
$i
=
0
;
$k
=
0
;
foreach
(
$testcases
as
$testcase
)
{
$mform
->
addElement
(
'textarea'
,
$tool
->
name
.
'_'
.
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
()
.
'_desc'
,
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
(),
'wrap="virtual" rows="5" cols="50"'
);
$mform
->
setDefault
(
$tool
->
name
.
'_'
.
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
()
.
'_desc'
,
$testcase
->
getDescr
());
if
(
$testcase
->
getType
()
==
TestType
::
PREPARATORY
)
{
//nur beschreiben
}
elseif
(
$testcase
->
getType
()
==
TestType
::
EVALUATION
)
{
if
(
$testcase
->
getFactor
())
{
$quanti
=
$testcase
->
getFactor
();
}
else
if
(
++
$i
===
$k
)
{
$quanti
=
(
$factor
-
(
$k
-
1
)
*
$quanti
)
.
".00"
;
//verteilt Bewertungsanteil auf einzelne Testcases
}
$mform
->
addElement
(
'text'
,
$tool
->
name
.
'_'
.
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
(),
get_string
(
'decrease'
,
'cas'
),
null
);
$mform
->
setDefault
(
$tool
->
name
.
'_'
.
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
(),
$quanti
);
$mform
->
setType
(
$tool
->
name
.
'_'
.
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
(),
PARAM_FLOAT
);
}
$mform
->
addElement
(
'html'
,
'<br>'
);
foreach
(
$testcases
as
$testcase
)
{
if
(
$testcase
->
getType
()
==
"EVALUATION"
)
{
$k
++
;
}
}
$points
=
"1.00"
;
foreach
(
$testcases
as
$testcase
)
{
$mform
->
addElement
(
'textarea'
,
$tool
->
name
.
'_'
.
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
()
.
'_desc'
,
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
(),
'wrap="virtual" rows="5" cols="50"'
);
$mform
->
setDefault
(
$tool
->
name
.
'_'
.
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
()
.
'_desc'
,
$testcase
->
getDescr
());
if
(
$testcase
->
getType
()
==
TestType
::
PREPARATORY
)
{
//nur beschreiben
}
else
if
(
$testcase
->
getType
()
==
TestType
::
EVALUATION
)
{
if
(
$testcase
->
getFactor
())
{
$points
=
$testcase
->
getFactor
();
}
}
elseif
(
$tool
->
type
==
'STYLECHECKER'
)
{
foreach
(
CommentSeverity
::
values
()
as
$ctype
)
{
//$factor = $DB->get_record('cas_rel2tools', array('cas' => $cas->get_instance()->id, 'tool' => $tool->id, 'commenttype' => $ctype->id), $fields = 'factor', $strictness = IGNORE_MISSING);
$mform
->
addElement
(
'text'
,
$tool
->
name
.
'_'
.
$ctype
,
get_string
(
$ctype
,
'cas'
)
.
': '
.
get_string
(
"decrease"
,
'cas'
),
null
);
$mform
->
setDefault
(
$tool
->
name
.
'_'
.
$ctype
,
"2.00"
);
$mform
->
setType
(
$tool
->
name
.
'_'
.
$ctype
,
PARAM_FLOAT
);
$mform
->
addElement
(
'text'
,
$tool
->
name
.
'_'
.
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
(),
get_string
(
'decrease'
,
'cas'
),
null
);
$mform
->
setDefault
(
$tool
->
name
.
'_'
.
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
(),
$points
);
$mform
->
setType
(
$tool
->
name
.
'_'
.
$testcase
->
getType
()
.
"_"
.
$testcase
->
getName
(),
PARAM_FLOAT
);
}
$mform
->
addElement
(
'html'
,
'<br>'
);
}
}
}
...
...
lang/en/cas.php
View file @
6c9d6b99
...
...
@@ -58,8 +58,8 @@ $string['description'] = 'Aufgabentext';
$string
[
'lang'
]
=
'Programmiersprache'
;
$string
[
'duedate'
]
=
'Abgabefrist'
;
$string
[
'maxpoints'
]
=
'erreichbare Punkte'
;
$string
[
'weight'
]
=
'
Anteil an Bewertung (in %)
'
;
$string
[
'decrease'
]
=
'
Abzug in %
'
;
$string
[
'weight'
]
=
'
Maximaler Punktabzug in dieser Kategorie in % der Gesamtpunktzahl
'
;
$string
[
'decrease'
]
=
'
Punktabzug
'
;
$string
[
'points'
]
=
'Punkte'
;
$string
[
'pointnum'
]
=
'Punktzahl'
;
$string
[
'predefinedfiles'
]
=
'Vorgegebene Dateien'
;
...
...
locallib.php
View file @
6c9d6b99
...
...
@@ -160,9 +160,9 @@ class cas {
// update grades (max_points)
if
(
!
empty
(
$this
->
instance
))
{
$grade_item_id
=
$DB
->
get_record
(
'grade_items'
,
array
(
'itemtype'
=>
'mod'
,
'itemmodule'
=>
'cas'
,
'iteminstance'
=>
$this
->
instance
->
id
),
'id'
)
->
id
;
if
(
$grade_item_id
)
{
$grade
=
$DB
->
get_record
(
'grade_items'
,
array
(
'itemtype'
=>
'mod'
,
'itemmodule'
=>
'cas'
,
'iteminstance'
=>
$this
->
instance
->
id
),
'id'
);
if
(
$grade
&&
$grade
->
id
)
{
$grade_item_id
=
$grade
->
id
;
$grade_item
=
new
stdClass
();
$grade_item
->
id
=
$grade_item_id
;
$grade_item
->
grademax
=
$this
->
instance
->
grade
;
...
...