Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
moodle-mod_vpl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caseine
moodle-mod_vpl
Commits
a104e476
Commit
a104e476
authored
5 years ago
by
Astor Bizard
Browse files
Options
Downloads
Patches
Plain Diff
Fixed diff algorithm. Removed zero-diff files from diff graph.
parent
390df423
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
similarity/diff.class.php
+3
-3
3 additions, 3 deletions
similarity/diff.class.php
views/vpl_grapher.class.php
+17
-1
17 additions, 1 deletion
views/vpl_grapher.class.php
with
20 additions
and
4 deletions
similarity/diff.class.php
+
3
−
3
View file @
a104e476
...
...
@@ -474,7 +474,7 @@ class vpl_diff {
* @param string $filedata1
* @param string $filedata2
* @param int $timelimit The maximum amount of time to spend on this computation (in milliseconds).
* If provided and the time limit is exceeded, a
n
exception will be thrown.
* If provided and the time limit is exceeded, a
moodle_
exception
with code 'difftoolarge'
will be thrown.
* @return int The diff in number of chars.
*/
static
public
function
compute_filediff
(
$filedata1
,
$filedata2
,
$timelimit
=
0
)
{
...
...
@@ -500,7 +500,7 @@ class vpl_diff {
while
(
true
)
{
if
(
$timelimit
>
0
&&
microtime
(
true
)
-
$starttime
>
$timelimit
/
1000
)
{
// Time out.
throw
new
E
xception
();
throw
new
moodle_e
xception
(
'difftoolarge'
);
}
while
(
count
(
$queue
[
$priority
])
==
0
)
{
$priority
++
;
...
...
@@ -525,7 +525,7 @@ class vpl_diff {
// Found shortest diff amongst lines.
// Backtrack to compute total diff as a sum of lines diff.
$totaldiff
=
0
;
while
(
$i1
>
0
&&
$i2
>
0
)
{
while
(
$i1
>
0
||
$i2
>
0
)
{
if
(
!
isset
(
$prev
[
$i1
][
$i2
]))
{
$i1
--
;
$i2
--
;
...
...
This diff is collapsed.
Click to expand it.
views/vpl_grapher.class.php
+
17
−
1
View file @
a104e476
...
...
@@ -186,9 +186,25 @@ class vpl_grapher {
if
(
$diff
&&
count
(
$names
)
>
1
)
{
$names
[]
=
get_string
(
'total'
);
$series
[
get_string
(
'total'
)]
=
$totalseries
;
// Filter out all zero-diff files.
$names
=
array_filter
(
$names
,
function
(
$name
)
use
(
&
$series
){
foreach
(
$series
[
$name
]
as
$value
){
if
(
$value
!=
0
)
{
return
true
;
}
}
// All diffs are zero for this file - do not include it.
unset
(
$series
[
$name
]);
return
false
;
});
}
self
::
draw
(
$title
,
get_string
(
'submissions'
,
VPL
)
,
get_string
(
"sizeb"
),
$subsn
,
$series
,
$names
);
}
catch
(
Exception
$e
)
{
}
catch
(
moodle_exception
$e
)
{
if
(
$e
->
errorcode
!=
'difftoolarge'
)
{
// The exception was not thrown by diff calculation, don't catch it.
throw
$e
;
}
global
$PAGE
;
echo
'<span class="chart-area nograph">'
;
echo
'<b>'
.
$title
.
'</b><br>'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment