Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-qtype_stack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-qtype_stack
Commits
b42507fe
Unverified
Commit
b42507fe
authored
11 months ago
by
Chris Sangwin
Committed by
GitHub
11 months ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1219 from Mat-Ge/patch-decimalplaces
decimalplaces(ex,n) for n=0 or integerp(ex); two test cases
parents
1afbea5c
650bafc3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
stack/maxima/assessment.mac
+8
-2
8 additions, 2 deletions
stack/maxima/assessment.mac
tests/castext_test.php
+5
-5
5 additions, 5 deletions
tests/castext_test.php
with
13 additions
and
7 deletions
stack/maxima/assessment.mac
+
8
−
2
View file @
b42507fe
...
@@ -736,7 +736,13 @@ decimalplacesfun(ex, n, dispdps) := block([ex2],
...
@@ -736,7 +736,13 @@ decimalplacesfun(ex, n, dispdps) := block([ex2],
if dispdps then ex2:displaydp(ex2, n),
if dispdps then ex2:displaydp(ex2, n),
return(ex2)
return(ex2)
)$
)$
decimalplaces(ex, n) := decimalplacesfun(ex, n, false)$
decimalplaces(ex, n):= block(
if n=0 then return(round(ex)),
if integerp(ex) then return(ex),
decimalplacesfun(ex, n, false)
)$
dispdp(ex, n) := block(
dispdp(ex, n) := block(
if not(real_numberp(ex)) then error("dispdp requires a real number argument."),
if not(real_numberp(ex)) then error("dispdp requires a real number argument."),
if not(integerp(n)) then error("dispdp cannot create a non-integer number of decimal places."),
if not(integerp(n)) then error("dispdp cannot create a non-integer number of decimal places."),
...
...
This diff is collapsed.
Click to expand it.
tests/castext_test.php
+
5
−
5
View file @
b42507fe
...
@@ -816,12 +816,12 @@ class castext_test extends qtype_stack_testcase {
...
@@ -816,12 +816,12 @@ class castext_test extends qtype_stack_testcase {
}
}
$cs2
=
new
stack_cas_session2
(
$s2
,
null
,
0
);
$cs2
=
new
stack_cas_session2
(
$s2
,
null
,
0
);
$at1
=
castext2_evaluatable
::
make_from_source
(
'{@dispdp(a,2)@}, {@dispdp(b,3)@}, {@dispsf(b,4)@}'
,
'test-case'
);
$at1
=
castext2_evaluatable
::
make_from_source
(
'{@dispdp(a,2)@}, {@dispdp(b,3)@}, {@dispsf(b,4)@}
, {@decimalplaces(a,0)@}, {@decimalplaces(1,2)@}
'
,
'test-case'
);
$this
->
assertTrue
(
$at1
->
get_valid
());
$this
->
assertTrue
(
$at1
->
get_valid
());
$cs2
->
add_statement
(
$at1
);
$cs2
->
add_statement
(
$at1
);
$cs2
->
instantiate
();
$cs2
->
instantiate
();
$this
->
assertEquals
(
'\({2.72}\), \({4.000}\), \({4.000}\)'
,
$at1
->
get_rendered
());
$this
->
assertEquals
(
'\({2.72}\), \({4.000}\), \({4.000}\)
, \({3}\), \({1}\)
'
,
$at1
->
get_rendered
());
}
}
/**
/**
...
@@ -835,12 +835,12 @@ class castext_test extends qtype_stack_testcase {
...
@@ -835,12 +835,12 @@ class castext_test extends qtype_stack_testcase {
}
}
$cs2
=
new
stack_cas_session2
(
$s2
,
null
,
0
);
$cs2
=
new
stack_cas_session2
(
$s2
,
null
,
0
);
$at1
=
castext2_evaluatable
::
make_from_source
(
'{@dispdp(a,0)*x^2@}, {@dispdp(b,3)@}, {@dispsf(b,4)@}'
,
'test-case'
);
$at1
=
castext2_evaluatable
::
make_from_source
(
'{@dispdp(a,0)*x^2@}, {@dispdp(b,3)@}, {@dispsf(b,4)@}
, {@decimalplaces(a,0)@}, {@decimalplaces(1,2)@}
'
,
'test-case'
);
$this
->
assertTrue
(
$at1
->
get_valid
());
$this
->
assertTrue
(
$at1
->
get_valid
());
$cs2
->
add_statement
(
$at1
);
$cs2
->
add_statement
(
$at1
);
$cs2
->
instantiate
();
$cs2
->
instantiate
();
$this
->
assertEquals
(
'\({3\cdot x^2}\), \({-4.000}\), \({-4.000}\)'
,
$at1
->
get_rendered
());
$this
->
assertEquals
(
'\({3\cdot x^2}\), \({-4.000}\), \({-4.000}\)
, \({3}\), \({1}\)
'
,
$at1
->
get_rendered
());
}
}
/**
/**
...
@@ -854,7 +854,7 @@ class castext_test extends qtype_stack_testcase {
...
@@ -854,7 +854,7 @@ class castext_test extends qtype_stack_testcase {
}
}
$cs2
=
new
stack_cas_session2
(
$s2
,
null
,
0
);
$cs2
=
new
stack_cas_session2
(
$s2
,
null
,
0
);
$at1
=
castext2_evaluatable
::
make_from_source
(
'{@dispdp(a1,0)*x^2@}, {@dispdp(b,3)@}, {@dispsf(b,4)@}'
,
'test-case'
);
$at1
=
castext2_evaluatable
::
make_from_source
(
'{@dispdp(a1,0)*x^2@}, {@dispdp(b,3)@}, {@dispsf(b,4)@}
, {@decimalplaces(a,0)@}, {@decimalplaces(1,2)@}
'
,
'test-case'
);
$this
->
assertTrue
(
$at1
->
get_valid
());
$this
->
assertTrue
(
$at1
->
get_valid
());
$cs2
->
add_statement
(
$at1
);
$cs2
->
add_statement
(
$at1
);
$cs2
->
instantiate
();
$cs2
->
instantiate
();
...
...
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