Coverage for tasks/isaaqed.py: 71%
28 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-15 14:23 +0100
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-15 14:23 +0100
1"""
2camcops_server/tasks/isaaqed.py
4===============================================================================
6 Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
7 Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
9 This file is part of CamCOPS.
11 CamCOPS is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 CamCOPS is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
24===============================================================================
26** Internet Severity and Activities Addiction Questionnaire, Eating Disorders
27 Appendix (ISAAQ-ED) task. **
29"""
31from typing import Any, Type
33from cardinal_pythonlib.stringfunc import strseq
34from sqlalchemy.sql.sqltypes import Integer
36from camcops_server.cc_modules.cc_db import add_multiple_columns
37from camcops_server.cc_modules.cc_request import CamcopsRequest
38from camcops_server.tasks.isaaqcommon import IsaaqCommon
41class IsaaqEd(
42 IsaaqCommon,
43):
44 __tablename__ = "isaaqed"
45 shortname = "ISAAQ-ED"
47 Q_PREFIX = "e"
48 FIRST_Q = 11
49 LAST_Q = 20
51 @classmethod
52 def extend_columns(cls: Type["IsaaqEd"], **kwargs: Any) -> None:
54 add_multiple_columns(
55 cls,
56 cls.Q_PREFIX,
57 cls.FIRST_Q,
58 cls.LAST_Q,
59 coltype=Integer,
60 minimum=0,
61 maximum=5,
62 comment_fmt=cls.Q_PREFIX + "{n} - {s}",
63 comment_strings=[
64 "pro-ED websites 0-5 (not at all - all the time)",
65 "fitspiration 0-5 (not at all - all the time)",
66 "thinspiration 0-5 (not at all - all the time)",
67 "bonespiration 0-5 (not at all - all the time)",
68 "online dating 0-5 (not at all - all the time)",
69 "calorie tracking 0-5 (not at all - all the time)",
70 "fitness tracking 0-5 (not at all - all the time)",
71 "cyberbullying victimization 0-5 (not at all - all the time)",
72 "mukbang 0-5 (not at all - all the time)",
73 "appearance-focused gaming 0-5 (not at all - all the time)",
74 ],
75 )
77 ALL_FIELD_NAMES = strseq(Q_PREFIX, FIRST_Q, LAST_Q)
79 @staticmethod
80 def longname(req: CamcopsRequest) -> str:
81 _ = req.gettext
82 return _(
83 "Internet Severity and Activities Addiction Questionnaire, "
84 "Eating Disorders Appendix"
85 )
87 def is_complete(self) -> bool:
88 if self.any_fields_none(self.ALL_FIELD_NAMES):
89 return False
91 return True
93 def get_task_html_rows(self, req: CamcopsRequest) -> str:
94 # "Scale" is a visual thing for the original; use "score" here.
95 _ = req.gettext
96 header = """
97 <tr>
98 <th width="70%">{title}</th>
99 <th width="30%">{score}</th>
100 </tr>
101 """.format(
102 title=self.xstring(req, "grid_title"),
103 score=_("Score"),
104 )
106 return header + self.get_task_html_rows_for_range(
107 req, self.Q_PREFIX, self.FIRST_Q, self.LAST_Q
108 )