Skip to content

Commit

Permalink
Merge pull request #303 from edu-pi/develop
Browse files Browse the repository at this point in the history
deploy fron
  • Loading branch information
seroak authored Nov 19, 2024
2 parents 40fa474 + b4d9396 commit 93933ac
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 113 deletions.
13 changes: 10 additions & 3 deletions src/pages/Classroom/components/ClassroomModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ const ClassroomModal = ({ isOpen, onClose, guest }: Props) => {
<div className={styles["popup__content__title"]}>제출 코드</div>
{isLoading ? (
<div>로딩중...</div>
) : studentCode ? (
) : Object.keys(studentCode?.result!).length !== 0? (
<pre className="highlighted-code">
{studentCode.result.split("\n").map((line, index) => (
{studentCode?.result.split("\n").map((line, index) => (
<code key={index} className={styles["code__line"]}>
<span className={styles["line__number"]}>{index + 1}</span>
<SyntaxHighlighter key={`code-${index}-${line}`} language={"python"} style={oneLight}>
Expand All @@ -71,7 +71,14 @@ const ClassroomModal = ({ isOpen, onClose, guest }: Props) => {
))}
</pre>
) : (
<div>코드가 없습니다</div>
<pre className="highlighted-code">
<code key={0} className={styles["code__line"]}>
<span className={styles["line__number"]}>{1}</span>
<SyntaxHighlighter key={`code-${1}`} language={"python"} style={oneLight}>
코드가 없습니다.
</SyntaxHighlighter>
</code>
</pre>
)}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Visualization/VisualizationClassroom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const VisualizationClassroom = () => {
</Split>
<div className="floating-buttons">
{guestStatus?.result === ActionType.HELP && (
<button className="btn btn-complete-summit" disabled={true}>
<button className="btn btn-complete-summit" onClick={handelIngRequest}>
<img
src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6L6 18'%3E%3C/path%3E%3Cpath d='M6 6l12 12'%3E%3C/path%3E%3C/svg%3E"
alt="제출 완료 아이콘"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Console = () => {
return (
<div className={styles["console-wrapper"]}>
<div className={styles["view-section1-2"]}>
<p className={styles["view-section-title"]}>Console</p>
<p className={styles["view-section-title"]}>콘솔</p>
<textarea
className={cx(styles["input-area"], isInputError && styles["input-error"])}
value={inputData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { data_codes, string_codes, operation_codes, control_codes, list_codes, r
import { PreprocessedCodesContext } from "@/pages/Visualization/context/PreProcessedCodesContext.ts";
const Dropdown = () => {
const [isOpen, setIsOpen] = useState(false);
const [selectedOption, setSelectedOption] = useState("샘플 코드");
const [selectedOption, setSelectedOption] = useState("커리큘럼");
const dropdownRef = useRef<HTMLDivElement>(null);
const codeContext = useContext(CodeContext);
if (!codeContext) {
Expand Down Expand Up @@ -47,7 +47,7 @@ const Dropdown = () => {
<div className={styles["select-box"]} ref={dropdownRef}>
<div
className={`${styles["default-option"]} ${
selectedOption !== "샘플 코드" ? styles["is_selected"] : ""
selectedOption !== "커리큘럼" ? styles["is_selected"] : ""
}`}
onClick={toggleDropdown}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ export const data_codes = [
["기본 변수 선언", "# 예제 1: 기본적인 변수 선언\n" +
"name = \"Alice\"\n" +
"age = 25\n" +
"is_student = True\n",
"is_student = True\n" +
"print(name)\n" +
"\n" +
"name = \"Bob\"\n" +
"print(name)\n",
],
["변수의 이름 규칙", "# 예제 2: 변수 이름 규칙 (유효한 변수 이름)\n" +
"my_var = 10\n" +
Expand All @@ -16,11 +20,13 @@ export const data_codes = [
["대소문자 구분", "# 예제 3: 대소문자 구분\n" +
"Var = 5\n" +
"var = 10\n" +
"print(Var, var) # 5와 10 출력",
"\n" +
"print(Var, var)\n",
],
["여러 변수 선언", "# 예제 4: 여러 변수 선언\n" +
"x, y, z = 1, 2, 3\n" +
"print(x, y, z)",
"\n" +
"print(x, y, z)\n",
],
["종합", "# 1. 변수 선언 및 할당\n" +
"name = \"Edupi\" # 문자열 변수\n" +
Expand All @@ -47,21 +53,23 @@ export const data_codes = [
export const string_codes = [
["문자열 인덱싱", "# 예제 1: 문자열 인덱싱\n" +
"text = input()\n" +
"print(text[0]) # P\n" +
"print(text[-1]) # n"],
"\n" +
"print(text[0])\n" +
"print(text[-1])\n"],
["문자열 슬라이싱", "# 예제 2: 문자열 슬라이싱\n" +
"text = \"Hello, Edupi!\"\n" +
"\n" +
"print(\"전체 문자열: \", text)\n" +
"print(\"처음 5글자:\", text[:5]) \n" +
"print(\"5번째부터 끝까지:\", text[5:]) "],
"print(\"5번째부터 끝까지:\", text[5:])\n"],
["문자열 연산", "# 예제 4: 문자열 연산\n" +
"greeting = \"Hello\"\n" +
"name = \"World\"\n" +
"message = greeting + name + \"!\" # 문자열 합치기\n" +
"message = greeting + name + \"!\"\n" +
"print(message)\n" +
"\n" +
"repeat = \"Ha\" * 3\n" +
"print(repeat) # HaHaHa\n",
"print(repeat)\n",
],

];
Expand Down Expand Up @@ -94,8 +102,12 @@ export const operation_codes = [
"print(a != b)\n",
],
["다향 연산자", "# 예제 3: 다항 연산자\n" +
"result = 10 + 5 * 2 - 3 # 우선순위: *, +, -\n" +
"print(result)\n",
"a, b = 10, 5\n" +
"c, d = 2.0, 3.0\n" +
"\n" +
"# 우선순위: *, +, -\n" +
"result = a + b * c + d\n" +
"print(result)\n",
],

];
Expand All @@ -104,89 +116,97 @@ export const control_codes = [
["if-else문", "# 예제 1: if-else문\n" +
"number = int(input())\n" +
"if number > 0:\n" +
" print(\"Positive\")\n" +
" print(\"Positive\")\n" +
"else:\n" +
" print(\"Negative or Zero\")\n",
" print(\"Negative or Zero\")\n",
],
["if-elif-else문", "# 예제 2: if-elif-else문\n" +
"grade = int(input())\n" +
"if grade >= 90:\n" +
" print(\"A\")\n" +
" print(\"A\")\n" +
"elif grade >= 80:\n" +
" print(\"B\")\n" +
" print(\"B\")\n" +
"elif grade >= 70:\n" +
" print(\"C\")\n" +
" print(\"C\")\n" +
"else:\n" +
" print(\"F\")\n",
" print(\"F\")\n" +
"\n" +
"print(\"END\")\n",
],
["중첩 if문", "# 예제 3: 중첩 if문\n" +
"age = 20\n" +
"if age >= 18:\n" +
" if age >= 65:\n" +
" print(\"Senior citizen\")\n" +
" else:\n" +
" print(\"Adult\")\n",
" if age >= 65:\n" +
" print(\"Senior citizen\")\n" +
" else:\n" +
" print(\"Adult\")\n"+
"\n" +
"print(\"END\")\n",
],
];

export const list_codes = [

["리스트 인덱싱", "# 예제 1: 리스트 인덱싱\n" +
"nums = [10, 20, 30, 40]\n" +
"print(nums[0], nums[-1]) # 첫 번째, 마지막 요소\n",
"\n" +
"# 첫 번째, 마지막 요소\n" +
"print(nums[0], nums[-1])\n",
],
["리스트 슬라이싱", "# 예제 2: 리스트 슬라이싱\n" +
"nums = [10, 20, 30, 40]\n" +
"\n" +
"n1 = nums[1:3] # [20, 30]\n" +
"n2 = nums[:2] # [10, 20]\n" +
"n3 = nums[2:] # [30, 40]\n",
"n1 = nums[1:3]\n" +
"print(n1)\n" +
"\n" +
"n2 = nums[:2]\n" +
"print(n1)\n" +
"\n" +
"n3 = nums[2:]\n" +
"print(n1)\n"
,
],
["리스트 정렬", "# 예제 3: 리스트 정렬\n" +
"nums = [3, 1, 4, 1, 5, 9]\n" +
"sorted_nums = sorted(nums)\n",
],
["리스트 합치기", "# 예제 4: 리스트 합치기\n" +
"nums1 = [3, 1, 4, 1, 5, 9]\n" +
"nums2 = [7, 8, 9]\n" +
"combined = nums1 + nums2\n" +
"print(combined)\n",
],
"\n" +
"sorted_nums = sorted(nums)\n" +
"print(sorted_nums)\n",
]
];

export const repeat_codes = [
["for문 기본", "# 예제 1: for문 기본 사용\n" +
"for i in range(1, 10, 2):\n" +
" print(i)\n"],
" print(i)\n"],
["리스트 요소 반복", "# 예제 2: 리스트 요소 반복\n" +
"marks = [90, 25, 67, 45, 80]\n" +
"\n" +
"for number in range(len(marks)):\n" +
" if marks[number] < 60: \n" +
" continue\n" +
" print(f\"{number+1}번 학생 축하합니다. 합격입니다.\")\n",
" if marks[number] < 60: \n" +
" continue\n" +
" print(f\"{number+1}번 학생 축하합니다. 합격입니다.\")\n",
],
["while문 기본", "# 예제 3: while문 기본 사용\n" +
"count = 0\n" +
"while count < 3:\n" +
" print(count)\n" +
" count = count + 1\n" +
" \n" +
" print(count)\n" +
" count = count + 1\n" +
"\n" +
"print(\"END\")\n",
],
["반복문에서 break", "# 예제 4: 반복문에서 break 사용\n" +
"for i in range(10):\n" +
" if i == 2:\n" +
" break\n" +
" print(i)\n" +
" if i == 2:\n" +
" break\n" +
" print(i)\n" +
"\n" +
"print(\"END\")\n",
],
["반복문에서 continue", "# 예제 5: 반복문에서 continue 사용\n" +
"for i in range(10):\n" +
" if i % 2 == 0:\n" +
" continue\n" +
" print(i)\n" +
" if i % 2 == 0:\n" +
" continue\n" +
" print(i)\n" +
" \n" +
"print(\"END\")\n"],
];
Expand All @@ -196,37 +216,20 @@ export const function_codes = [
[
"기본 함수", "# 예제 1: 기본 함수\n" +
"def greet(name):\n" +
" return f\"Hello, {name}!\"\n" +
" return f\"Hello, {name}!\"\n" +
"\n" +
"result = greet(\"Alice\")\n" +
"print(result)\n",
],
[
"지역 변수", "# 예제 2: 지역 변수\n" +
"def local_example():\n" +
" x = 10 # 지역 변수\n" +
" print(x)\n" +
" x = 10 # 지역 변수\n" +
" print(x)\n" +
"\n" +
"local_example()\n" +
"# print(x) # 오류 발생 (x는 함수 외부에서 사용 불가)\n",
],
[
"홀수 짝수 합", "# 숫자가 홀수인지 짝수인지 확인하는 함수\n" +
"def sum_even_odd(nums):\n" +
" odd_sum = 0;\n" +
" even_sum = 0;\n" +
"\n" +
" for num in nums:\n" +
" if num % 2 == 0:\n" +
" even_sum = even_sum + num\n" +
" else:\n" +
" odd_sum = odd_sum + num\n" +
" return even_sum, odd_sum\n" +
"\n" +
"# 함수 호출\n" +
"list2 = [1,2,3,4,5,6]\n" +
"sum_even_odd(list2)\n",
],
[
"최대값 찾기", "# 리스트에서 최대값을 찾는 함수\n" +
"def find_max(numbers):\n" +
Expand Down Expand Up @@ -254,38 +257,27 @@ export const function_codes = [
"area = calculate_area(width, height)\n" +
"perimeter = calculate_perimeter(width, height)\n" +
"\n" +
"print(f\"Area: {area}\") # 출력: Area: 15\n" +
"print(f\"Perimeter: {perimeter}\") # 출력: Perimeter: 16\n",
"print(f\"Area: {area}\")\n" +
"print(f\"Perimeter: {perimeter}\")\n",
],
[
"두 점 사이의 거리", "# 두 점 사이의 x축 차이를 계산하는 함수\n" +
"def delta_x(x1, x2):\n" +
" if x1 > x2:\n" +
" return x1 - x2\n" +
" else:\n" +
" return x2 - x1\n" +
"\n" +
"# 두 점 사이의 y축 차이를 계산하는 함수\n" +
"def delta_y(y1, y2):\n" +
" if y1 > y2:\n" +
" return y1 - y2\n" +
" else:\n" +
" return y2 - y1\n" +
"두 점 사이의 거리", "# 제곱근 구하는 함수\n" +
"def sqrt(a):\n" +
" return a**(1/2)\n" +
"\n" +
"# 두 점 사이의 거리를 계산하는 함수\n" +
"def calculate_distance(x1, y1, x2, y2):\n" +
" dx = delta_x(x1, x2)\n" +
" dy = delta_y(y1, y2)\n" +
" return (dx**2 + dy**2)**0.5\n" +
"def calculate_distance(point1, point2):\n" +
" x_dist = pow(point1[0] - point2[0], 2)\n" +
" y_dist = pow(point1[1] - point2[1], 2)\n" +
" distance = sqrt(x_dist + y_dist)\n" +
" return distance\n" +
"\n" +
"# 사용 예제\n" +
"x1 = 1\n" +
"y1 = 2\n" +
"x2 = 4\n" +
"y2 =6\n" +
"point1 = [1, 2]\n" +
"point2 = [4, 6]\n" +
"\n" +
"distance = calculate_distance(x1, y1, x2, y2)\n" +
"print(f\"Distance: {distance}\") # 출력: Distance: 5.0\n",
"distance = calculate_distance(point1, point2)\n" +
"print(f\"Distance: {distance}\")\n",
],

];
Expand Down
Loading

0 comments on commit 93933ac

Please sign in to comment.